Scala (pronounced /ˈskɑːlə/ SKAH-lə or /ˈskeɪlə/ SKAY-lə) is a multi-paradigm A multi-paradigm programming language is a programming language that supports more than one programming paradigm. As Leda designer Timothy Budd holds it: The idea of a multiparadigm language is to provide a framework in which programmers can work in a variety of styles, freely intermixing constructs from different paradigms. The design goal of programming language A programming language is an artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine, to express algorithms precisely, or as a mode of human communication designed to integrate features of object-oriented programming Object-oriented programming is a programming paradigm that uses "objects" – data structures consisting of datafields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, modularity, polymorphism, and and functional programming In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state. Functional programming has its roots in the.[1] The name Scala stands for "scalable language", signifying that it is designed to grow with the demands of its users.

Contents

Platforms and license

Scala runs on the Java platform Java refers to a number of computer software products and specifications from Sun Microsystems, a subsidiary of Oracle Corporation, that together provide a system for developing application software and deploying it in a cross-platform environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones on the (Java Virtual Machine A Java Virtual Machine enables a set of computer software programs and data structures to use a virtual machine model for the execution of other computer programs and scripts. The model used by a JVM accepts a form of computer intermediate language commonly referred to as Java bytecode. This language conceptually represents the instruction set of) and is compatible with existing Java Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) programs. It also runs on Java Platform, Micro Edition Java Platform, Micro Edition, or Java ME, is a Java platform designed for mobile devices and embedded systems. Target devices range from industrial controls to mobile phones and set-top boxes. Java ME was formerly known as Java 2 Platform, Micro Edition (J2ME) Connected Limited Device Configuration The Connected Limited Device Configuration is a specification of a framework for Java ME applications targeted at devices with very limited resources such as pagers and mobile phones. The CLDC was developed under the Java Community Process as JSR 30 (CLDC 1.0) and JSR 139 (CLDC 1.1).[2] An alternative implementation exists for the .NET platform The Microsoft .NET Framework is a software framework that can be installed on computers running Microsoft Windows operating systems. It includes a large library of coded solutions to common programming problems and a virtual machine that manages the execution of programs written specifically for the framework. The .NET Framework is a Microsoft, but it has not been kept up to date.[3]

Scala has the same compilation model as Java and C# C# is a multi-paradigm programming language encompassing imperative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines. It was developed by Microsoft within the .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270). C# is one of the programming languages (separate compilation, dynamic class loading), so Scala code can call Java libraries (or .NET libraries in the .NET implementation).

Scala's operational characteristics are the same as Java's. The Scala compiler generates byte code that is nearly identical to the Java compiler. In fact, Scala code can be decompiled to readable Java code, with the exception of certain constructor operations. To the JVM, Scala code and Java code are indistinguishable. The only difference is a single extra runtime library, scala-library.jar.[4]

The Scala software distribution, including compiler and libraries, is released under a BSD license The phrase BSD licenses represents a family of permissive free software licenses. The original was used for the Berkeley Software Distribution , a Unix-like operating system after which the license is named.[5]

History

