3.1 A scalable language

Systems languages, such as C, C++, and to some extent Java, have long been the part and parcel of developing complex, large-scale software, often with critical performance requirements. By contrast, scripting languages have filled the need of one-off programming tasks and of tying together components developed in more complex and performant languages, often performed as a batch job. Because they filled different niches, systems languages and their associated libraries evolved to become relatively more complex compared to their scripting-language cousins.

Instead of having to choose between a simpler but less-performant scripting language, on the one hand, and a speedy but complex systems language, on the other, Scala designer Martin Odersky envisioned a language that would be suitable for (or scale to) large and complex systems as well as small scripting tasks.

In almost every development team, some developers are more skilled in a language while some have more experience with a problem domain. Scala aims to present complexity at the level most appropriate for a developer. Developers more skilled in the language itself are able to define new, relatively simple language constructs that address the needs of domain experts who may have less Scala experience.

Scala's division-of-labor aspect has been applied to software testing, data analysis, as well as to the area of concurrency and actor programming. The Actor API developers defined a handful of programming constructs that present a simple and straightforward way to work with actors, without the API user having to understand the intricacies of actor concurrency. In essence, the Scala Actor API "grows" the Scala language into a robust, concurrent programming environment.

Another way in which Scala achieves scalability is via its reliance on the Java runtime environment. Scala code compiles to Java bytecode. As a result, Scala is fully binary-compatible with Java, although it is not source-code compatible. Scala's developers invested much effort to ensure that the compiled bytecode is nearly as efficient as if the code were compiled from Java language sources.

A benefit of Scala being a JVM language is that Scala code can use any existing Java library. Invoking a Java method from Scala is just like invoking that method from another Java class. That seamless binary compatibility also assists the novice Scala developer to ease into Scala one step at a time. Indeed, a good way to get started with Scala is to implement a piece of new functionality in Scala in the context of an existing Java project. The current leading Scala IDEs, such as Eclipse and IntelliJ, support mixed Java and Scala projects.

Although you don't need to understand the full implementation details of the Actor API to start developing concurrent programs in Scala, you will need to grasp a handful of Scala language features in order to follow the examples in the next chapters.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset