3 ms·
> Might have been true back in the JDK 6 or JDK 7 age but from JDK 8 to JDK 19 it has become a better functional programming language than most functional progr
by leetcrew 4y ago
> Might have been true back in the JDK 6 or JDK 7 age but from JDK 8 to JDK 19 it has become a better functional programming language than most functional programming languages.
uhh, let me know when they add the ability to define a standalone function that exists outside of a class.
> If the author likes he can keep coding in C++ where strcpy is Turing complete.
c++ certainly has its warts. but having worked with both professionally, I find java to be by far the more frustrating of the two.
some random gripes off the top of my head:
I can't invoke a no-args constructor like this: `MyType var;`
I can't do something like `public MyType() = delete` to make my class nonconstructable (which would at least partially help with the "no standalone functions" issue).
there is no notion of tuple in the standard library. I have to define a new class (or abuse Map.Entry) every time I want to return more than one value from a method.
I can't construct a collection (or POD) type like this: `MyCollection c = { a, b, c };`. Yes, I can do stuff like `List<T> list = Arrays.asList(a, b, c)`, but then I have an immutable array enclosed by a mutable list, where any attempt to modify it is a runtime error?!
in my experience, java somehow manages to be more verbose and less ergonomic than c++, which is really saying something.
disclaimer: I have not worked much with JDK versions >11, so maybe they've addressed some of above.
- PaulHoule 4y agoFrankly I don’t have problem with classes that have nothing but static methods, you can write a private constructor if you are so concerned somebody is going to construct an instance of the class. (Somehow that’s a problem that really concerns C++ programmers. They keep saying RAII over and over again as if it was a magic talisman that made their code reliable) People who write functional libraries in Java frequently write Pair<A,B> and sometimes Triple<A,B,C> but they independently discover there is no point in declaring a Tuple27. Recovering LISP programmers point out the ‘nameless tuple’ problem is one of the many reasons the idea of LISP is better than the reality. In modern Java you can write a record if you need to bundle together a few results.