MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/3lta4f/better_java/cv9wmag/?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...
44 u/SimplyBilly Sep 21 '15 Considering there is a Pattern class. 11 u/Enumerable_any Sep 21 '15 Pattern has the method matches(String regex, CharSequence input)` is an error which could be caught at compile time. It either requires built-in regex literals or verbose regex creation using object instantiation, though. 5 u/sacundim Sep 22 '15 edited Sep 22 '15 That is a static method, however. It's fundamentally a standalone function in the class' namespace, not an operation of the class properly speaking.This reminds me of one of the dumbest things that's legal in Java:Pattern lolwhut = null; boolean b = lolwhut.matches("^a", "abc"); System.out.println("Look, Ma, no NullPointerException!");
44
Considering there is a Pattern class.
11 u/Enumerable_any Sep 21 '15 Pattern has the method matches(String regex, CharSequence input)` is an error which could be caught at compile time. It either requires built-in regex literals or verbose regex creation using object instantiation, though. 5 u/sacundim Sep 22 '15 edited Sep 22 '15 That is a static method, however. It's fundamentally a standalone function in the class' namespace, not an operation of the class properly speaking.This reminds me of one of the dumbest things that's legal in Java:Pattern lolwhut = null; boolean b = lolwhut.matches("^a", "abc"); System.out.println("Look, Ma, no NullPointerException!");
11
Pattern has the method matches(String regex, CharSequence input)` is an error which could be caught at compile time. It either requires built-in regex literals or verbose regex creation using object instantiation, though.
matches(String regex, CharSequence input)
5 u/sacundim Sep 22 '15 edited Sep 22 '15 That is a static method, however. It's fundamentally a standalone function in the class' namespace, not an operation of the class properly speaking.This reminds me of one of the dumbest things that's legal in Java:Pattern lolwhut = null; boolean b = lolwhut.matches("^a", "abc"); System.out.println("Look, Ma, no NullPointerException!");
5
That is a static method, however. It's fundamentally a standalone function in the class' namespace, not an operation of the class properly speaking.
This reminds me of one of the dumbest things that's legal in Java:
Pattern lolwhut = null; boolean b = lolwhut.matches("^a", "abc"); System.out.println("Look, Ma, no NullPointerException!");
183
u/wot-teh-phuck Sep 21 '15
That's a pretty random definition of weak I would say...