knb knb - 3 years ago 70
Scala Question

Why was NetLogo implemented in a mixture of Java and Scala?

Why was NetLogo implemented in a mixture of Java and Scala? Was it because of better support for concurrency? I am not familiar with Scala, but I think the functional programming style is better suited for expressing guarantees for concurrent programming.

Answer Source

The following is based on my experience as the lead developer of NetLogo from 2001 until 2014.

All of the Java code in NetLogo is old code that we simply never got around to converting to Scala.

The NetLogo project began around 1999, long before Scala existed.

By the time we switched to Scala in 2008, we had accumulated a great deal of Java code. Over time, a lot of that Java code has been converted to Scala, but not all of it. Converting absolutely all of it to Scala would be a big effort; it isn't worth it.

Pretty much all new code in NetLogo, since 2008, is in Scala.

Concurrency was not a major motivation for switching from Java to Scala. (In most of NetLogo, there are only two threads, the GUI thread and the job thread. Only BehaviorSpace uses more threads, and they are easy to keep separate in either language.)

The main motivation for using Scala was simply that Scala is a much more powerful, expressive, flexible, and elegant language than Java, with much better support for functional programming and immutability, which are a great help in writing elegant, correct code.

That makes Scala is more fun and satisfying to work in, and the resulting code is likelier to be correct and is shorter and more maintainable. Using Scala also (more often than not, in our experience) attracts smart people to the development team.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download