Have no any idea what to do today after dinner, although I have some homeworks need to submit soon, I still decided to try something new in a short time. I recalled I read an article yesterday on stackshare.io, it seems there is a company named instacarts tried Scala programming language to setup their development stack. I am very curious on the programming language, it seems someone said: “Speaking More Than One Language Could Sharpen Your Brain.”, how about Scala?
1. Download the recent Scala SDK here:
2. Uncompress the package, put the folder into
/usr/local, add the path into system environment variable
1 2 3 4 5 6
NOTE: You can skip the above two steps with a full-fledged docker image, which even do not affect your local system, but allow you to try the following steps. Please see the instruction on how to download the docker image on Scala at the bottom.
3. Open your perfered Editor, for me, it is sublime text and/or vi, type the followind code in:
1 2 3 4 5
then save the file as
NOTE: If you do not want to type them in, please git clone the repository in my github here:
4. Compile and execute it:
1 2 3
5. We can even ignore to add a method
main to be act as the entry point of the program by extending object from
1 2 3
Cool! You are almost done. Scala has two surprises here for you!
6. The first surprise with Scala is we can easily to script it with bash shell script, like:
1 2 3 4 5 6 7
Save it as
helloscala.sh, then run it as:
7. Scala provide a REPL interactive shell to allow developers to try some short experiments:
1 2 3 4 5 6 7 8 9 10 11 12
If you are on Ubuntu, or other linux, please make sure your have
docker command on your terminal, please try the command here:
You should get a version of docker above
1.2.0, then run the command ( it will take a little bit time to download docker image at first time ):
NOTE: With the option
--rm, docker will remove the container when it exits automatically. Please make sure you save your documents before type
exit from docker container.
On Mac, please refer to the ref for Boot2Docker.
Written with StackEdit.