Scala, the passion is finally starting to take hold.

I have to admit, I'm starting to warm up quite a bit to Scala. It was of interest to me but after I had seen Venkat Subramaniam's talk at the NFJS conference this year, I decided it was past time to pickup some books and start looking at it seriously.

Usually my biggest problem with moving away from Java is the tool support. This holds little water with those who still think simple text editors are the best way to code. Maybe I'm ruined by technology, but hovering over a method to see the javadoc or hitting F3 to view the source code takes the annoying out of learning new languages. Without this support, so much time is wasted on petty syntax errors and searching though api doc that could have come with trusty ctrl+space. Well it turns out the tool support for Scala in Eclipse and NetBeans was actually pretty good. The static typing (low ceremony static typing I might add) enables the editor to do some pretty nice type checking, code completion and syntax highlighting. This was a nice change over the dynamic languages I've been dabbling in.

After playing around with the simple examples in Ordesky's book, I skipped straight to the Swing chapters. I found the syntax to be nice and concise but the problem is that I can't compare it to Swing code I've written because I DO NOT WRITE GUI'S BY HAND. There's a product called NetBeans that works brilliantly for GUI design. Hopefully I'll get to use again before Oracle throws it under a bus. After that I tried looking into liftweb. That was a less than optimal experience due to the Maven archetypes being a cross between out of date and flat out broken. I had good luck with the mailing list but my GitHub ticket (which is one hunky piece of crap work in progress) was closed, probably because of my lousy issue title.

So after my "ok who cares about SwingBuilder", a flacid Lift-off with liftweb, and the lack of needing to build a highly concurrent HelloWorld with actors, I started to think that maybe I'll enjoy using Scala in the future but at this point there unfortunately wasn't a use for it in my daily life. Then I was put into a situation of prototyping something for someone which required handing in a fully functional application, in Java, and this is where the fondness began to grow.

The thing that drove me absolutely nuts was all of these high ceremony domain objects. 150 out of 450 total lines were public getters and setters. Sure eclipse generated them but I got so distracted by the noise. The worst part is you have to JavaDoc all of those too (or should). It also makes re-factoring more of a pain. What a waste of time! The other feature that I really wanted to leverage was fine grained access control. The problem dealt with moving vehicles based on received commands. It seemed natural to put turn and move commands on the vehicles which mutated their coordinates. I think my functional friends would recommend something that takes and returns a new rover but one step at a time for me dudes. I did have a command processor which processed the inbound commands and then executed them on the rover. It would have been nice to restrict access to the turn and move methods only to this command processor interface to prevent someone who doesn't know what they're doing from moving the vehicle off a cliff.

I used to hold design patterns close to my heart until I heard someone say design patterns only serve as workarounds to deficiencies in a language. The more I learn Scala the more I see these deficiencies in Java. I still don't and never will dislike Java, but I do think I'm going to start mixing a little Scala in with my everyday applications. At least for domain objects or objects that have a lot of member variables.

If you're in Chicago you should try to attend the Chicago Area Scala Enthusiasts(CASE) meetup that is hosed by Dean Wampler. Dean's a great presenter and top notch technologist. He covered ScalaCheck and ScalaTest this week and he also showed use of Simple Build Tool (SBT) which does some pretty nice tricks like continuous compilation and testing. It also wins points with me for supporting Maven dependency management.

No comments:

Post a Comment