Scala.Net and Scala with Martin Odersky
We talked to Martin Odersky, Chairman and Chief Architect as well as co-founder of Typesafe about Scala.Net, the version of Scala that support .Net, as well as about Scala in general. Martin is the creator of the Scala programming language, and a professor in the programming research group at EPFL, the leading technical university in Switzerland. Throughout his career, Martin's singular objective has been to make the basic job of writing programs faster, easier and more enjoyable.
In the process he has personally written more lines of Java and Scala code than almost any other individual in the world. He wrote javac, the compiler used by the majority of today’s Java programmers, and scalac, the compiler used by the fast-growing Scala community. He authored "Programming in Scala," the best-selling book on Scala. Previously he has held positions at IBM Research, Yale University, University of Karlsruhe and University of South Australia, after having obtained his doctorate in 1989 from ETH Zürich as a student of Niklaus Wirth, the creator of Pascal.
InfoQ: A few years ago there already had been a Scala version for .NET which disappeared. So why do you consider it important to provide Scala on .NET?
Martin Odersky: Scala .Net has a complex history, that’s rarely discussed outside the hacker community. Individuals like Nikolay Mihaylov and Lukas Rytz made great progress creating a cross-compiler, and Miguel Garcia, part of the Scala group at EPFL, has worked diligently to get the cross-compiler to actually bootstrap itself to the .Net environment - in order to have a executable Scala.net that compiles its own sources - which he refers to as “a classic chicken and egg problem of colossal proportions.“
Also, there are many reasons why it’s valuable to have Scala on .Net, both for developers and companies in general. Developers have to learn just one language to suit both environments, and companies can move scarce resources, good developers, easily between platforms to save money and increase flexibility.
Given the concise and highly productive nature of Scala, by using Scala on .Net, developers are able to quickly deploy applications across the two major industry platforms: JVM and .Net. .Net provides an integration platform for several languages and this implementation of Scala inter-operates nicely. You can use existing .Net libraries or applications without re-writing everything in Scala. Ultimately it means that many tools and applications created for the .Net and JVM environments can be ported from one to the other. This works to everyone’s advantage.
InfoQ: How do you think Scala.Net will compete with F#?
Martin Odersky: Very little, perhaps more over time. Scala offers quite different capabilities, the integration of Object Oriented with the Functional programming style. Scala on .Net gives most benefits to developers wanting to write code that they would like to run on both the JVM and .Net. It is likely that most people who use F# will continue to use it.
Some may start to use Scala on .Net too as it would allow them to run that code on the JVM.
InfoQ: What Scala versions will be supported?
Martin Odersky: The latest version of Scala will be supported, delayed by perhaps a few days while the .Net version is built and tested.
InfoQ: How exactly did you move Scala to .NET and what have been the main benefits and challenges?
Martin Odersky: According to Miguel Garcia, one of the major challenges was that Scala programs make heavy use of the Java JDK and this is just not supported under .Net. So, we had to come up with a compiler that generated suitable code for .Net. While the cross-compiler was a great piece of work, it ran on JDK only so its sources had a lot of dependencies on JDK APIs.
A long running open source project, IKVM, driven by Jeroen Frijters that allows Java programs to be converted to MSIL and a .Net library that provides the basic JDK support, provided an excellent foundation for the effort to port the Scala library to .Net. The IKVM compiler takes JVM byte code and turns it into .net assembly. This byte code level change, although a big step, does not in itself bring us to true bootstrapping because we are still left with the JDK dependencies. The task therefore became creating a pre-processor that would modify the Scala source code directly replacing JDK dependencies with IKVM .Net equivalents, a major mapping exercise.
InfoQ: There is a preliminary version available for download. How am I supposed to develop programs with Scala for .NET?
Martin Odersky: So, you can develop Scala programs directly in MS Visual Studio. This fall, the Visual Studio plug-in for Scala will support the basic functionality expected of the IDE: code completion, code browsing, line breaks, expression breaks and exception reporting and so on.
For now, the current plug-in does not yet support code completion or code browsing so some developers may prefer to write code on the JVM using Eclipse or Intellij and then do final debugging under Visual Studio. You can find a "how to use" guide here and a slide presentation overview of Scala.Net project here.
The current implementation is already quite robust. The Scala.Net compiler does compile itself, some 100k lines or so of Scala code.
InfoQ: How would Scala applications running on the JVM and on the CLR interoperate?
Martin Odersky: Primitive types offered by the .Net virtual machine CLR are a superset of the JVM types. There's also value types which are like records. From a compiler writer point of view it is easy to convert from one to the other. Strings work well with the transform procedure. It is unlikely that any corner cases have been missed as they have been well tested. The IKVM has had many years of use in the IKVM community.
InfoQ: Let me now switch a little bit to Scala in general. If I asked you to describe Scala in a sentence, how would that sentence look like?
Martin Odersky: Scala is a concise, highly productive programming language that fuses Object Oriented and Functional styles while integrating with Java application code seamlessly.
InfoQ: If someone plans to start a Scala project, her colleagues will demand a proof of concept. So what are the largest applications that are using Scala today and for what purpose?
Martin Odersky: There are many large applications based on Scala ranging from NASA launch control to business critical trading applications at companies like EDFT and Trafigura. Some of the largest are in use every day by the general public at Twitter, Foursquare, and LinkedIn where the Scala applications handle billions of web transactions a day.
InfoQ: What would you say to a manager why he should trust in Scala instead of using his favourite Java platform?
Martin Odersky: You can trust in Scala for the same reasons you you trust your Java platform. It uses the same highly reliable JVM. The Scala compiler is reliable and robust being written by Martin Odersky, the person who wrote the reference javac compiler you use for Java programs. Scala applications integrate seamlessly with your Java applications and operational deployment is identical. Most of all you get much more productive development, faster project turn arounds and lower maintenance costs. And it has the full commercial support from Typesafe.
InfoQ: What will be the next changes or extensions Scala will undergo if we speak about the next 1,2 years?
Martin Odersky: The focus in Scala research and development is striving to make things simpler for the developer. Multi-core and GPU based systems are here and harnessing that power is hard with todays programming models. Programmers have to worry about scale, synchronisation, races, deadlocks and many other concurrency issues. Future versions of Scala will enable developers to use simpler models and be sure that things will work whether deployed on a single multi-core system or on a heterogeneous system that includes GPU style processors too.
Today you have the Scala Parallel Collections that enable a programmer use existing Scala code and with minor changes gain the performance given by multi-core systems. From Typesafe you have Akka that greatly simplifies the distributed processing model to give robust messaging based computing like Erlang. Joint research at EPFL and Stanford university is destined to give this performance boost and programmer model simplicity for heterogeneous systems to large scala parallel applications in machine learning, mechanical design, airflow simulation, financial risk analysis, Monte Carlo and many others. You will start to see these things arriving in Scala over the next 1 to 2 years.
InfoQ: So how do you think Scala will look like in 5 years in terms of the language and its surrounding ecosystem?
Martin Odersky: I expect that it will be an established programming language with widespread use in industry. I also hope that, even with its current rapid growth, the Scala community will keep the level of intelligence and friendliness that it has now.
InfoQ: What are your personal opinions about the future of Java?
Martin Odersky: It looks like the Java platform will continue its dominance on the server. I expect more language diversity on top of that platform than what we have seen so far.
InfoQ: You recently founded the company Typesafe. So what are the goals and the business model of the company?
Martin Odersky: The company aims to provide the best products and support for commercial and community users of Scala. It will provide developers with the tools to create scalable applications as simply as possible. The business model of the company is based on support of an open source stack, similar to Red Hat, Spring Source, or Cloudera.
InfoQ: Martin, thank you for this interview.
About the Interviewee
Martin Odersky is a co-founder of Typesafe, the creator of the Scala programming language, and a professor in the programming research group at EPFL, the leading technical university in Switzerland. Throughout his career, Martin's singular objective has been to make the basic job of writing programs faster, easier and more enjoyable. In the process he has personally written more lines of Java and Scala code than almost any other individual in the world. He wrote javac, the compiler used by the majority of today’s Java programmers, and scalac, the compiler used by the fast-growing Scala community. He authored "Programming in Scala," the best-selling book on Scala. Previously he has held positions at IBM Research, Yale University, University of Karlsruhe and University of South Australia, after having obtained his doctorate in 1989 from ETH Zürich as a student of Niklaus Wirth, the creator of Pascal.
Uwe Zdun, Rafael Capilla, Huy Tran, Olaf Zimmermann Mar 09, 2014
Olav Maassen, Liz Keogh & Chris Matts Mar 08, 2014