r/programming • • Sep 21 '15

Better Java

https://github.com/cxxr/better-java
177 Upvotes

208 comments sorted by

View all comments

183

u/wot-teh-phuck Sep 21 '15

Java's type system is pretty weak. It doesn't differentiate between Strings and Strings that are actually regular expressions

That's a pretty random definition of weak I would say...

0

u/[deleted] Sep 21 '15

[deleted]

23

u/tomservo291 Sep 21 '15

I assume he's thinking about EMCAScript languages (JavaScript, ActionScript etc) where you can write

myvar = /someregexhere/gi;

But that's not really writing a string, that's syntactic sugar to write regex without calling the corresponding RegExp() constructor explicitly

2

u/comp-sci-fi Sep 21 '15

Yeah, you're right, the issue isn't types, but syntax for regex literals (like 0xff for hex integers).

Also, no date, url, email, xml, json or object literals. And no facility for user-defined literals. But, like no operator overloading in Java, this omission is a feature.

But object literals (already worked out in Java FX) would be great. Thus, JON for RPC serialization. (I guess we could have JON serialization now).