Archive

Archive for August, 2014

Head First Akka with Scala

August 1, 2014 1 comment

Howdy

Have you enjoy Scala yet ? Have you love this language and its actor model yet ?

Probably you have. I will now explore a really cool framework for building distributed system with actor model. It’s Akka Framework. It’s a reactive framework.

 

image

 

If you haven’t heard about the term reactive you need to check out this one first.

image

 

First we will need to install SBT first. If you have already familiar with java. Managing dependency, installing library, setting up structure is really painful if you are not using tools or IDE. SBT is a simple build tools that doesn’t sucks like Ant (with XML hell). You need to download that first from here.

image

Now we can start by creating SBT project  for this lesson. Create a file build.sbt and insert the following content into the file.

 

image

Run sbt compile for the first time for initializing sbt and your project. It will download the required library for Akka. Your output might be different with me. At the first time it will take awhile. Just be patience.

image

 

Create directory src/main/scala

 

image

Create file HelloActors.scala. Insert the following code

image

Run the project by executing sbt run from the directory where build.sbt created.

 

image

 

Now you can continue exploring by download the following chapter and write some code !!.

Cheers

 

References :

http://www.reactive.io/tips/2014/03/28/getting-started-with-actor-based-programming-using-scala-and-akka/

http://doc.akka.io/docs/akka/2.3.4/intro/getting-started.html

http://doc.akka.io/docs/akka/2.0/intro/getting-started-first-scala.html

http://doc.akka.io/docs/akka/2.0/index.html

http://doc.akka.io/docs/akka/2.3.4/scala/index-network.html/

http://doc.akka.io/docs/akka/2.3.4/scala/cluster-usage.html#preparing-your-project-for-clustering

Tools :

http://www.jetbrains.com/idea/features/scala.html

http://confluence.jetbrains.com/display/IntelliJIDEA/Scala?_ga=1.109172037.1933020012.1406117705

Advertisement
Categories: Uncategorized

Head First Scala

August 1, 2014 Leave a comment

It’s been a long time since I learn my last programming language. I’ve been using C# for about 6 years now. I think it’s time to learn something new.

Because of my current job heavily involved with concurrency and network I choose a language that can give me great advantage for that problem. There’s no doubt that JVM is the most reliable and mature runtime in the world. A big internet company like google, amazon and linkedin use it.

The great thing about that is there are a lot of library out there when you want to write a software. Just do your research, google it and you are ready to go with the short amount of time. The problem is the Java language become old and old. It’s not fun using that anymore.

Fortunately a bunch of smart people write another JVM based language like scala, clojure, groovy, erjang etc. This is great stuff, because you can have a taste of modern language while enjoying productivity using existing Java library.

I choose scala to learn first from a bunch of JVM languages. That’s because it’s have a multi paradim programming like functional, object oriented and concurrent. Ok. Let’s get started.

The first thing you want to do is installing JDK. You can install JDK 7 or latest. Download it from the official website.

image

After you install the JDK make sure that you set your environment variable. Follow this instruction.

 

Installing scala for Windows is very easy. Just download the MSI installer from here and run it.

image

 

Now open Command Line and type scala. Print hello world to console and celebrate your victory.

image

 

Learning a new language can be boring if you have already knew a lot from your previous experience. One approach is to visit the fundamental and unique characteristic from this language first and then going deep. One book I found very interesting for introducing the language with different paradigm is Seven Languages in Seven Weeks.

image

Be careful this is just an appetizer to bring the appetite. Smile with tongue out. After you buy the book then open Chapter 5 about Scala, read and type the code. You will amaze how fast you can learn this language. This language is very interesting because of it’s actor model. Also it will introduce you to functional concept like pattern matching, high order function.

 

Enjoy your first journey with Scala

Cheers

Categories: Uncategorized