The Scala Programming Language | Tutorial
In this tutorial, we explain The Scala Programming Language.
Scala - It is a light and simple type of programming language. It is supported the oops concept and function-based programming language. The source code of scala is complied by java bytecode and the scala program runs JVM (java virtual machine). The first version was released in 2003. scala is a static type of programming language.
Scala programming is based on Java. Therefore, if you understand Java syntax, learning Scala is very easy. Even if you are not familiar with Java but know another programming language, such as C, C++, or Python, it will help you understand Scala concepts very quickly.
What is used of Scala?
Scala is a very important and very useful language for example if you are started from gadget studying to net apps. As a high-degree standard motive language, Scala boasts an in-depth variety of viable applications. Scala permits builders to make exact use of general JVM capabilities and Java libraries.
Scala is a static programming language, and Java is a cross-platform, Web-oriented programming language. Because of nested code, scaling is less readable, while Java is more readable. The Scale framework is Play, Lift, and the Java framework is Spring, Grails, and so on.
Java is harder than scala or not?
It is kind system is a lot of communicatory than Java, which suggests that more logical errors may be expressed than compilation errors; you wish time to master them, therefore Scala is healthier than Java is good. It's exhausting to learn.
Why Scala is complex?
Scala is an imperative programming language and it is also object-oriented. It is garbage collected from a wide array of languages. scala is belonged to c,c++ oops .Scala on the opposite hand - despite running on the JVM, providing straightforward ability with Java Apis - is what's normally named a multi-paradigm language. The language provides deep syntactical integration of purposeful programing language features, however structures code in associate object destined fashion.
What is the difference between Java and Scala?
| Java | Scala |
|---|---|
| Java is a multi-platform, network-centric, programming language | Scala is a statically typed programming language |
| Java offers backward compatibility | Scala doesn't offer backward compatibility |
| Java is more readable | Scala is less readable because of nested code |
| Java syntax | Scala syntax |
|---|---|
| int mathFunction(int num) { int numSquare = num*num; return (int) (Math.cbrt(numSquare) + Math.log(numSquare)); } | def mathFunction(num: Int): Int = {
var numSquare: Int = num*num
return (math.cbrt(numSquare) + math.log(numSquare)).
asInstanceOf[Int]
} |
- PYTHON
- Ruby on Rails
- PERL
- Akka
- Spark
- Play
- Scalding
- neo4j
| Java class | Scala class |
|---|---|
| public class Point { private final double x, y; public Point(final double x, final double y) { this.x = x; this.y = y; } public Point( final double x, final double y, final boolean addToGrid ) { this(x, y); if (addToGrid) grid.add(this); } public Point() { this(0.0, 0.0); } public double getX() { return x; } public double getY() { return y; } double distanceToPoint(final Point other) { return distanceBetweenPoints(x, y, other.x, other.y); } private static Grid grid = new Grid(); static double distanceBetweenPoints( final double x1, final double y1, final double x2, final double y2 ) { return Math.hypot(x1 - x2, y1 - y2); } } | class Point( val x: Double, val y: Double, addToGrid: Boolean = false ) { import Point._ if (addToGrid) grid.add(this) def this() = this(0.0, 0.0) def distanceToPoint(other: Point) = distanceBetweenPoints(x, y, other.x, other.y) } object Point { private val grid = new Grid() def distanceBetweenPoints(x1: Double, y1: Double, x2: Double, y2: Double) = { math.hypot(x1 - x2, y1 - y2) } } |




Comments