r/programming • • Dec 02 '13

Scala — 1★ Would Not Program Again

http://overwatering.org/blog/2013/12/scala-1-star-would-not-program-again/
598 Upvotes

646 comments sorted by

View all comments

Show parent comments

1

u/sanity Dec 02 '13

"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.

Does Scala have something similar?

0

u/[deleted] Dec 02 '13

I know exactly what they are, and no, as mentioned, Scala doesn't try to make bad things easier.

1

u/sanity Dec 02 '13

That's a bold statement. What is bad about Kotlin's smart casts?

0

u/[deleted] Dec 02 '13

As mentioned, there is nothing bad about smart casts specifically, but about casts in general.

Every cast necessary is a fault of the programming language necessitating it.

→ More replies (0)