Skip to content

Comment on Scala Feels like EJB 2 parent

Comments

For instance you can implement a library providing Units of Measurements such that you can track the correct type through computations, e.g:

    val time: Time[Int] = 15 s
    val length: Length[Int] = 450 m
    val speed: Speed[Int] = time / length
The type annotations are of course completely optional.

The interesting thing is that while the implementation is quite complex, the actual user has a very simple interface to develop against.

So while you can write complex code in Scala, Scala allows you to keep the complexity in the library-side, while it would bleed into the use-site in Java (use-site generics, anyone?).

Java can't do that. In fact, they already failed twice with it.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.