My Scala Days [Week 1]

I started doing Scala not because I am curious about it, like Haskell, but because I have to since the project that want to work on is in Scala.

Some articles say Scala means scalable language but one particular article says it mean staircase in Italian. And Scala surely means “ladder” (or staircase) in Italian.

Unfortunately, I don’t have strong Java basics so I thought I would have some problems with it.

Fortunately, I am very comfortable with Functional Programming so that is one less thing to worry about it.

Let’s move on to setting up the development environment and learning part.


Development Environment #

For the development environment, I tried to resist my temptation to setup Emacs for Scala Development. For those who insist on doing everything on Emacs, here are two things that you need for your Emacs; ENhanced Scala Interaction Mode for Emacs and New Scala Mode.

This time, I need to speed things up and I want everything as simple as possible with Get Shit Done Philosophy.

I started doing a typical Hello World after I have installed and have my environment set up.

There was one problem which I went through when I was trying to get my Hello World program to run in IntelliJ. The problem is that there are multiple 'scala-library*.jar' files.

Error:scalac: Multiple 'scala-library*.jar' files (scala-library.jar, scala-library.jar, scala-library.jar) in Scala compiler classpath in Scala SDK scala-sdk-2.11.7`

The problem occurs because of the duplicates of library files in the directory that I pointed for Scala SDK in IntelliJ. I pointed to /usr/local/Cellar/scala/2.11.7 for the Scala SDK and there are two folders which contains library files: one folder has the real files and the other has symlinks to the files in the former directory. If you want to make sure of the installed path of Scala, do brew info scala and you will have some useful info. For my case, I realized that I have to point to /usr/local/opt/scala/idea for Scala SDK for IntelliJ. So, I set my Scala SDK again in IntelliJ by doing File > Project Structure and then removing the Scala SDK that is already there (you can see the duplicates on the right panel) and then adding back again by setting the path as /usr/local/opt/scala/idea.

Things work well after that and there, Lo and Behold, the “Hello World” appears after the program is successfully compiled.


Learning Resources #

The first thing that I did was download all the videos of Functional Programming in Scala and prepared my mind to do all those. That’s going to be super tough for me.

I gathered as many resources for Scala as possible and I got the following:

It is a good idea to read Martin Odersky’s Scala levels guide and put a mark on where you want to be after “x” amount of time. But first, I need to get a hang of what this whole Scala thing is. One thing that I have become after being a Haskeller for quite a while is that I am too lazy to write a lot of code to have something that I want. But well, I have to learn to be a bit verbose again if I want to be in the land of Scala.

First, I read the first two chapters of Scala for the Impatient and tried out the exercises. It is always a good idea to do exercises rather than just reading the book since the real learning happens when you are twisting your brain this way and that way in a foreign land. But I have to admit that I wanted to move on quick so I didn’t give much time for each exercise. I referred to solutions for Scala for the Impatient as I move on.

At the same time, I followed the guide of Learning Scala by Joel Abrahamsson to get my feet wet and to clean my head a bit when I am stuck with those exercises from SftI or just plainly get bored with that.

Another article which really proved to be helpful after getting a little bit warm in Scala is First Steps to Scala by Bill Venners, Martin Odersky, and Lex Spoon. This article is a nicely written and can serve as a good recap after getting here and there in the first week of learning Scala.

Here are some of the takes for me:

I need to get a better hang of traits.

Here, again, is a very good place to get deeper and deeper into the concepts of Scala by taking Another Tour of Scala. I read the first one Scala Basics and I pretty much liked it so I will continue munching those articles as I continue learning.

I tried to work on Scala Labs and Scala Koans but sbt takes too long whenever I am starting it up. I have no idea how to work on those too. I have to find a way to work on it.

After learning quite a bit of basics of Scala from the above resources, I find Scala cheat sheet very helpful. This cheat sheet clarifies as well as solidifies some of the new concepts as well as the fuzzy ones in my mind


This blog does not encompass all the details of my Scalain Journey. This will be a living and breathing matter as I add more and more stuffs as I remember what I did and what I stumbled upon.

 
17
Kudos
 
17
Kudos

Now read this

[You give this a name yourself]

Why is the value of a bean sprout a lot less than that of a diamond? You might think that I am nuts for such a comparison or you might think that I am going to say something bat-shit insane by starting out like this or you might think... Continue →