Scala Programming Language : Introduction

The word “Scala” is a short form of the term “Scalable Language”. Technically, Scala programming is a combination of the two style of programming approaches and those are “Object Oriented Programming” and “Functional Programming”. The Object Oriented approach makes language very easy to build large applications with big structures and architecture and Functional approach keeps design very modular and pluggable. This is how Scala language is empowered by fusion of both of these approaches.


Know more about Functional Programming…..

So what are the features provided by Scala?

Scala is Object Oriented

Scala is considered to be purely object oriented language which means everything in Scala is an object. There are no primitive types and operators available in Scala. Being an object oriented language and using JVM as a platform, Scala is fully compatible to use most of the Java libraries.

Scala is Functional

Scala is also a functional language. So, functions are the primary candidates rather than in objects in object oriented languages. It means programmer can focus on “WHAT to develop” rather than “HOW to develop”. It also have overcome the limitations of OOP for concurrent processing using immutable collections and types.

Scala uses JVM

Scala compiler compiles Scala code to the byte code same as Java compiler. It internally uses JVM for execution of the byte code hence it is also platform independent as Java.

Scala is compatible

Java and Scala both generates the byte code (in form of .class files) so it is quite possible to access Java classes in Scala and visa-versa.

Scala code is concise

The constructs of Scala language are more expressive than Java. Scala code is quite short compare to equivalent Java code.

Check below Example,

//Java Code 
class Employee{
    private String empName;
    private int empAge;
    public Employee(String empName, int empAge){
        this.empName = empName;
        this.empAge = empAge;

//Equivalent Scala code
class Employee(empName: String, empAge: Int)


Scala is high level

Scala code is more expressive than Java(Up to Java 7). As a programmer one should focus only on core logic rather than dealing with the other complexities. Scala keeps all side formalities of Java code away from programming.

Let’s have a look,

//Java code to find that a String contains any digit or not
boolean strHasDigit = false;
for (int i = 0; i < str.length(); ++i) {
    if (Character.isDigit(name.charAt(i))) {
        strHasDigit = true;

//Equivalent Scala code
val strHasDigit = str.exists(_.isDigit) 


Scala is statically typed

In simple words, Scala language has a very advance static type system. That means Scala automatically detects the type of the variable from its value and infers the variable type same as value type. Same as Java one should not have to declare the variable with type. Scala discovers and manages type of its variables and methods at runtime. Which allows to design a strong foundation for custom types for flexible and pluggable system design.

That’s it for now. We’ll learn more about Scala in my upcoming posts…..!!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>