The name of the Scala language comes from the "extensible language", and Scala is a language that blends the function objects. It can run on the Java platform, and the Scala program is compiled into the JVM's byte code. Their performance is usually consistent with Java programs. Scala code can invoke Java methods, Access Java fields, inherit from Java classes and implement Java interfaces
Download and install Scala
You can download the Scala package from the Scala home page: http://www.scala-lang.org/, so far, the latest release is 2.7.5-final, and the IDE's supporting plug-ins are available, Eclipse's Scala plugin download address is: HTTP://WWW.SCALA-LANG.ORG/NODE/94, or can be downloaded via Eclipse's update Manager: http:// Www.scala-lang.org/scala-eclipse-plugin (now the Eclipse plugin is supported as if it's a bit lame)
To unzip the Scala download compression package, such as decompression address is: C:\Program files\java\scala-2.7.5, and then set the environment variable, the Scala_home set to: C:\Program files\java\ scala-2.7.5, add scala_home\bin to the PATH environment variable and open the command line input: scalac-version test, OK if you can enter the version information correctly.
Get to know Scala.
In the field of computer science, everyone has reached a tacit understanding, usually using "HelloWorld" as a demo program, here is no exception, Scala syntax and Java is still very different, just like a foreign Daniel criticism Scala is "for different", Why not use Java-like syntax as groovy does, and if you're going from the JDK to Scala, the feeling of learning Scala may be different, or you might have an aversion to it, and in fact, it's usually the feeling that you're unfamiliar with it, and if you know the design intent behind it, May change your current point of view.
Here's a look at the HelloWorld in Java:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("HelloWorld");
}
}
Scala's HelloWorld:
1 object HelloWorld {
2 def main(args: Array[String]) {
3 System.out.println("HelloWorld");
4 }
5 }
The Scala declaration class here differs from Java in that Scala is defined by object, uses the definition of "def" to start the function in the method block, declares the function name, specifies the argument list in parentheses, and the argument is declared by the parameter name: the type of the argument. The return value type of the method is specified after the parentheses after the function name, for example, if you declare a method without parameters, the return value type int can be written as: Def A (): Int = {/method content}; The main function above shows the specified return value, the system default return value type is unit, which is equivalent to void in Java, but it has been set to @deprecated in the latest version, which means that the specified return type is not displayed. This approach is a lot simpler.
Here just compare Scala's HelloWorld writing, through such a simple task obviously and Java code simplicity of the PK is not to compete. If you want to see a better showdown, refer to the documentation on Scala's official website: Documentation: http://www.scala-lang.org/node/197 Example: http://www.scala-lang.org/node/219, The official website of IBM also has articles on Scala for a detailed introduction http://www.ibm.com/developerworks/cn/java/j-scala/