Introduction to Scala
Scala is the abbreviation of Scalable Language and is a multi-paradigm programming language
Martin Odersky of the Federal Institute of Technology Lausanne (EPFL) started designing Scala in 2001 based on the work of Funnel.
Funnel is a programming language that combines functional programming ideas with Petri nets.
Odersky's previous work was on Generic Java and javac (Sun Java compiler). Scala for the Java platform was released in late 2003/early 2004. Scala for the .NET platform was released in June 2004. The second version of the language, v2.0, was released in March 2006.
As of September 2009, the latest version is version 2.7.6. Expected features in Scala 2.8 include an overridden Scala collections library, named and default parameters for methods, package objects, and Continuations.
In April 2009, Twitter announced that they had migrated most of their backend programs from Ruby to Scala, and planned to migrate the rest. In addition, Wattzon has publicly stated that its entire platform is already written based on Scala infrastructure.
Scala features
Object-oriented features
Scala is a pure object-oriented language, and every value is an object. The data type and behavior of an object are described by classes and traits.
There are two ways to extend the class abstraction mechanism: one way is subclass inheritance, and the other way is the flexible mixing mechanism. These two approaches can avoid the problems of multiple inheritance.
Functional programming
Scala is also a functional language, and its functions can also be used as values. Scala provides a lightweight syntax for defining anonymous functions, supports higher-order functions, allows nesting of multiple levels of functions, and supports currying. Scala's case classes and their built-in pattern matching are equivalent to the algebraic types commonly used in functional programming languages.
Furthermore, programmers can use Scala's pattern matching to write code similar to regular expressions to process XML data.
Static Type
Scala has a type system that ensures code security and consistency through compile-time checks. The type system specifically supports the following features:
Generic classes
Covariance and contravariance
Mark
Upper and lower bound constraints on type parameters
Treat categories and abstract types as object members
Composite type
Explicitly specify the type when referencing yourself
View
Polymorphism Approach
Extensibility
Scala is designed to adhere to the fact that in practice, domain-specific application development often requires a language specific to that domain Extension. Scala provides many unique language mechanisms, making it easy and seamless to add new language constructs in the form of libraries:
Any method can be used as a prefix or postfix operator
Closures can be automatically constructed based on the expected type.
Concurrency
Scala uses Actor as its concurrency model. Actor is a thread-like entity that sends and receives messages through mailboxes. Actors can reuse threads, so millions of Actors can be used in the program, while threads can only create thousands. In versions after 2.10, Akka is used as its default Actor implementation.
Who uses Scala
In April 2009, Twitter announced that they had migrated most of their backend programs from Ruby to Scala, and planned to move the rest as well To be migrated.
In addition, Wattzon has publicly announced that its entire platform is already written based on Scala infrastructure.
UBS uses Scala for general products.
Coursera uses Scala as the server language.
Scala Web Framework
The following is a list of two currently popular Scala web application frameworks:
Lift Frame
Play Frame