I've been looking at learning another development language for some time. Over the years I've dabbled in PHP, Groovy, and even C/C++. While I learned a lot in doing this, I never became an 'expert' in any of them. For the most part, I used them for the project in which they were needed or for the scenario where they were most appropriate and then went back to Java for my primary development platform.
The reason is that I'd become so familiar with the Java tool set, language, and available libraries. I was (and am) most productive in that environment. But Java is showing its age and limitations. Its becoming clear that some of the most vexing problems facing developers will need a full range of tools to solve them, and while Java's OO support is good, its functional support is not. I, therefore, decided that I needed to expand and really learn another language pretty well. I decided that language is going to be Scala.
Why Scala? Well, I'll go over that in a different post. This post is about my experience writing my first Scala app. So, here it goes.
Since I am changing jobs (again), I decided I would leave something behind for my co-workers. In our current work environment, we have a shared drive where server error logs are stored in 'pseudo' XML format. It was always annoying to me that we had to navigate the file structure, open a text file, and hunt through the file to find an error we would be looking for. It was also difficult to determine how often an error was occurring. Now, the easy way to solve this is to use the log4j XML appender and read the files with Apache Chainsaw, but this is a large company, and it decided to go with a proprietary format. I decided to use Scala to write a little desktop app that the developers could use to view the log files in a tabular format, then select a row to see the stacktrace detail.
The application needed 3 essential things : a table to show rows, a TextArea to show the detail, and a FileChooser to select which log to view. In the background it also needed the following processing capabilities: read in a file, modify the text to make it valid XML, parse the XML tags. That's about it.
Well, I whipped out the app pretty quickly. It would have been much more quickly if I hadn't been learning Scala along the way. There were some really nice things about Scala that I found out. First, its swing wrapper classes are nice, and their pub/sub model is succinct. Second, the XML processing is excellent. The built in support for XML files allowed me to parse the logs in a couple of lines of code. Finally, the Actor metaphor for multi threading was also very easy to use and implement.
I had a few frustrations along the way as well. The Eclipse plugin was nice, but it still doesn't have code-complete (One of the biggest productivity tools in my mind). The code-complete is supposed to be in the plugin, but for some reason, doesn't seem to work for me. I've tried on 3 separate computers. This meant that I was reading a lot of documentation. Its also hard to read the documentation. Since Scala has so much support for so many features, the docs can get a little complicated to read. I'm sure as I become more familiar with the libraries and syntax this will get easier, but I can see how it would be daunting for a junior developer.
I'm by no means a Scala expert at this point, but I enjoyed the language enough, and it seems to have enough benefits that I'm looking forward to learning more. Who knows, maybe one day Scala will be my primary language...
A Fix for the Google Play Books EPUB Issue
5 days ago