InfoQ

News

Catching Up with Scala

Posted by Scott Delap and Craig Wickesser on Aug 22, 2007

Community
Java
Topics
Programming ,
Scripting
The Scala programming language has been catching the eye of a number of developers as of late. If you take a glance at the Scala website you'll find that Scala is a pure object-oriented programming language that seamlessly incorporates imperative and functional programming styles. Christopher Diggins noted that,
Until relatively recently programming languages have fit neatly into either "imperative" or "functional" categories. Scala represents a new breed of language which obliterates these arbitrary restrictions.
According to a blog post by David Rupp, Scala just might be The Next Next Java. Comments like this make it worth a look.

 

There are several key features provided by Scala which demonstrate its object-oriented nature. For example, every value in Scala is an object, this includes basic data types (i.e. booleans, numbers) as well as functions. Additionally, classes can be subclassed and Scala provides a mixin-based composition.

As opposed to languages that only support single inheritance, Scala has a more general notion of class reuse. Scala makes it possible to reuse the new member definitions of a class (i.e. the delta in relationship to the superclass) in the definition of a new class. This is expressed as a mixin-class composition.

 

Some of the key functional concepts provied in Scala include higher-order functions, currying, nested functions, sequence comprehensions, and more.

Scala is statically typed which allows it to provide generic classes, inner classes and even polymorphic methods. One other thing worth mentioning is that Scala was designed to interoperate with Java and .NET. The current version of Scala does not run on .NET (although the previous version did). There are plans for Scala to run on .NET in the future.

Scala also interoperates with Java. It uses a compiler, scalac to convert source files into Java class files (i.e. bytecode that runs on the JVM). You can access and use all Java classes from Scala, and you can also access Scala code from a Java application. To quote David Rupp,

It also has access to the multitudinous multitudes of existing Java libraries out there, making for a (potentially) easier migration path.
This allows Scala to make use of the vast collection of Java libraries and frameworks that have already been written for Java 1.4, 5.0, or 6.0 which Scala is regularly tested on. Scala may also work with older versions of Java but there is not formal testing done for those situations. Scala is distributed under a BSD license and has been deemed stable for several years.

 

This all leaves the question "Why should I use Scala?". Scala was designed with one goal in mind,

To create a language with better support for component software. (The Scala Programming Language, Donna Malayeri)
The idea is that software should be developed such that it can be constructed from re-usable parts. Scala aims at providing a programming language which unifies and generalizes key concepts from both object-oriented and functional styles.

 

It was through this one goal and design that Scala is able to provide some great features including...

  • Object-Oritented style
  • Functional style
  • Higher-level concurrency model
  • Scala brings Erlang style actor based concurrency on the JVM. Developers can now design scalable concurrent applications on the JVM using the actor model of Scala which will automatically take advantage of the multicore processors, without programming to the complicated thread model of Java.
  • Lightweight syntax for functions
  • Integration with XML
    • can write XML directly in Scala program
    • can convert XML into Scala classes
  • Seamlessly interoperates with Java

 

The style and features provided by Scala have left numerous developers interested in Scala, such as Debasish Ghosh who stated,

I have been playing around with Scala for quite some time and have been thoroughly enjoying the innovations that the language offers.

To summarize, Scala is a functional object-oriented language which provides a seamless blend of features not found elsewhere, all while running on the JVM. With an increasing interest by developers and increasing tool support Scala is certainly becoming a language to have in your tool belt.

A few precisions... by Stephane Micheloud Posted Aug 23, 2007 7:02 AM
Scala / Lift / Eclipse by Geoffrey Wiseman Posted Aug 23, 2007 8:42 AM
Re: Scala / Lift / Eclipse by craig w Posted Aug 23, 2007 11:50 AM
  1. Back to top

    A few precisions...

    Aug 23, 2007 7:02 AM by Stephane Micheloud

    While the current version of the Scala distribution does not run on .NET, interested Scala users may install the sbaz-package "scala-msil" which contains additional tools and libraries (alpha stage software) to run Scala on Mono/.NET.

    The Scala distribution is actually built and tested every night on the Sun Java 1.4, 1.5, 1.6 and IBM Java 1.5 platforms; the latest nightly build is available from the Scala website.

    The Scala distribution is released under a BSD-like license unless otherwise specified.

    Other features of Scala can be found in the online document "A Tour of the Scala Programming Language". A history of most language changes introduced in Scala 2 (appeared in March 2006) is available from the Scala Change Log page.

  2. Back to top

    Scala / Lift / Eclipse

    Aug 23, 2007 8:42 AM by Geoffrey Wiseman

    I fired up the Scala/Eclipse plugin a couple months ago to try some playing with Lift; the plugin's not bad, but it's a far cry from the Java tooling still. Ultimately, I had too much cognitive load at the time to really make progress on learning the ins and outs of Scala, so I set it aside for a time when I'm not already neck-deep in learning for my day-job.

  3. Back to top

    Re: Scala / Lift / Eclipse

    Aug 23, 2007 11:50 AM by craig w

    I agree, the Scala Plugin for Eclipse could use some lovin' :) If it could at least add code-completion/content assist, it would be so much better.

    But it is fun learning Scala, I am looking forward to reading more about Scala and hoping the Pragmatic guys write a book for it :)

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.