News for hackers. Stuff that matters.
Re:Java’s Cultural Problem by thriftwy on Monday September 19, 2022 @06:22AM (#32896441)
> Any FP developer should scream when seeing this

It would be an interesting observation in 2007, but fifteen years later with no industrial success of Haskell-inspired pure FP approach, I don't see why we should listen to "any FP developer" criticisms.

It's not that I have anything against FP - let's just admit that side-effect pure FP is a "futuretro" of today. A future that never was.

Re:Java’s Cultural Problem by marginalia_nu on Monday September 19, 2022 @06:33AM (#32896528)
I do think FP in Java is a bit of a mistake. Record types has done a lot more for the language than streams and lambdas.

I initially liked the idea of adding functional paradigms to the language, when the dust has settled all it does is create a sort of nasty Cronenberg language with most the drawbacks of both paradigms and few of the benefits of either.

Re:Java’s Cultural Problem by thriftwy on Monday September 19, 2022 @06:39AM (#32896557)
I absolutely disagree. Lambdas has in many ways revolutionized Java and put it back on its feet. Java 8 has seen faster adoption than any other major Java version because of this. Compare it with Java 11 or indeed with absolute non-adoption of Java 14.

Streams are not very well designed IMHO. That's why their usage remains limited. Much more useful and robust libraries are possible on top of Java lambdas support.

Since everyone is now on Java 11 (and many on Java 8 still), we will only really see the records used widely in five years or so.

The modules stuff was a huge mistake in my opinion. Some people tend to like them in theory, but in practice they absolutely destroyed the adoption of newer Java versions and set Java 11 back by 10 years (literally).

Re:Java’s Cultural Problem by kaba0 on Monday September 19, 2022 @07:59AM (#32897142)
Modules system was a necessary evil: it’s Hyrum’s law with the back then slowed down development of the JVM — every observable behavior of the system was hardcoded against, so the JVM devs had to build a wall against the changing internals to have any chance of continuing the evolution of the platform. Libraries that use never-agreed upon functionality are the ones in the bad here.
Re:Java’s Cultural Problem by thriftwy on Monday September 19, 2022 @10:45AM (#32899043)
> the ones in the bad here

Never blame people who try to solve real problems with your stuff. Better get your ego out of their way.

Re:Java’s Cultural Problem by bluejekyll on Monday September 19, 2022 @06:51AM (#32896638)
My issue with lambdas in Java is the complexity of types in defining interfaces that receive generic Functions as an argument. Really seems like a better definition could be used there, new language syntax possibly.

On the topic of Streams, the big issue that always crops up is exceptions. Streams and Exceptions are nearly incompatible with tacked on constructs that are painful to use. Any IO oriented program will have to face the issue of what happens to the Stream if an Exception is thrown.

Re:Java’s Cultural Problem by joshlemer on Monday September 19, 2022 @12:43PM (#32900698)
Agreed. If the type of the lambda can be inferred, then they are great to work with. But if you want to define one upfront and use it later, having to spell out the type of it is almost prohibitively annoying (what do I need in this situation, is it a Function or a Consumer or Supplier or Bifunction or BiConsumer or BinaryOperator or Predicate or BiPredicate or IntUnaryOperator or ObjDoubleConsumer or LongToDoubleFunction or .........). Most of the time I'll just avoid it if I can. I think I"m the only one on my team who would ever create a local function rather than a private method, for instance.

An other thing is java's lack of tuples. All the time I'm reaching for some kind of ad-hoc grouping/touple but have to resort to using something from Apache or Spring or (perhaps abusing) Map.Entry<K,V>

Re:Java’s Cultural Problem by marginalia_nu on Monday September 19, 2022 @12:59PM (#32900922)
> An other thing is java's lack of tuples. All the time I'm reaching for some kind of ad-hoc grouping/touple but have to resort to using something from Apache or Spring or (perhaps abusing) Map.Entry<K,V>

Record types does make that a lot easier. They aren't quite as ad-hoc as in other languages, but this:

  record Foo(int a, String b) {}
is a lot less to type than

  static final class Foo {
    private final int a;
    private final String b;
    public final Foo(int a, String b) {
      this.a = a;
      this.b = b;
    }
    public int a() {
      return a;
    }
    public String b() {
      return b;
    }
    public int hashCode() {
      return Objects.hashCode(a, b);
    }
    public boolean equals(Object o) {
      if (o == null) return false;
      if (o == this) return true;
      if (o instanceof Foo f) {
        return a == f.a && Objects.equals(b, f.b);
      }
      return false;
    }
    public String toString() {
      return getClass().getSimpleName() + "[ a = " + a + ", " + "b = " + b + "]";
    }
  }
Re:Java’s Cultural Problem by samus on Monday September 19, 2022 @09:14AM (#32897847)
The modules system is not a blocker for migration at all. At this point, it is completely optional to enable it.

What indeed caused breakage was the encapsulation effort that blocks unrestricted access to JVM internals, and that one was not even fully and forcibly turned on until Java 17.

Re:Java’s Cultural Problem by thriftwy on Monday September 19, 2022 @10:47AM (#32899069)
Well it requires users of your code to put a half dozen extra JVM args just to get your code (such as Java-based database like Apache Ignite) to run.

You can see how such features are not super popular to the extent of widespread non-adoption of Java 11 even 10 years after its release.

Re:Java’s Cultural Problem by samus on Wednesday September 21, 2022 @02:23AM (#32921423)
Oracle offers extended support for JDK 8 until the end 2030, which is more than four years longer than for JDK 11. I'd say this is the more likely reason that Java 11 is not adopted more. Spending a few hours to fire up an application to figure out the right --add-opens call really does not seem like such a big imposition to me.
Re:Java’s Cultural Problem by eckza on Monday September 19, 2022 @06:49AM (#32896626)
> no industrial success

Because FP is hard, and because it's easier to get 1000 Python monkeys to shit out half-baked garbage than it is to get 10 Haskell developers to agree on a set of blessed language extensions.

But when you get it right, your shit stops chewing a hole in itself in prod, and you can sleep at night and leave Slack alerts off over the weekend.

It's fine. Y'all can have your half-baked tire fires. "Industrial success" is a broken metric for "whether or not something is going to create real value for your product". We'll just keep shipping. And sleeping.

Re:Java’s Cultural Problem by democracy on Monday September 19, 2022 @07:19AM (#32896847)
The idea of our craft is to deliver value, not to find a new weird way to do the same thing. If dentists were programmers, the most expensive ones would be removing teeth via the rectum.
Re:Java’s Cultural Problem by lelanthran on Monday September 19, 2022 @08:08AM (#32897216)
> The idea of our craft is to deliver value, not to find a new weird way to do the same thing. If dentists were programmers, the most expensive ones would be removing teeth via the rectum.

What a nice quote this will make :-)

PM me the name of who I should attribute this too.

Re:Java’s Cultural Problem by kaba0 on Monday September 19, 2022 @07:53AM (#32897104)
What happens when your service scales and you get a performance bottleneck? Can you.. connect to a prod instance and look at the number of allocated instances? Can you do VM-event streams with barely any overhead continuously in prod? Will you actually be able to circumvent the performance bug?

Don’t get me wrong, I like Haskell and it is a more than fine language. Nonetheless, it doesn’t have anywhere close to the tooling Java has, and lazyness/FP is quite unintuitive regarding performance. And pure FP in itself is not guaranteed to result in better results by any form of evidence we have today, and doesn’t defend against logic bugs in any shape or form over what Java can do.

Also, it’s very unprofessional to look down on software engineers using different languages then you do..

Re:Java’s Cultural Problem by boruto on Monday September 19, 2022 @08:06AM (#32897197)
> Also, it’s very unprofessional to look down on software engineers using different languages then you do..

it's a major red flag for me when giving or taking interviews.

Re:Java’s Cultural Problem by UncleMeat on Monday September 19, 2022 @08:55AM (#32897686)
Agreed. Most of the hard problems in software engineering are completely separate from language and stack choice. Hyper-focus on these things smells of expert-beginner.
Re:Java’s Cultural Problem by lelanthran on Monday September 19, 2022 @08:07AM (#32897206)
> But when you get it right, your shit stops chewing a hole in itself in prod, and you can sleep at night and leave Slack alerts off over the weekend.

Okay, when FP people get it right, they can let the rest of us know and we'll jump on the bandwagon.

Until they get it right[1], let the enterprise devs do what they need to without pouring scorn on them.

[1] For whatever meaning of "right" you have.

Re:Java’s Cultural Problem by DFHippie on Monday September 19, 2022 @07:30AM (#32896925)
I just want to stop for a moment and admire some of your metaphor pileups:

> monkeys to shit out half-baked garbage

> your shit stops chewing a hole in itself

> half-baked tire fires

Awesome. Terrifying, but awesome.

Re:Java’s Cultural Problem by d-trieu on Monday September 19, 2022 @07:29AM (#32896919)
> We'll just keep shipping. And sleeping.

When do you actually ship though?

Re:Java’s Cultural Problem by vips7L on Monday September 19, 2022 @06:45PM (#32905182)
I’ve seen plenty of half-baked garbage from scala FP purists. Bad code is bad code.
Re:Java’s Cultural Problem by TuringTest on Monday September 19, 2022 @07:07AM (#32896762)
> It would be an interesting observation in 2007, but fifteen years later with no industrial success of Haskell-inspired pure FP approach

You kidding? The industrial success of the pure FP approach inspired by Haskell is that it has dragged all the other significant languages and frameworks to work in a more functional way, adding the constructs they lacked and popularizing the basic techniques.

Re:Java’s Cultural Problem by KptMarchewa on Monday September 19, 2022 @07:23AM (#32896874)
Not "industrial success" because there were none, but rather a validity of some of the ideas. Which were successful only when adopted by some other languages, like Scala (which has a lot of issues on it's own), Kotlin or Rust.
Re:Java’s Cultural Problem by TuringTest on Monday September 19, 2022 @12:19PM (#32900381)
Influencing a whole language of other industry languages to be closer to your model, that's what I would call industrial success for a radical experimental language dedicated to inventing and exploiting a new programming paradigm. Different criteria, I suppose.