2010年10月18日 星期一 09:55
Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive. Code sizes are typically reduced by a factor of two to three when compared to an equivalent Java application.
Many existing companies who depend on Java for business critical applications are turning to Scala to boost their development productivity, applications scalability and overall reliability.
For example, at Twitter , the social networking service, Robey Pointer moved their core message queue from Ruby to Scala. This change was driven by the company's need to reliably scale their operation to meet fast growing Tweet rates, already reaching 5000 per minute during the Obama Inauguration . Robeys thinking behind the Twitter Kestrel project is explained in the developers live journal . His concise 1500 lines of Scala code can be seen as he has generously made them available as an open source project.
Many top-notch programmers and industry leaders have already been captivated by Scala. They have become quite vocal encouraging others, creating a growing range of books on Scala and an almost endless supply of tips for Java programmers new to Scala, some of which are collected in "Java to Scala with the help of experts" . While here on the scala-lang site, there is a broad range of material too, from introductory Scala tutorials to advanced language research topics , or look at some Scala code examples , or just get started by installing Scala now.
Existing Java code and programmer skills are fully re-usable. Scala programs run on the Java VM, are byte code compatible with Java so you can make full use of existing Java libraries or existing application code. You can call Scala from Java and you can call Java from Scala, the integration is seamless. Moreover, you will be at home with familiar development tools, Eclipse, NetBeans or Intellij for example, all of which support Scala. It does not take long to become an effective Scala programmer when you are half way there already!
The Scala compiler is mature and proven highly reliable by years of use in production environments, The compiler was written by Martin Odersky who also wrote the Java reference compiler and co-authored the generics, used by millions of Java programmers today. You can be confident his implementation of the Scala compiler produces byte code that performs every bit as good as comparable Java code.
After having written hundreds of thousands lines of Java himself, Martin Odersky, Professor at EPFL, was well aware of the frustrations faced by Java programmers. He formed the vision of applying the best knowledge of the academic research community to the problem of making the Java programming experience better, even fun. His first pragmatic step was Java Generics, seen as a major success by the Java community. But for the full vision of scalable concurrent programming to be achieved he saw that the basic Java syntax would need to change. You simply couldn't get there from here. But a deceptively simple shift in syntax gained better uniformity to the object-oriented aspects of Java, and this in turn enabled a natural fusion with functional programming concepts which are critical for tackling concurrency. In 2001 Scala was born.
Some Java programmers find Scala a little alien at first but soon enjoy the concise way they can express their ideas as programs. Less key-strokes to make. Type inferencing, everthing-is-an-object, function passing, and many other features cut away unneeded syntactic overhead. With growing experience they find Scala has the abstraction support to simplify the creation of safe, generic libraries that are easy to use. Some go all the way to create their own Domain Specific Language (DSL). Scala scales with the programmer. The more a programmer learns the more depth they find in Scala and the easier even more complex tasks become. Most programmers report an 'ah-ah, I get it!' moment when they suddenly see the multifaceted aspects of Scala fuse into a smoothly interlocking set of concepts with incredible problem solving power.
For the small price of learning some new syntax, anyone can write programs with the same ease that they did in Java and steadily gain in problem solving power.
For programming language specialists a Scala language technical summary follows.
Scala is a pure object-oriented language in the sense that every value is an object . Types and behavior of objects are described by classes and traits . Classes are extended by subclassing and a flexible mixin-based composition mechanism as a clean replacement for multiple inheritance.
Scala is also a functional language in the sense that every function is a value . Scala provides a lightweight syntax for defining anonymous functions, it supports higher-order functions , it allows functions to be nested , and supports currying . Scala's case classes and its built-in support for pattern matching model algebraic types used in many functional programming languages.
Furthermore, Scala's notion of pattern matching naturally extends to the processing of XML data with the help of right-ignoring sequence patterns . In this context, sequence comprehensions are useful for formulating queries. These features make Scala ideal for developing applications like web services .
Scala is equipped with an expressive type system that enforces statically that abstractions are used in a safe and coherent manner. In particular, the type system supports:
A local type inference mechanism takes care that the user is not required to annotate the program with redundant type information. In combination, these features provide a powerful basis for the safe reuse of programming abstractions and for the type-safe extension of software.
In practice, the development of domain-specific applications often requires domain-specific language extensions. Scala provides a unique combination of language mechanisms that make it easy to smoothly add new language constructs in form of libraries:
A joint use of both features facilitates the definition of new statements without extending the syntax and without using macro-like meta-programming facilities.
Scala is designed to interoperate well with the popular Java 2 Runtime Environment ( JRE ). In particular, the interaction with the mainstream object-oriented Java programming language is as smooth as possible. Scala has the same compilation model (separate compilation, dynamic class loading) like Java and allows access to thousands of existing high-quality libraries. Support for the .NET Framework ( CLR ) is also available.
2010年10月18日 星期一 10:02
Scala Compiler is mature, high reliable, but in fact, it is not exactly with high performance, scalac is slow to some extent, to improve the performance of scala compilation, use fsc in stead.
Zeuux © 2024
京ICP备05028076号