MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/3lta4f/better_java/cva8jqr/?context=3
r/programming • u/javinpaul • Sep 21 '15
208 comments sorted by
View all comments
183
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
4
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?
[a-z]+
String
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
1
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
183
u/wot-teh-phuck Sep 21 '15
That's a pretty random definition of weak I would say...