Home » Java, Scala

Scala basics: What is Scala?

24 November 2008 7 Comments
If you're new here, you
may want to subscribe
to the RSS feed.
Thanks for visiting!

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

Tweet This Post

Subscribe

Did you like this post? Subscribe for more!

Subscribe via RSS
(What is RSS?)

7 Comments »

  • Web 2.0 Announcer said:

    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 …

  • Arjan`s World » LINKBLOG for November 25, 2008 said:

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

  • Rodney said:

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

  • Daan (author) said:

    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.

  • Sheena said:

    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

  • Daan (author) said:

    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

  • Sheena said:

    Thank you so much , I needed that direction .

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.