The Power of Scala vs. Java | Toptal
There is admittedly some truth to the statement that "Scala is hard", but the learning curve is well worth the investment. Some of the more complex features of the language ( Tuples , Functions , Macros , to name a few) ultimately make it easier for the developer to write better code and increase performance. Frankly, we are programmers, and if we're not smart enough to learn a language that has some complexity, then we're in the wrong business.
Scala is a type-safe JVM language that incorporates both object oriented and functional programming into an extremely concise, logical, and extraordinarily powerful language. Some may be surprised to know that Scala is not quite as new as they thought, having first been introduced in 2003. However, it is particularly within the past few years that Scala has begun to develop a significant following. Which begs the question of "why Scala?". This article examines the advantages of Scala,
The truth is that Java is often just way too verbose. In Scala, the compiler is incredibly smart, so this avoids the developer needing to specify explicitly those things that the compiler can infer
since Scala prefers immutability, I can write this in Scala even more concisely with case classes:
Scala is statically-typed.
Read full article from The Power of Scala vs. Java | Toptal
There is admittedly some truth to the statement that "Scala is hard", but the learning curve is well worth the investment. Some of the more complex features of the language ( Tuples , Functions , Macros , to name a few) ultimately make it easier for the developer to write better code and increase performance. Frankly, we are programmers, and if we're not smart enough to learn a language that has some complexity, then we're in the wrong business.
Scala is a type-safe JVM language that incorporates both object oriented and functional programming into an extremely concise, logical, and extraordinarily powerful language. Some may be surprised to know that Scala is not quite as new as they thought, having first been introduced in 2003. However, it is particularly within the past few years that Scala has begun to develop a significant following. Which begs the question of "why Scala?". This article examines the advantages of Scala,
The truth is that Java is often just way too verbose. In Scala, the compiler is incredibly smart, so this avoids the developer needing to specify explicitly those things that the compiler can infer
val list = List("1", "2", "3")
val ints = list.map(s => s.toInt)
class Product {
var id: Int = _
var category: String = _
}
class User {
private var _name: String = _
var orders: List[Order] = Nil
def name = _name
def name_=(name: String) = {
if (name == null) {
throw new NullPointerException("User.name cannot be null!")
}
_name = name
}
this entirely removes the need to pre-configure method accessors.since Scala prefers immutability, I can write this in Scala even more concisely with case classes:
case class User(name: String, orders: List[Order])
def products = orders.flatMap(o => o.products)
def productsByCategory(category: String) = orders.flatMap(o => o.products).filter(p => p.category == category)
Scala is statically-typed.
Read full article from The Power of Scala vs. Java | Toptal
No comments:
Post a Comment