Pt1 – Hello World in Scala

I’ve tried to make this as simple as possible to get a working, runnable Scala class.

The main parts of this video are

  • downloading an IDE to write Scala in
  • a class to print “Hello, World” to the console

You can download the IDE from http://scala-ide.org/download/current.html. It is a release of eclipse bundled with Scala plugins and will run just like a normal eclipse installation.

Here is the class I create in the video:

package com.vf

object Test1 extends App {
 
  println("Hello, World")

}

A few things worth noting:

  • The package declaration is similar to in java but the file does not need to be in the folder com/vf and there is no semi-colon – these are not always required.
  • We define this class as object not class. This, combined with the extends App will mean the inline contents of this class get wrapped inside a main method and can be executed. For the curious, object actually identifies a class as being a Singleton. It will be initialized lazily as required.
  • The println method is like a scala alias for System.out.println – Scala tries hard to be less verbose than java and typically is.

Anyway, here is the video:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s