Epic codefest: 7 programming languages in 7 days

We challenged our developers to learn Clojure, Scala, JavaScript, Ruby, Java, Kotlin, and Go in a day. Here's how easy it is to make the switch

Page 7 of 9

Day six: Scala Granny
Developer: Michael Brush, "like a hairbrush," Java/Spring guy

What makes Scala with the Play framework special is that it seems to be trying to make Java simpler.

Scala is similar to Groovy in that it is almost a scripting language on top of Java. Play is the equivalent of Grails as the Web framework that sits on top of Scala, and it seems to be the community's standard way of working with Scala. Scala/Play compiles all of its code into Java, and developers can use any Java class in the Scala language. Of course, Scala and Play themselves have a lot of classes that are intended to be used for the simplification and scalability of Java.

Scala/Play was easy to set up and use. I liked the way that you define the URLs for the application. There is a separate file that feels like a hosts file. This makes it easy to see all of your URLs in one location. It was also easy to understand what you were returning to the Web page. For instance, to return a 200 success, you just use the Ok() method with the contents of what you'd like to return.

I did my coding in Eclipse using a Scala plug-in that installed with no issues. There is not a plug-in for Play, so I also kept a console window open when I needed to do things specific to Play.

The build was done from the command window. Play has a console that you use. You browse to the root directory of your project and type play. This runs a few items, then you're in a command-prompt window specific to Play.

To build the project, I just ran run (and used clean if I needed to clean the project). This builds the project and starts it running on an internal Web server. After it is started, you can switch back over to Eclipse and develop; you don't have to touch it again. It compiles each time you go to the website that is set up.

I'd have to become more familiar with Scala/Play to know whether I would recommend it for a larger project. I don't know yet how models interact, but for something along the lines of Granny, I'd definitely use Scala/Play again.

One reason is simplicity. Sometimes I overcomplicate a problem, and I did just that with one of the issues I was having with this project. I was dead-set that if I didn't code the project a certain way, you could not have an address with blank fields. I finally decided to let that hang-up be, and it turned out what I was trying to do wasn't necessary and the framework took care of allowing the blank fields on its own.

James Iry at Typesafe was a big help with the project, especially with getting my big issues resolved.

I would recommend Scala on a project. For now, I'd start on small Web-based projects, but I can see that with some more knowledge, Scala could be useful for big projects as well. It's flexible and simple.

Documentation was the biggest issue with Play. It's a young framework (1.0 was released October 2009), and they are still improving and simplifying it. Specifically, I had problems marshaling and unmarshaling JSON. It appears that this has gone through a few iterations. I think this is a good and bad thing. The developers of Play appear to be listening to the community and are improving Play based on what the community wants, but this means a lot of changes between versions. As a result, it's harder to find information for the version you are currently working on. At some point as the framework gets more mature, this will slow down, and the documentation and answers on Google and the like will get more consistent.

| 1 2 3 4 5 6 7 8 9 Page 7
From CIO: 8 Free Online Courses to Grow Your Tech Skills
Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.