A modern software platform for the era of multicore and cloud computing - Q&A with Mark Brewer, President and CEO, Typesafe
December 01, 2012
This Embedded Computing Design Q&A taps Mark Brewer, President and CEO of Typesafe, with questions on how the Scala programming middleware helps optim...
ECD: What are the advantages of using general-purpose programming languages like Java and Scala for embedded development?
BREWER: Scala is a general-purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. Scala smoothly integrates features of object-oriented and functional languages, enabling developers to be more productive while retaining full interoperability with Java and taking advantage of modern multicore hardware.
Scala is also a functional language. Inspired by the long tradition of functional programming, Scala makes it easy to avoid shared state so that computation can be readily distributed across cores on a multicore server and across servers in a data center. This makes Scala an especially good match for modern multicore CPUs and distributed cloud computing workloads that require concurrency and parallelism.
Scala is equipped with an expressive type system that detects and avoids many kinds of application errors at compile time. At the same time, a sophisticated type inference capability frees developers from the redundant type information “boilerplate code” that is typical of Java.
Because the code sizes are typically reduced by a factor of two to three when compared to an equivalent Java application, Scala is well suited for an embedded environment due to its lightweight and concise nature, as demonstrated in the following code samples:
Java class definition
public class Person {
public final String name;
public final int age;
Person(String name, int age) {
this.name = name;
this.age = age;
}
}
Equivalent Scala class definition
class Person(val name: String, val age: Int) {}
Java code
import java.util.ArrayList;
...
Person[] people;
Person[] minors;
Person[] adults;
{ ArrayList
ArrayList
for (int i = 0; i < people.length; i++)
(people[i].age < 18 ? minorsList : adultsList)
.add(people[i]);
minors = minorsList.toArray(people);
adults = adultsList.toArray(people);
}
Equivalent Scala code
val people: Array[Person]
val (minors, adults) = people partition (_.age < 18)
Scala protects investments in existing Java libraries, tools, and developer programming skills. Scala programs are compiled directly to Java bytecode that runs on the mature Java Virtual Machine (JVM), leveraging its robust just-in-time compilation, garbage collection, and well-understood deployment techniques. The operations team doesn’t see a difference. Developers keep working with their familiar tools, but they’re writing code that’s shorter, faster, more scalable, more correct, and maybe even more fun.
ECD: How does the latest wave of multicore processors affect software development with object-oriented programs?
BREWER: The Java programming language was created in 1995, so it was suited to handle the first generation of Internet applications, with object-oriented programming models, multiplatform runtime, and network orientation. However, with the advent of cloud computing and interactive applications that demand near real-time capabilities, the Java language and traditional Java middleware have begun to show their age when faced with the equally significant hurdles of large-scale distributed applications and multicore platforms.
In most languages, the key to utilizing the full power of multicore CPUs is by writing concurrent multithreaded applications. Considering the shared state, state visibility, threads, locks, concurrent collections, and thread notifications involved, writing this type of application is difficult, even for experienced developers. These concepts are by nature error-prone and often result in deadlocks or application crashes.
In an attempt to keep up with the times, Java has evolved, but has become bulky and cumbersome in the process. Java and Java Enterprise Edition (JEE) application servers are inherently difficult to scale predictably; scaling up is extremely hard to accomplish, and the commercial licensing terms offered by most vendors prohibit the economical scale-out that customers so desperately need as an alternative to this model.
Another essential component of building scalable applications for embedded devices is middleware. Akka, built upon the scale afforded by the Scala programming language, is a message-oriented programming model for building multi-threaded applications. Akka raises the level of abstraction so that developers only need to worry about messages and business logic, instead of dealing with the low-level plumbing required in Java.
Play! builds upon Akka to deliver a Model-View-Controller (MVC)-style Web framework with a development experience much like that enjoyed by Rails developers. Play-mini is a subset of the Play! framework that consists of a REST layer on top of the Netty non-blocking I/O socket server. It offers the ability to deploy Akka applications for service-layer jobs that don’t need the rest of the Play tools (for example, the MVC/interface layer).
ECD: How does advanced middleware technology enable developers to build better software for the cloud?
BREWER: Akka is an event-driven middleware framework implemented in Scala for building reliable, high-performance distributed applications. It raises the abstraction level for the developer, removing the need to worry about the low-level plumbing required to create highly concurrent applications in languages such as Java.
Raising the abstraction level is key for building better software in the cloud. Developers can focus on implementing business logic and adding value, not spending time worrying about implementing low-level features such as high-availability services and state/memory management. With Akka, the developer gets an ideal fabric for the cloud that is:
- Elastic and dynamic, with the ability to expand and contract based on the actual load the system is experiencing
- Fault-tolerant and self-healing, where the system detects failures automatically and can restart individual components or entire servers based on the business requirements
- Customizable and adaptive load-balancing, where software components can route messages based on system load or any other user-definable criteria
- Configured so that clusters can rebalance the load in failover situations via actor migration, where actors are moved between systems dynamically
The bottom line is that it’s very easy to build loosely coupled and dynamic systems that can almost organically change and adapt at runtime.
ECD: Briefly explain Typesafe’s technology and the current applications for it in an embedded computing environment.
BREWER: Typesafe’s vision is to enable development of concurrent, fault-tolerant applications with a single unified programming model, managed runtime, and binary compatible distribution.
Typesafe was founded in 2011 by the creators of the Scala programming language and Akka middleware, who joined forces to create a modern software platform for the era of multicore hardware and cloud computing workloads. The company provides an easy-to-use packaging of Scala, Akka, Play!, and developer tools through both an open-source stack and a commercial stack that provides commercial support, maintenance, and operations tools via the Typesafe Subscription. In conjunction with its partners, Typesafe also provides training and consulting services to accelerate the commercial adoption of Scala, Akka, and Play!
Companies that use the Typesafe Stack in an embedded way typically rely on its low latency, high throughput, and resiliency design points. It is used as for handling millions of messages per second across networks and network devices.
ECD: What challenges are your customers dealing with right now?
BREWER: Performance at scale is a main driver for customers to consider the Typesafe Stack. We’ve found that customers who have tried the traditional development paradigms using JEE application servers, PHP, and Ruby hit a performance or efficiency wall. In addition to being highly efficient, the components of the Typesafe Stack are compact from both a disk and memory standpoint, especially when compared to the traditional JEE application server, and lend themselves well to the embedded space.
Typesafe [email protected] typesafe.com
Follow: @typesafe Facebook Linkedin