My impressions of Scala
Scala is fine and I would definitely use it over vanilla Java, but I still prefer Go if I’m not able to use Python.
My Impressions #
Why did I even look at Scala? #
Being on the development team for Python accurately suggests it’s my favourite programming language. But that doesn’t mean I don’t realize there are other programming languages out there which are in actual use. So I try to learn other languages which might have some interesting aspect to them which I might be able to crib from in order to enhance Python.
I also realize not every company out there uses Python. So if I ever find myself needing a new job it would be good to have my repetoire of languages expanded beyond just Python to make me more employable. And with the JVM thoroughly entrenched in the world of computing it never hurts to know a language that runs on the JVM which isn’t Java.
And lastly, learning a new language often teaches you a new way to look at problems. I am definitely a better programmer for having learned numerous languages. It gives you a new perspective of what exactly you can do and in a flexible language like Python you can often apply lessons from other languages there (e.g. knowing when something calls for a functional solution over a procedural one).
What did I do to learn Scala and try it out? #
To learn Scala I did a few things. First I read the book, Programming in Scala. I then took the Functional Programming Principles in Scala course at Coursera at the behest of a friend (who promised to learn Python if I took ths course, so bonus motivation =). Finally, I did a very small trips history project I have been meaning to do for quite some time in Scala to make me actually code something. It’s very small, but it’s better than nothing and it wasn’t a canned problem.
What do I think of the language? #
It’s fine. One complaint I have about Scala is its reliance on the Java ecosystem for things. For instance, if you want to do date-based work, you don’t use anything in the Scala SDK but instead use the Java SDK (specifially
java.util.Calendar). That means the docs for the SDK available to Scala is split in two. While I guess that is no different than installing a third-party project to accomplish something, it still feels odd to me and it would be nice if the Scala SDK docs simply included the Java SDK docs so you had a single location to search (but there might be licensing issues blocking that).
The language also tries hard to be functional and object-oriented at the same time. That also means it tries to be immutable and mutable all at once. While the latter allows for it to be a much nicer Java, the former adds another layer on top of many things, making the language feel quite large and not something you can fit in your head at once. As a very rough comparison, the Scala spec is a 154 page PDF (that leaves out the index), while Go’s spec is 50 pages when printed.
Finally, I have to admit to my own bias to preferring dynamically/interface-typed languages. Trying to deal with JSON in Scala was a right pain. I’m sure there are 3rd-party libraries to help ease it, but the whole exercise did remind me how inflexible statically typed, inheritance-based languages can get in the way (yes, I also realize that feature serves a purpose, but I’m with Go in that if you want your language to be statically typed you want it to use interfaces over inheritance).
I suspect that if I treated Scala as simply a functional language or a cleaned up Java then I would enjoy it more (and I suspect most companies that use the language do take a stance as part of their style guide). But as a whole the language feels too much like C++ by trying to do so much in the language itself.
My current ranking of languages in order of personal preference #
- C++ (flip-flops with Java depending on how I’m feeling that day)
Now this list only includes languages where I have at least written some code that I personally was responsible for and thus needed to care about it enough to be able to maintain it.
What’s next #
Languages on the slate to learn are: