I heard a lot about this language, but my hands didn’t reach it at all. I began to study it and decided to share it with you.
Scala is a multi-paradigm programming language designed to be concise and type safe for simple and fast programming. It organically combines the possibilities of functional and object-oriented programming. Read more here
http://ru.wikipedia.org/wiki/ScalaI want to emphasize that Scala language in the JAVA virtual machine, which allows it to use Java libraries, also has the ability to use these two languages in one project and whatnot ...
Scala has absorbed a significant number of concepts and syntax conventions for Java and C #. The way property is expressed is largely borrowed from Sather. The concept of a unified object model is taken from Smalltalk.
I think that's enough words. You yourself understood what the Scala language is. Let's move on to the code itself. This is how the simplest Hellow World looks like:
object HelloWorld {
def main(args: Array[String])={
System.out.println("Hello World")
}
}
')
Very similar to Java code, explain the difference. The object keyword initially indicates that this class is singelton. Very convenient, isn't it? The declaration of methods here, as in Python, is done using the
def keyword. Parameters in brackets indicate the parameters passed to the
args: Array[String]
method
args: Array[String]
The declaration of variables looks like this
: Type . In Java, the main method takes an array of strings, in Scala, arrays are collections of the Array type, and inside the [] characters, the Type stored in the collection is indicated, this is how the List is in Java. that is, functions (methods) in it are variables that can be assigned a value, which we do
def main (args: Array [String]) = {. Scala can use the standard java class library, which is supplemented by its own Scala library, in the example we use Java class System for output, as you can see Scala and Java calmly use each other.
Links to language
www.scala-lang.org Do not judge strictly myself just learning this language.
That's all, if someone likes, I will write further, as you learn the language