3 ms·
I had to quickly patch a Java 8 web app weeks ago, years after I worked with Java. Java 8 is not bad but still trailing Ruby by a long shot in terms of readabi
by pmontra 10y ago
I had to quickly patch a Java 8 web app weeks ago, years after I worked with Java.
Java 8 is not bad but still trailing Ruby by a long shot in terms of readability. Thinking in Ruby I wanted to implement the Java equivalent of
input.select {|i| validations.include?(i) }.map {|i| "'#{i}'" }.join(",")
where validations is a List<String>.
I ended up with a small nightmare with streams and collectors. That boilerplate shouldn't belong to this world, probably it's there because of the Java way to static typing.
They use Spring, don't know which versions, but it's got @RequestParam annotations to extract parameters from the request body. I think this is Spring Boot. It looks like Sinatra because of the @RequestMapping. Having @RequestParam in the action arguments looks a little like Phoenix pattern matching but I didn't have time to dig into the web and understand if it can really route requests to different actions according to the RequestParam. Overall is more or less where Ruby frameworks where ten years ago unless it's got pattern matching.
The webapp I had to work on still use ctags, which are a major PIA which slows down work and raises costs.
Queries are written in SQL, which is perfectly OK, and executed on a connection returning a java.sql.ResultSet. Not shiny but everybody can understand that. I googled jOOQ and it looks like ActiveRecord/AREL for Java. Nice but it would have cost me more time for this kind of quick hack.
- TheCoelacanth 10y agoWhat's so bad about this? input.stream().filter(i -> validations.contains(i)).map(i -> "'" + i + "'").collect(Collectors.joining(",")) It doesn't compare with ruby for code golf, but for readability it's practically identical.
- matwood 10y agoI agree. Depending on how validations is defined you could also use a method reference .filter(validations::contains).map...