The design of Scala started in 2001 at the École Polytechnique Fédérale de Lausanne The École Polytechnique Fédérale de Lausanne is one of the two Swiss Federal Institutes of Technology and is located in Lausanne, Switzerland. EPFL is ranked as Europe's number 1 and world's number 15 university in the field of "Engineering/Technology and Computer Sciences" in the academic ranking of world universities (ARWU) by (EPFL) by Martin Odersky, following on from work on Funnel, a programming language combining ideas from functional programming and Petri nets A Petri net is one of several mathematical modeling languages for the description of discrete distributed systems. A Petri net is a directed bipartite graph, in which the nodes represent transitions (i.e. discrete events that may occur), places (i.e. conditions), and directed arcs (that describe which places are pre- and/or postconditions for.[6] Odersky had previously worked on Generic Java and javac, Sun's Java compiler.[6] Scala was released late 2003 / early 2004 on the Java platform, and on the .NET platform in June 2004.[1][6][7] A second version of the language, v2.0, was released in March 2006.[1]

As of April 2010, the latest release is version 2.7.7. A beta of Scala 2.8 is also available. Features slated for 2.8 include an overhaul of the Scala collections library, named and default parameters for methods, package objects, and continuations A continuation reifies an instance of a computational process at a given point in the process's execution. It contains information such as the process's current stack , as well the process's point in the computation. Such an instance can then be later resumed upon invocation. The "current continuation" or "continuation of the.[8]

Object-oriented features

Scala is a pure object-oriented language An object-oriented programming language is one in which everything (involved in program) is defined under a class having some common properties and functions among them and these are called it's objects. And that allows or encourages, to some degree, object-oriented programming techniques such as encapsulation, inheritance, modularity, and in the sense that every value is an object In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure. Data types A data type In programming, a classification identifying one of various types of data, as floating-point, integer, or Boolean, stating the possible values for that type, the operations that can be done on that type, and the way the values of that type are stored and behaviors of objects are described by classes In object-oriented programming, a class is a construct that is used as a blueprint to create objects of that class. This blueprint describes the state and behavior that the objects of the class all share. An object of a given class is called an instance of the class. The class that contains (and was used to create) that instance can be considered and traits. Class abstractions are extended by subclassing and by a flexible mixin In object-oriented programming languages, a mixin is a class that provides a certain functionality to be inherited by a subclass, while not meant for instantiation . Inheriting from a mixin is not a form of specialization but is rather a means of collecting functionality. A class may inherit most or all of its functionality from one or more mixins-based composition mechanism to avoid the problems of multiple inheritance.

Functional programming

Scala also supports functional programming In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state. Functional programming has its roots in the. The language provides a lightweight syntax for defining anonymous functions, supports higher-order functions In mathematics these are also known as operators or functionals. The derivative in calculus is a common example, since it maps a function to another function, allows functions to be nested, and supports currying In mathematics and computer science, currying or Schönfinkelisation, invented by Moses Schönfinkel and later re-invented by Haskell Curry,[not specific enough to verify] is the technique of transforming a function that takes multiple arguments in such a way that it can be called as a chain of functions each with a single argument. Using the keyword lazy defers the initialization of a variable until this variable is used. Evaluation of delimited continuations will be supported in version 2.8.

Scala's case classes and its built-in support for pattern matching In computer science, pattern matching is the act of checking for the presence of the constituents of a given pattern. In contrast to pattern recognition, the pattern is rigidly specified. Such a pattern concerns conventionally either sequences or tree structures. Pattern matching is used to test whether things have a desired structure, to find model Algebraic data types In computer programming, particularly functional programming and type theory, an algebraic data type is a datatype each of whose values is data from other datatypes wrapped in one of the constructors of the datatype. Any wrapped datum is an argument to the constructor. In contrast to other datatypes, the constructor is not executed and the only used in many functional programming languages.

Tail call In computer science, a tail call is a subroutine call which is followed by a return to the calling code. Such a call is said to be in tail position. If a subroutine performs a tail call to itself, it is called tail recursive. Tail calls can usually be optimized into more efficient code by removing unnecessary call stack manipulation—in effect, optimization is not supported completely, because the JVM lacks tail call support. In simple cases, the Scala compiler can optimize tail calls into loops.[9]

An implementation of a Quicksort Quicksort is a well-known sorting algorithm developed by C. A. R. Hoare that, on average, makes comparisons to sort n items. In the worst case, it makes comparisons, though if implemented correctly this behavior is rare. Typically, quicksort is significantly faster in practice than other algorithms, because its inner loop can be efficiently algorithm in functional style, for comparison with the Erlang Quicksort example Erlang is a general-purpose concurrent programming language and runtime system. The sequential subset of Erlang is a functional language, with strict evaluation, single assignment, and dynamic typing. For concurrency it follows the Actor model. It was designed by Ericsson to support distributed, fault-tolerant, soft-real-time, non-stop:

def qsort: List[Int] => List[Int] = {
case Nil => Nil
case pivot :: tail =>
val (smaller, rest) = tail.partition(_ < pivot)
qsort(smaller) ::: pivot :: qsort(rest)
}

Static typing

Scala is equipped with an expressive static type system that enforces the safe and coherent use of abstractions. In particular, the type system supports:

Extensibility

The design of Scala acknowledges the fact that, in practice, the development of domain-specific applications often requires domain-specific language In software development and domain engineering, a domain-specific language is a programming language or specification language dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique. The concept isn't new—special-purpose programming languages and all kinds of modeling/ extensions. Scala provides a unique combination of language mechanisms that make it easy to smoothly add new language constructs in the 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.

Concurrency

Scala has built-in support for the actor model In computer science, the Actor model is a mathematical model of concurrent computation that treats "actors" as the universal primitives of concurrent digital computation: in response to a message that it receives, an actor can make local decisions, create more actors, send more messages, and determine how to respond to the next message, in addition to the standard Java concurrency APIs. An alternative CSP implementation for channel-based message passing is Communicating Scala Objects[10].

Software using Scala

Lift is a free Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with minimal restrictions only to ensure that further recipients can also do these things and that manufacturers of consumer- web application framework that aims to deliver benefits similar to Ruby on Rails Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language. It is intended to be used with an Agile development methodology that is used by web developers for rapid development. The use of Scala means that any existing Java Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) library and Web container In Java Platform, Enterprise Edition, a web container "implements the web component contract of the J2EE architecture". This contract specifies a runtime environment for web components that includes security, concurrency, life-cycle management, transaction, deployment, and other services. A web container provides the same services as a can be used in running Lift applications.

In April 2009 Twitter Twitter is a social networking and microblogging service, owned and operated by Twitter Inc., that enables its users to send and read other user messages called tweets. Tweets are text-based posts of up to 140 characters displayed on the author's profile page. Tweets are publicly visible by default, however senders can restrict message delivery to announced they had switched large portions of their backend from Ruby Ruby is a dynamic, reflective, general purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was initially developed and designed by Yukihiro "Matz" Matsumoto. It is based on Perl, Smalltalk, Eiffel, Ada,[citation needed] and Lisp to Scala and intended to convert the rest.[11] In addition, Wattzon has publicly been noting that its entire platform has been written from the ground up in Scala.[12]

Foursquare uses Scala and Lift.

"Hello world" example

Here is the classic Hello world program A "Hello World" program is a computer program which prints out "Hello, World!" on a display device. It is used in many introductory tutorials for teaching a programming language. Such a program is typically one of the simplest programs possible in most computer languages. It is often considered to be tradition among programmers written in Scala:

object HelloWorld extends Application {
println("Hello, world!")
}

or

object HelloWorld {
def main(args: Array[String]) {
println("Hello, world!")
}
}

Notice how similar it is to the stand-alone Hello World application for Java Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file). A notable difference is that nothing is declared to be static; the singleton created by the object keyword is used instead.

Assuming the program is saved in a file named HelloWorld.scala, it can then be compiled from the command line:

> scalac HelloWorld.scala

To run it:

> scala -classpath . HelloWorld

This is analogous to how a Java "hello world" program is compiled and run. Indeed, Scala's compilation and execution model is identical to that of Java, making it compatible with Java build tools such as Ant Apache Ant is a software tool for automating software build processes. It is similar to Make but is implemented using the Java language, requires the Java platform, and is best suited to building Java projects.

