My beginnings in Scala or learn Scala after Java

    I heard a lot about this language, but my hands did not reach it at all. Here 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 quick programming. It organically combines the capabilities of functional and object-oriented programming. For more details, read here
    I want to emphasize that Scala is a language in the JAVA virtual machine, which gives it the opportunity to use Java libraries, it is also possible to use these two languages ​​in one project and much more ...

    Scala has absorbed a significant number of Java and C # concepts and syntax conventions. The way that properties are expressed is largely borrowed from Sather. Smalltalk takes the concept of a unified object model.

    I think there are enough words. You yourself understood what kind of Scala language is. Let's move on to the code. This is the simplest Hello World: It looks very much like Java code, I will explain the difference the keyword object initially indicates that this class is a singleton. Very convenient isn't it? Declaring methods here is done in Python using the def keyword . The parameters passed to the method are indicated in parentheses. The declaration of variables looks like this : Type
    object HelloWorld {
    def main(args: Array[String])={
    System.out.println("Hello World")

    args: Array[String]
    . In Java, the main method accepts an array of strings, in Scala arrays are collections of type Array, and inside the characters [] the Type is stored in the collection, it's like List in Java. Scala language is not only OO but also Functional, that is, functions (methods) in it are variables that can be assigned a value, which is what we do def main (args: Array [String]) = { .Scala can use the standard Java class library, which is complemented by its own Scala library, in the example we use the Java class System to output how you see Scala and Java calmly use each other.

    Links to the language
    Do not judge strictly, I only study this language myself.
    That's all, if someone liked it, I will write further, as I study the language

    Also popular now: