On Scala

My personal Swiss army knife

Divan Visagie
From The Couch

--

The first program I intentionally wrote, that is to say I actually felt that I knew what I was doing and had a clear purpose, was one that would copy stuff into folders based on date modified… or something like that. That bit of C++ is long gone .The point is , the reason I wrote it was because I wanted to get something done and there was nothing around that I knew of that could get the job done.

These small use cases have never left me, I view writing code to solve problems the same way most people view calculators as good at solving math problems. This means I have a preferred language which is my goto hammer for everything that looks remotely like a nail.

For many years my hammer has been JavaScript , it lets me control robots, write simple web services, process files and experiment with simple algorithms with little to no uphill battle out of the starting gate. I liked JavaScript simply because it was enjoyable to use and because it was: “both functional and object oriented”.

Being a little overenthusiastic about different programming languages , once I got comfortable with associated features such as closures , function objects and functors, I thought it would be rather interesting to set out finding another language that did all this. I Googled it, and Scala came up.

My first impression of the language was: this is different, way different. Another thought popped into my head though; That was my reaction with Go as well, were we on the precipice of a syntactic generation shift? . After playing around with Scala a little bit , I thought, “well this is nice” and it did the things I had become used to in JavaScript better than a lot of other languages did , but other priorities made me shelve the process of learning this new language. Besides, I knew some statically typed C like languages already and had my dynamic hammer for when I wanted those features.

A few Years later , Apple releases Swift, my reaction? “This looks familiar” , indeed Swift had clearly borrowed a lot of syntax from Scala, of course they are very different languages , but I think the syntax style of a language generation reveals a certain shift in thinking. Needless to say , that thought of the generation shift peaked it’s head once again.

In the last quarter of 2015 though , Scala fell off my todo shelf and onto my desk of todo things. An interest in Akka was the spark that ignited the fire , though it was Twitter’s openness about how their enginerring works that really added fuel to the flame. Twitter uses so much Scala you would swear they invented it , in fact in some cases, like Futures, one could argue they sort of did.

My GitHub profile started filling with pointless Scala projects instead of pointless JavaScript ones and I started learning the finer points of functional programming. I found the most rewarding part of Scala , oh... wait that’s the second , the best part of Scala is case classes (I’m lazy like that). The second most rewarding part of Scala is that you can learn the object oriented part quite quickly and be able to solve problems just as you have before, but being a close cousin to the Swiss Army Knife , it allows you to dive deep into the kinds of features that are surprising to someone who is not versed in functional programming. Basically , Scala is a scalable language.

Scalability is kind of what you want for your personal language because it’s where you go off topic, where you play with ideas to find 100 ways to solve the same problem and sometimes take a project in a completely different direction after some shower-thought. This can have major benifits in real world projects too, just look at teh aforementioned Twitter to see that this language isn’t just a toy I like playing with.

All of this however does not mean I’m going to start adopting Scala.js in all my website projects , but it does mean that express projects will be replaced with ones written in Finatra . I also think that in this very short space of evaluation time I would be confident enough to try some production project in Scala if afforded the opportunity.

To sum it all up , I like my new hammer , because it has a cork screw, and a scissors , and a… what is that white slide out thing opposite the tweezer? Is it a monad?

--

--

Divan Visagie
From The Couch

I write about tech and anything else I find interesting