It is also possible to feed this program directly into the Scala interpreter, using the option -i (to load code from the file) and the option -e (to execute additional code needed to actually invoke the HelloWorld object's method):

> scala -i HelloWorld.scala -e 'HelloWorld.main(null)'

An alternative shorter version of the Hello World scala program is

println("Hello, world!")

which if saved in a file called HelloWorld2.scala, can then simply be run using:

> scala HelloWorld2.scala

Testing

There are some ways to test code in Scala:

The built-in Scala library SUnit is deprecated and will be removed in version 2.8.0, see SUnit documentation.

See also

References

  1. ^ a b c d Martin Odersky et al., An Overview of the Scala Programming Language, 2nd Edition
  2. ^ "Scala on .NET". Programming Methods Laboratory of EPFL The École Polytechnique Fédérale de Lausanne is one of the two Swiss Federal Institutes of Technology and is located in Lausanne, Switzerland. EPFL is ranked as Europe's number 1 and world's number 15 university in the field of "Engineering/Technology and Computer Sciences" in the academic ranking of world universities (ARWU) by. 2008-01-07. http://www.scala-lang.org/docu/clr/. Retrieved 2008-01-15. "Scala is primarily developed for the JVM and embodies some of its features. Nevertheless, its .NET support is designed to make it as portable across the two platforms as possible."
  3. ^ http://www.artima.com/weblogs/viewpost.jsp?thread=163733
  4. ^ http://blog.lostlake.org/index.php?/archives/73-For-all-you-know,-its-just-another-Java-library.html
  5. ^ http://www.scala-lang.org/node/146
  6. ^ a b c Martin Odersky, "A Brief History of Scala", Artima.com weblogs, June 9, 2006
  7. ^ Martin Odersky, "The Scala Language Specification Version 2.7"
  8. ^ Scala 2.8 Preview
  9. ^ Tail calls, @tailrec and trampolines
  10. ^ Communicating Scala Objects, Bernard Sufrin, Communicating Process Architectures 2008
  11. ^ Greene, Kate (April 1, 2009). "The Secret Behind Twitter's Growth, How a new Web programming language is helping the company handle its increasing popularity.". Technology Review. MIT. http://www.technologyreview.com/blog/editors/23282/?nlid=1908. Retrieved April 6, 2009.
  12. ^ Cloud, Jeremy (March 10, 2009). "Scala + WattzOn, sitting in a tree...". http://www.slideshare.net/raffikrikorian/scala-wattzon-sitting-in-a-tree.

Further reading

External links

Categories: Scala programming language | Functional languages | Object-oriented programming languages | Statically-typed programming languages | JVM programming languages | .NET programming languages | Java programming language family | Concurrent programming languages | Java platform

Personal tools
Namespaces
Variants
Views
Actions
Navigation
Interaction
Toolbox
Print/export
Languages

 

The above information uses material from Wikipedia and is licensed under the GNU Free Documentation License.
Some facts may not have been fully verified for accuracy. [Disclaimers]
This page was last archived by our server on Thu Jul 29 01:52:56 2010. [ refresh local cache ]
Displaying this page or its contents does not use any Wikimedia Foundation's resources.
The owners of this site proudly support the Wikimedia Foundation.


Programming Scala--New from O'Reilly: Scalability = Functional ... - Media Newswire (press release)
news.google.com
Programming Scala --New from O'Reilly: Scalability = Functional ...

Media Newswire (press release)

Sebastopol, CA-Learn how to be more productive with Scala , a new multi-paradigm language for the Java Virtual Machine (JVM) that integrates features of both ...
Google News Search: Scala (programming language),
Thu Jul 29 01:53:03 2010
highres 10548804 jpeg
photos4.meetupstatic.com
highres 10548804 jpeg
480px x 640px | 115.60kB

[source page]

We are going to look at Scala programming language and how to integrate with Java

Yahoo Images Search: Scala (programming language),
Thu Jul 29 01:53:04 2010
Lift picking up momentum
scala-lang.org
Lift picking up momentum

bagwell

Wed, 06 May 2009 09:41:56 GM

In the May/June 2009 Edition of the IEEE Internet Computing journal Steve Vinoski publishes an article ". Scala. and Lift - Functional Recipes for the Web" in his column "The Functional Web".

Google Blogs Search: Scala (programming language),
Thu Jul 29 01:53:04 2010