4 ms·
To me, the sin of Java has been to make String final. Or, to be more precise, not to have made it generifiable. (So the compiler knew the difference between, le
by lolive 7y ago
To me, the sin of Java has been to make String final.
Or, to be more precise, not to have made it generifiable.
(So the compiler knew the difference between, let's say, String<FirstName> and String<LastName>)
- deleted 7y ago[deleted]
- lmm 7y agoNewtype-style wrappers can solve that one at compile time, and do in other JVM languages.
- kjeetgill 7y agoI'm not sure I understand your example, do you want a string of FirstNames? Did you mean something like: class FirstName extends String {...}
- lolive 7y agoSomething like semantic-aware String, yes. (with syntactic sugar to avoid me repetitive tasks, plus the ability to uplift an existing code using String to its typesafe version in the most straightforwatrd manner). Something like the generics system but for String. I of course can uplift my String into Objects. But it is unneeded for 90% of the String usages. Plus it forces you to unbox the String from its Object to pass it to a function that consumes just a String.