Skip to content
Related Articles

Related Articles

Interesting fact about Scala

View Discussion
Improve Article
Save Article
  • Last Updated : 26 Feb, 2019

Scala(pronounced as “skah-lah”) is general-purpose programming language designed by Martin Odersky. The design of Scala started in 2001 at EPFL, Lausanne, Switzerland. Scala was released publicly in 2004 on Java platform. Scala is designed to be concise and addresses criticisms of Java. Scala source code is compiled to Java byte code and the resulting executable code runs on a Java Virtual Machine. The latest release of Scala is 2.12.8.

Some Interesting Facts About Scala

  • Name: Scala is short for Scalable Language.
  • A Hybrid Language: Scala is a fusion of Object Oriented Programming(OOP) and Functional Programming. OOP is a programming paradigm based on the concept of “objects”, which are data structures that contain data in the form of fields and code in the form of procedures or methods. On the other hand, Functional programming is a programming paradigm, computer programs, are building by a structure and elements. that the evaluation of mathematical functions are treated as computation and avoids mutable data and also avoids changing-state . These two paradigms differentiate Scala from other programming languages.
  • Auto-Inference: Scala automatically infers type information. Type information is supplied by the user only if it is necessary.
  • Mutable and Immutable Variables: Scala allows us to make any variable mutable or immutable at the time of declaration. Keyword var defines any variable as mutable while keyword val defines a variable as immutable.
  • No Semicolon: Semicolon acts as a separator in most of the modern programming languages(C, C++, Java, etc) and is a mandatory character to be written after every statement. However, Scala does not need a semicolon after every statement. Scala statements can be separated by newline character.
  • Import statements: It is not necessary to write all import statements in the beginning of the program. Importing classes in Scala can be done at any point.
  • Features of Scala: Apart from all OOP features of Java, Scala has features of functional programming languages like Scheme, Standard ML and Haskell, including currying, type inference, immutability, lazy evaluation, and pattern matching.
  • Functions and Procedures: In Scala, functions and procedures are two different entities and are not used interchangeably. Function can return any type and contains = sign in its prototype. Procedure, on the other hand, does not have = sign and has Unit() return type in all cases. Print statements are generally not encouraged in function definition.

    def func1():Int = {
    //this is a function
    //returns Int
    def proc1() {
    //this is a procedure
    //returns void(Unit())
  • Higher-Order Functions: In Scala, we can pass a function as an argument to another function. Such functions are called higher-order functions.

    val l = List(1, 2, 3)
    l.foreach(println) // println passed as an argument to foreach function

    Also, a function’s return value can be another function.

    def square(x:Float) = { pow(x, 2) }
  • Supports Nested Functions: We can define a function within another function and make use of it as per the requirement. Nested function can be called from any point within the scope of outer function.
  • Big Data Industry: Apache Spark is an open-source cluster-computing framework and is a widely used technology for big data processing. Spark programs are written in Scala because of its scalability on JVM . Scala is most prominently used language by big data developers for working on Spark projects. Use cases of Spark with Scala- Alibaba, Netflix, Pinterest, etc.
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!