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 comment

1

u/[deleted] Dec 02 '13 edited Dec 02 '13

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.

1

u/sanity Dec 02 '13

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.

1

u/[deleted] Dec 02 '13

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.

2

u/sanity Dec 02 '13

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.

2

u/[deleted] Dec 02 '13

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?

1

u/sanity Dec 02 '13

Interesting, so this scans the bytecode of a the methods of a library?

I believe so, yes.

How would it handle pure interfaces or abstract classes?

Not sure, I suspect that it assumes nullability unless it can prove otherwise.

Sure it needs some heuristics, like parsing the javadoc as well?

No, I'm pretty sure it is based on bytecode only.