Features of Scala

Scala is a Functional and Object-Oriented language, by adopting Scala you can take benefits of functional programming features as well as object-oriented programming features.

The following are some of the features of Scala.

    1. Functional Programming

    Scala is a functional programming language in which each function is represented as a value. It supports very easy syntax features to define anonymous functions, Scala supports nesting of functions as well as currying. The case classes and built-in support of Scala support the functionality of algebraic types function that is used by various functional languages.

    2. Flexibility in Syntax

    Scala provides Flexibility in writing codes and does not need unnecessary Semicolons if there is an end of the line in a program then it will treat that as the end of the expression or statement although we can use Semicolons to separate the code or expression. The methods in Scala can be used as an infix operator and so on.

    3. Statically Typed

    Scala is the language of the static types that means the type of a variable is known to the compiler if it is properly defined. If the type is not identified by the compiler then an invalid type error is thrown.

    The following is the list of types supported by Scala.

    • Polymorphic methods
    • Implicit parameters and conversions
    • Explicitly typed self-references
    • Compound types
    • Abstract type & Inner classes members as object members
    • Upper and lower type bounds
    • Variance annotations
    • Generic classes

    4. Functional Tendencies

    Scala supports all object-oriented features available in Java, it also provides a large number of capabilities that are present in the functional programming language and this way Scala can be written in a functional programming language but at the same time, object-oriented styles and functional style can be mixed as well.

    The following are some of the examples.

    • Pattern matching
    • Tuples
    • Nested functions
    • Higher-order functions
    • Lazy evaluation
    • Immutable variables and objects
    • No distinction between statements and expressions

    5. Immutability

    Scala applies a distinction between immutable and mutable variables. Mutable variables are declared using the var keyword and immutable values are declared using the val keyword.