We are glad to announce that, as of last week, Codility tests can also be solved in Scala. Judging from the numerous requests from both our clients and programmers, this elegant object-functional programming language is definitely gaining momentum!
In June, we were happy to welcome Grzegorz Kossakowski at our Warsaw office. It was a stroke of luck, really, since Grzegorz is the person hacking the Scala compiler at Typesafe, the “mothership” of Scala, and thus the best consultant and beta-tester for our Scala support that we could have wished for.
Let’s give the floor to Grzegorz and Paweł, creators of Codility’s Scala support, for a Q&A on Scala:
Codility: What fascinates you most about Scala?
Grzegorz Kossakowski: I got interested in Scala four years ago. Right from the beginning I was struck by the elegance of Scala’s design. Scala is built on a very solid mathematical foundation, but at the same it addresses very down-to-earth problems, like providing good compiler error messages, and interoperability with the Java ecosystem. Scala offers a very interesting mixture of Functional and Object-Oriented programming paradigms in a way that combines the best of both worlds. To my surprise, my fascination with Scala led me all the way to hacking the Scala compiler full time!
C: What was most challenging in adding Scala support to Codility?
Paweł Marczewski: The biggest challenge was the start-up time—both for the Scala compiler and for programs written in Scala. We aim to give our candidates immediate feedback when they solve our test, and this is why a long start-up time is troublesome. We do not keep a Java virtual machine or Scala runtime constantly working in the background because we need to give the candidates equal testing conditions. However, we managed to improve the running times by caching some results. Surely, thanks to Grzegorz, future versions of Scala will also improve in that regard.
C: Why is Scala’s start-up time slow?
GK: Although the start-up time of the Scala compiler is not at the top of the list of performance problems we are currently trying to address, my meeting with Paweł from Codility inspired me to do some profiling. The initial results I got suggested that we are spending surprisingly long periods of time scanning the classpath. That’s the logic responsible for opening jar files and listing all the files stored in them. I was expecting to find that we were spending time in more complicated parts of the Scala compiler. However, to get definitive conclusions (and improvements), more work is needed. I found the meeting with Codility very valuable because it’s the first time we have a very clear use case for improving the Scala compiler’s performance, instead of just advising people to use sbt or IDE.
C: What kinds of companies would benefit most from adopting Scala and how does Typesafe help out?
GK: There are many reasons to use Scala, but since we are discussing the hiring process I should mention that companies using Scala very often have an easier time hiring good engineers. The reason for this is that good engineers want to work with modern tools, including programming languages, and the use of Scala is a good signal that a given organization is a little ahead of the competition in that regard. I believe that Typesafe helps make Scala more than just an attracting hiring advantage: by providing support and by polishing rough edges in Scala we are making Scala a very solid and productive platform on which even the largest companies can build their software.
C: How does problem-solving in Scala differ from solving problems in imperative languages?
PM: Of all the languages we currently support at Codility, Scala is probably the most suitable for functional programming. While our tasks have so far been used mostly to test programming ability in imperative programming languages, they are actually exactly the kind of algorithmic problems that can help show off the strength of the functional paradigm.
GK: I solved some of Codility’s problems just for fun, and I noticed that Scala’s powerful collections help to make the solution’s code more succinct and clear. Instead of dealing with low-level operations one can focus on the core of the problem.
Thanks both of you for making it happen!