Live data from Hacker News

Modern Java – A Guide to Java 8

github.com

11–20 of 203 posts

Re: Modern Java – A Guide to Java 8

#11

I personally jumped right into Clojure on the jvm without much Java experience. I've found it to be awesome. Is there a non-political reason that someone should choose Java over Clojure (or possibly Scala)? Where does Java shine?

> Is there a non-political reason that someone should choose Java over Clojure (or possibly Scala)? Where does Java shine?

If you are stuck with a group of developers who have no interest in learning anything new and wish to use Java until they retire then Java is the only choice. Other than no new learning required I can't think of many reasons to pick Java as a first choice. Java tends to be popular because it's the oldest, most familiar default for the JVM rather than any particular strength.

Re: Modern Java – A Guide to Java 8

#12

I personally jumped right into Clojure on the jvm without much Java experience. I've found it to be awesome. Is there a non-political reason that someone should choose Java over Clojure (or possibly Scala)? Where does Java shine?

Java shines by the number of java professionals available on the market.

Re: Modern Java – A Guide to Java 8

#13

I personally jumped right into Clojure on the jvm without much Java experience. I've found it to be awesome. Is there a non-political reason that someone should choose Java over Clojure (or possibly Scala)? Where does Java shine?

Many people have a gut-level aversion to dynamically typed languages.

Re: Modern Java – A Guide to Java 8

#14

I personally jumped right into Clojure on the jvm without much Java experience. I've found it to be awesome. Is there a non-political reason that someone should choose Java over Clojure (or possibly Scala)? Where does Java shine?

I love clojure, but on a large code base I find good refactoring tools to be extremely helpful when trying to evolve how things are implemented. In that respect Java wins hands down just because of the tooling around it. It also may be easier sometimes to use Java for working with particular libraries.

There are however areas where I'd use clojure every time. Luckily the JVM is really good for doing mixed language work on, so you don't have to work entirely in one language.

Re: Modern Java – A Guide to Java 8

#15
This is a really nice overview of the new Java 8 features. I like how this tutorial communicates mostly with code snippets and has "read more" links for most topics.

If you are using Java and have not tried Lambda Expressions, method references and default methods, do so now! After that, you'll think "How was I able to live without that?".

I also think that the way Java integrates lambda expressions (via functional interfaces) is really nice. Sure, you have to write some boilerplate code in some scenarios. But since they re-used interfaces and did not event some "function" type (or similar), it fits really nicely into the existing language.

If you don't know Java, this tutorial will probably not be enough - But that probably wasn't the intentian anyway. It's a great intro to what has changed with Java 8 (and all those changes are real improvements for the Java language, IMHO).

Re: Modern Java – A Guide to Java 8

#16

I personally jumped right into Clojure on the jvm without much Java experience. I've found it to be awesome. Is there a non-political reason that someone should choose Java over Clojure (or possibly Scala)? Where does Java shine?

Most parts of software development probably is not about starting new projects from scratch but about maintaining existing code bases. That's where Java really shines due to its (often hated) backwards compatibility.

Re: Modern Java – A Guide to Java 8

#17
> maps don't support streams

This is very misleading. There is not a #stream method on Map because Map supports three different streams:

    map.keySet().stream()
    map.values().stream()
    map.entrySet().stream()

Re: Modern Java – A Guide to Java 8

#18

I personally jumped right into Clojure on the jvm without much Java experience. I've found it to be awesome. Is there a non-political reason that someone should choose Java over Clojure (or possibly Scala)? Where does Java shine?

All IME, and as a Scala fan:

Clojure has a weakly integrated type system (an inherent disadvantage of optional type systems). At the simplest level this makes silly errors much easier and means you have to write more tests to maintain the same defect rate.

The lack of types mean you require extensive use of macros for advanced functionality. IME macros have major maintainability issues in a multi-person codebase.

Both these things are major disadvantages for automatic comprehensibility of code. Autocompletion can be more-or-less usable but will never be as good as in Java or Scala. Automated refactoring is inherently unsafe in the presence of macros (Scala's fancier typed constructs (typeclasses, for/yield with custom types) mean you need macros much less often; Java tends to force you to expand these things out by hand (or else use annotations which act as de facto macros), which has its own maintainability issues but does at least mean automated refactoring will work correctly).

Some of the language culture pushes people towards less principled abstractions. From this side of the fence that looks like anti-intellectualism; no doubt from their side it's pretension on typed programmers' part. But either way I think they're setting themselves up for long-term maintainability issues (e.g. the semantics of clojure transducers in the presence of errors are infuriatingly not-quite-right, which will either remain a painful gotcha forever, or necessitate a painful migration in the future).

As a minority language Clojure may not be as well supported in the surrounding ecosystem - partly things like IDEs but also code coverage tools, profilers, monitoring.... Remember the JVM ecosystem is wider than just the languages themselves.

There are good things about Clojure, but it's by no means clear-cut.

Re: Modern Java – A Guide to Java 8

#20
post #17

> maps don't support streams This is very misleading. There is not a #stream method on Map because Map supports three different streams: map.keySet().stream() map.values().stream() map.entrySet().stream()

But those are streams on sets.

Those are streams on views on the map. My complaint is that a reader seeing "maps don't support streams" with no further explanation is unlikely to get the correct idea, and may infer that something like

  map.entrySet().stream().filter(e -> e.getKey().equals(e.getValue())).findAny()
is not expressible.
Post reply on HN