4 ms·
So many cool things already done and even more to come. Some parts that excite me as a Scala nerd: * One can now use implicit function types to basically build
by coryfklein 9y ago
So many cool things already done and even more to come. Some parts that excite me as a Scala nerd:
* One can now use implicit function types to basically build your own table language syntax that is type-safe. [1]
* Multiversal Equality: you get to decide whether it makes any sense to compare an Apple and an Orange using "==" or "!=", as opposed to Java's forced requirement of allowing you to compare anything with anything. [2]
* Null safety checks! Quoting from [3], "Adding a null value to every type has been called a "Billion Dollar Mistake" by its inventor, Tony Hoare. With the introduction of union types, we can now do better. A type like String will not carry the null value. To express that a value can be null, one will use the union type String | Null instead."
* First-class enums, finally. [4]
* Erased parameters: you can declare variables specifically for type-safety that _don't exist_ during run-time, improving efficiency. [5]
[1] http://dotty.epfl.ch/docs/reference/implicit-function-types.html http://dotty.epfl.ch/docs/reference/implicit-function-types....
[2] http://dotty.epfl.ch/docs/reference/multiversal-equality.html http://dotty.epfl.ch/docs/reference/multiversal-equality.htm...
[3] http://dotty.epfl.ch/docs/reference/overview.html http://dotty.epfl.ch/docs/reference/overview.html
[4] http://dotty.epfl.ch/docs/reference/enums/enums.html http://dotty.epfl.ch/docs/reference/enums/enums.html
[5] http://dotty.epfl.ch/docs/reference/erased-terms.html http://dotty.epfl.ch/docs/reference/erased-terms.html
- lmm 9y ago> * Multiversal Equality: you get to decide whether it makes any sense to compare an Apple and an Orange using "==" or "!=", as opposed to Java's forced requirement of allowing you to compare anything with anything. [2] Unfortunately it's being introduced in a fail-unsafe way that as far as I can see makes it virtually useless. If I see "x == y" in code, I have no way to be confident that this isn't an old-fashioned universal comparison without going into the details of x and y, so I'm no better off than I was without this feature.
- coryfklein 9y agoYea, I'd love a compiler switch that enables the strict mode globally, while adding the leniency on a case-by-case basis instead.
- bad_user 9y agoYou can always switch to usage of Eq and its === operator from Cats or Scalaz.
- eeperson 9y agoIt looks like you can force strict equality everywhere with the flag '-language:strictEquality'. See the dotty documentation for more details: http://dotty.epfl.ch/docs/reference/multiversal-equality.html http://dotty.epfl.ch/docs/reference/multiversal-equality.htm... EDIT just realized you are m50d on reddit and probably saw the exact same comment I got that from.
- philipwhiuk 9y agoImplicits are a massive pain in the ass.