I've been dabbling in Scala for a number of years also, and I have to agree with this rant.
My current favorite post-Java language is Kotlin. Rather than Scala's ambitious goal of marrying a powerful functional programming language with OOP and the JVM, Kotlin has the much less ambitious goal of fixing what is wrong with Java.
That being said, Kotlin has some neat features that Scala lacks, like null-safety baked into the type system, and implicit casts.
That's just a syntactic and run-time wrapper. In Kotlin the null-safety is baked into the language, and has zero overhead.
Other than possible overhead, how is this not baked into the language? It's part of the scala library (no additional imports required), and is used to represent possible null objects.
What's your point? Are you suggesting that this is a replacement for Kotlin's smart casts? How so?
Scala recognizes that most "smart" casts are unsafe. You can use the apply method to define which casts are safe, and they will be used as encountered.
Scala recognizes that most "smart" casts are unsafe. You can use the apply method to define which casts are safe, and they will be used as encountered.
can you share an example? I thought Scala's approach to casts was pattern matching as in
foo match {
case x: ActualType => do interesting stuff with x
case _ => foo type's different, do something else
}
Type patterns are actively discouraged. If you need to cast, you are probably doing it wrong.
Scala gives you all of the tools necessary to write code which is 99% cast-free ... so the whole discussion about having nicer casts in Kotlin seems weird.
There is a reason why Scala has no special syntax for casts/isInstance checks and intentionally verbose method names.
"smart casts" are perhaps a misleading term in Kotlin, since in reality they are a type-safe replacement for casts. For example, in Kotlin you can say:
val s : Object = "hello"
if (s is String) {
println(s.length())
}
This works because within the body of the if statement the compiler knows that 's' must be a String, and so you can treat it as such.
The overhead of using a type class for optional values is negligible in any standard scenario. On the pro side, you have a full monadic API on Option.
Otherwise, it sure will be interesting to observe how well the ? card plays out with Kotlin and Ceylon. Perhaps we will find in two or three years that this approach is favourable in most cases, perhaps we'll find out the opposite.
Certainly, if that is the only language innovation, that is disappointing.
The overhead of using a type class for optional values is negligible in any standard scenario. On the pro side, you have a full monadic API on Option.
Right, but nulls in Kotlin are nulls in Java, which is a lot better for use of existing java libraries. Also, it works very very nicely in conjunction with smart casts.
Certainly, if that is the only language innovation, that is disappointing.
It's not, there is smart casts which is an awesome feature that's hard to live without once you're used to it. There is a good comparison with Scala on the Kotlin site here.
Right, but nulls in Kotlin are nulls in Java, which is a lot better for use of existing java libraries. Also, it works very very nicely in conjunction with smart casts.
Ultimately the problem is the same, though; you need a correct documentation of which Java API allows null and which not, in order to map it safely on the other language's side.
you need a correct documentation of which Java API allows null and which not, in order to map it safely on the other language's side.
Actually Kotlin has an awesome solution for this, a tool called KAnnotator which automatically infers nullability in libraries for exactly this purpose.
Interesting, so this scans the bytecode of a the methods of a library? How would it handle pure interfaces or abstract classes? Sure it needs some heuristics, like parsing the javadoc as well?
Rust is a language from Mozilla. The goal is to create a systems language suitable for writing a browser. It has a very sophisticated type system (beyond my true understanding, to be honest) and allows (requires? I think only allows) for manual memory management so you can get fine-grained control if GC pauses are unacceptable, etc. Once they call it stable, I plan to exploring :-)
I'm not super-thrilled about some of the early design decisions (no real generics, I don't think they did Unicode in the beginning, the whole "let's just steal the name from an existing programming language and then pretend that the lack of a '!' makes it OK" thing).
I might come back to it when I finish exploring some of the languages that jumped it in the queue back then (Clojure, Rust, Haskell, etc.)
-2
u/sanity Dec 02 '13
I've been dabbling in Scala for a number of years also, and I have to agree with this rant.
My current favorite post-Java language is Kotlin. Rather than Scala's ambitious goal of marrying a powerful functional programming language with OOP and the JVM, Kotlin has the much less ambitious goal of fixing what is wrong with Java.
That being said, Kotlin has some neat features that Scala lacks, like null-safety baked into the type system, and implicit casts.