Scalability of a language is effected by some factors ranging from syntax details to component abstraction construct. The main aspect of scala that makes it scalable is that it is a combination of both object-oriented and functional programming. It has good support for both the programming constructs like high-order functions, tail-call optimization, immutable values, pattern matching, polymorphism, abstraction, inheritance etc. Scala also includes its own interpreter which can be used to execute instruction directly, without previous compiling. Another key feature is parallel collections library designed to help developers address parallel programming patterns.
Some Another features are as follow :
- Scala is concise. it provides a better support for backend operations. Scala programs tend to be short upto a factor of 10 compared to Java. It avoids code that shows up again and again in order to get some result that burdens Java program.
Example: In Java, a class with constructor looks like:
// data members of the class.
// contructor would initialized data members
// with the values of passed arguments while
// object of that class created.
.name = name;
.id = id;
In Scala it’ll be written as:
- Scala helps you manage complexity by letting we raise the level of abstraction in the interfaces we design. Java treats stings as low-level entities that are stepped through character by character in a loop. The Scala code treats same string as higher-level sequences of character that can be queried. Scala provides the facility to develop the frameworks and libraries.
Example: In Java,to find the first uppercase letter.
// Function to find string which has
// first character of each word.
; i < str.length(); i++)
In scala it will be written as:
In Java code, string is low level entities whereas in Scala same string is treated as high level entities. In Scala _.isUpperCase is a function literals.
- It supports static typing in which computations are formed as statements that change program state at compile time. It is an approach that can provide improved runtime efficiencies. By the values they hold and compute a static type system classifies variables and expressions. A system of nested class types much like Java’s, it allows us to parameterize types with generics, to hide details using abstract types, and by using intersections it combine types .
- It is implemented on Java Virtual Machine(JVM) so it can access all Java methods and fields, inherit from Java classes and implement Java interface. It does not require any special syntax, explicit interface descriptions, or glue code. It uses Java’s types and dresses them up to look nicer. The Scala compiler compiles the program into .class file, containing the Bytecode that can be executed by JVM. All the classes of Java SDK can be used by Scala. With the help of Scala user can customize the Java classes.
- Scala short <(x: Short): Boolean
- Scala short <(x: Char): Boolean
- Scala Extractors
- Scala | Partially Applied functions
- Scala String indexOf(String str) method with example
- Scala String contentEquals() method with example
- Scala Keywords
- Scala Int /(x: Int) method with example
- Scala Int /(x: Short) method with example
- Program to print Java Set of characters in Scala
- Scala Map size() method with example
- Scala SortedMap addString() method with a start, a separator and an end with example
- Scala Iterator addString() method with example
- Scala String substring(int beginIndex, int endIndex) method with example
- Scala | Functions Call-by-Name
- Program to convert Java list to an iterator in Scala
- Scala Set &() method with example
- Scala | Type Inference
- Program to convert Java set of Shorts to an Indexed Sequence in Scala
- Scala Int <(x: Char) method with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.