Scala basics: What is Scala?

Scala

Many people do not know about the programming language Scala, or why they should care. I think you should care, because Scala has some nice secrets from which you can learn a lot. Scala is a great excuse for learning new things. Even if you never use Scala again, it can be a nice addition to any programmer’s toolbox.

No matter what language you are programming in, it is a good habit to look at new developments. New ways of doing stuff keeps your brain alive. You become a better programmer with your existing tools. And maybe you get some new tools in the process.

So, onto the first question, What is Scala?

What is Scala?

Scala is a relatively young programming language. It has the following distinguishing features:

  • Java compatible bytecode
  • Functional programming language

Java compatible bytecode

Scala is a bit special because it runs on the Java virtual machine. This means that Scala code will compile into Java compatible bytecode. For the Java programmers, this means you can integrate Scala directly into your Java projects. This means that it is possible to create a Java interface and implement it in Scala. Or call Scala methods from Java. It also means that you can use a truckload of existing Java libraries with Scala.

This is very neat, as you do not have to convert entire projects to Scala. You can use Scala in the spots where it fits, and use Java as the main language. This makes Scala look a lot more interesting, especially in big Java shops.

Functional programming language

Scala is a functional programming language. To give a tip-of-the-iceberg-idea: every function is an object. Scala gives the possibility to pass values, but also to pass calculations to methods. This is very powerful and opens a lot of doors to all kinds of new programming constructs.

In Scala, you can make the following constructs very easily:

  • Anonymous functions
  • Pass a function as argument to another function
  • Nested functions
  • Function as return value of a function

The Hello World example

As any post about a new programming language, I cannot omit the Hello World example.

So, download Scala, copy/paste the following code and get started!

object HelloWorld {
  def main(args: Array[String]) {
    println("Hello, world!")
  }
}

Further reading

Tags:

7 Responses to “Scala basics: What is Scala?”

  1. Rodney December 30, 2008 at 16:09 #

    I guess the real question is why would I use Scala?

  2. Daan December 30, 2008 at 18:36 #

    You can choose for yourself. If you know what it is, you can decide if it makes sense to use it.

    For me personal, Scala is a learning experience. It is refreshing to sometimes look at other technologies. When I learn more about other technologies, I can apply that knowledge to my current projects.

    You can become a better programmer by looking around with an open mind, rembering the good stuff, forgetting the bad stuff.

  3. Sheena July 15, 2010 at 16:07 #

    Hi Daan,

    Im an IT student and currently I am studying a course that involves scala as a means to exhibit functional programming. would you be able to tell me , how many companies actually use scala or in which disciplanary areas scala would be applicable ? Its just that if I know about its application, then I ll just get a greater drive to learn the language.

    Thank You,
    Sheena

  4. Daan July 16, 2010 at 09:19 #

    Hi Sheena,

    I have no idea how many companies really use Scala. I know a few, but have no conclusive statistics on that.

    Twitter uses it in middleware and frontend code: http://kevinoncode.blogspot.com/2008/10/octobers-bay-area-scala-enthusiasts.html.
    See also http://www.scala-lang.org/node/1658 for an overview of companies using Scala. There are some large companies in that list!

    – Daan

  5. Sheena July 16, 2010 at 10:08 #

    Thank you so much , I needed that direction .

Trackbacks/Pingbacks

  1. Web 2.0 Announcer - November 25, 2008

    Scala basics: What is Scala?…

    [...]Many people do not know about the programming language Scala, or why they should care. I think you should care, because Scala has some nice secrets from which you can learn a lot. Scala is a great excuse for learning new things. Even if you never …

  2. Arjan`s World » LINKBLOG for November 25, 2008 - November 25, 2008

    [...] Scala basics: What is Scala? – ‘Daan’ [...]

Leave a Reply