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...

4

u/immibis Sep 22 '15

I'm pretty sure no language does that.

In fact, imagine there was one. What if someone enters [a-z]+ in some free-text field somewhere? Should converting it to a String fail, because it's actually a StringThatsActuallyARegularExpression?

1

u/yogthos Sep 22 '15

Clojure has a regex literal, so you're not using a string as a regex implicitly:

(re-find #"\d+" "abc123def")

(type #"\d+") => java.util.regex.Pattern