Saturday 26 January 2013

Hello world in scala

I am slowly reading Seven Languages in Seven Weeks. The book briefly describes 7 computer languages, with just enough detail to get the flavour of each language. Today I had a little play with scala The point is to learn new techniques that some languages make easier.

New smaller languages seem to be very popular at the moment. For example the software for twitter  was originally written in ruby, but as the site got bigger they rewrote it in scala. I see a lot of adverts for jobs in scala -- perhaps even at the BBC for the Iplayer. Scala is a mixed object oriented and functional language. It runs on the java VM.

I downloaded the scala run time stuff via the standard package manager from Ubuntu.
First off is to print hello world. I just followed the instructions on wikipedia.

So my first program.


ubuntu >cat HelloWorld.scala 
object HelloWorld extends App {
   println("Hello, World!")
 }

Compile and run:

ubuntu >scalac HelloWorld.scala
ubuntu >scala -classpath . HelloWorld
Hello, World!

No comments:

Post a Comment