5 ms·
I am a big functional programming geek. I am one of the few people on the planet who can honestly say I have been paid to write F#, Haskell, Clojure, and Erlan
by tombert 1y ago
I am a big functional programming geek. I am one of the few people on the planet who can honestly say I have been paid to write F#, Haskell, Clojure, and Erlang. I have spoken at FP conferences like six or seven times, and I have shit on Java for most of my career.
And yet, my latest talk at Lambda Days basically boiled down to “Java 21 and later don’t actually suck anymore”, and I genuinely do mean that.
Java 21 is actually fun to write, even for a grumpy FP advocate like me. Virtual threads make concurrency a lot simpler, and now that there’s proper records and ADTs (in the form of sealed interfaces), along with pattern matching, the language is actually pleasant to use. I haven’t dived into 25 yet, but I suspect I will like it as much or more than 21.
The biggest issue, though, is that Java programmers won’t use the new features. It was like pulling teeth at my last job to get people to use stuff from Java 8 (e.g. the `var` keyword), and none of my coworkers even knew how to use NIO or BlockingQueues which I think predate agriculture. I mean, hell, I had explain what “fairness” was to engineers when using a ReentrantLock because someone “corrected” my code with `synchronized`.
I don’t think Java makes people into bad programmers, but I do think it selection-biases for intellectually unambitious engineers. They learn exactly enough Java in college to pass their courses, and then get a job at a BigCo that doesn’t strictly require ever learning anything more than what they were taught in their “intro to data structures” course.
I have met some extremely intelligent Java engineers who do have intellectual curiosity, so I am not saying it affects everyone, but I do think that they are the minority. Java 25 might add every feature to make my wildest dream come true but it won’t matter if I am not allowed to use it.
- Xenoamorphous 1y agoWhat do you think of “modern” Javascript to write FP?
- tombert 1y agoI haven’t touched much modern JS. I have done some TypeScript in the last few years but of course that’s a transpiled thing. I think TS isn’t too bad to write functional stuff though I have no idea if people actually enjoy reading my code.
- nunobrito 1y agoProgramming language is a tool. Java developers value stability and ease of understanding for the code. I've seen the nice features you complain that don't get used, reality is that nobody wants to waste time knowing them unless they are intuitive to use. Especially when are forcing to use newer JDKs. There is no value in solving a challenge in a way that only you understand or make others lose time trying to understand the logic. Java 8 was the peak of development age for the JDK. Everything that came after isn't really memorable nor helpful, especially lambdas. You mention "var", why would we ever want in Java to hold a variable that you can't read immediately what is the type? That is a source of bugs and time waste to track down what object is being used. I don't mind you are happy with all these changes, just remember that we absolutely don't care about them nor will make much of an effort because in the end of the day we don't want to follow the same route of other programming languages unable to handle gigantic and complex platform systems. This isn't a competition to showoff who can apply new tricks, we absolutely don't care about functional programming. Java code must be simple and easy for anyone to read, that's it.
- frje1400 1y ago> You mention "var", why would we ever want in Java to hold a variable that you can't read immediately what is the type? var items = new HashMap(); Instead of HashMap items = new HashMap(); That's the point of var. It reduces noise a lot in some situations.
- jsnsndn 1y agoWhile I do use `var` when appropriate, your example is in general not appropriate You would like to use Map<Key, Value> items = new HashMap<>() since in general you do not want implementation detail leaking into contracts
- vips7L 1y agoUsing var there doesn’t leak any implementation details into any contracts. Var is for local variables inside of functions. There are no details or contracts there.
- whobre 1y agoI don’t use Java often, but many developers at my workplace do; they universally hate the new FP features.
- vips7L 1y agoEveryone seems to love them at my workplace and in /r/java.
- jghn 1y agoAnd then there are those of us who have used Java for a long time who feel the FP features make Java tolerable.
- tombert 1y agoThis is precisely my point. For a lot of Java programmers anything that they didn’t learn in university is “bad”, as far as I can tell, purely because they don’t want to actually learn new things. They’ll give half-hearted justifications that are usually reductive or just flat out lies [1], but ultimately it seems to boil down to new=bad. The amount of terrible code I have had to debug because Java programmers haven’t figured out you can use queues is upsetting, because all they learned in university is how to use `synchronized` wrong. [1] I have learned that nearly every time someone says their disgusting code is “faster”, even when they claimed they tested it, it is almost universally untrue when I write a microbenchmark to check it.
- Larrikin 1y ago
- plasma_beam 1y agoI view this largely as a symptom of the widescale “success” of the bloated J2EE app servers in the early 2000s to mid 2010s. Your Java version and dependencies were locked in and upgrading was a massive effort. A large group of developers stagnated on Java 1.4.2 and 5 and seemingly never updated their use of the language, even when moving to Java 8 and beyond. The legacy stuff keeps ticking along.
- tombert 1y agoI kind of think thats backwards. I think the success of the abomination that we have decided to label as J2EE or Jakarta was attractive to intellectually unambitious Java engineers because it progressed so slowly. I think people here are really underestimating how intellectually lazy most people are at their jobs. HN selection-biased for a geekier crowd so a lot of my criticisms don’t apply to readers of this forum.
- 3036e4 1y agoSorry, but I don't think a preference for slow evolution is always because of laziness. What's wrong with wanting to keep improving on a skill instead of having to waste time relearning things every six months? Software is rare among arts/crafts/whatever in that it is difficult to find nice areas of software to keep digging deeper into (as curious people do!) rather than having to move on to something new just when you start to be good something. It's not even wanting to focus on depth instead of breadth, as the constant changes means you are barely able to keep using your older skills, so there is little actual breadth more like constantly moving between shallow pools of knowledge. Maybe it feels great to constantly be moving, but I do not see how it is productive or positive in any way for us.
- tombert 1y agoI am arguing that they aren’t improving their skills in any regard, including how to properly use the tools they already pretend to know. They don’t go “deep” or “broad”, they don’t learn anything more than what they were taught in university. I have had to debug a lot of concurrent Java, so my opinions are skewed towards that, but I have seen cases where “staff engineers” label every single function as `synchronized`, who genuinely don’t know why you would use a queue, have no concept of thread starvation or fairness, when to use an atomic instead of a mutex, and genuinely do not seem to understand that for network applications it’s generally more important to figure out how to reduce latency than trying to choose the optimal hashmap or sort implementation. These aren’t arcane details that require a PhD in category theory or require being constantly plugged into hacker news, these are extremely basic things that these Java engineers do not know. I think most Java engineers, like more professionals in general, are very bad at their jobs. I think Java just selection-biases higher than other languages for people who are bad at their jobs.
- santiagobasulto 1y agoThis is amazing news! Two questions for you: - how’s the environment? Build tools, dependency management, etc. it used to be a PitA back then. - how has the typing system and generics evolved to support this? Have they introduced any type of variance?
- jfengel 1y agoMaven still sucks. IntelliJ IDEA is genuinely great. It helps that they were the ones who developed Kotlin, and a fair bit of the actual language changes were gacked from Kotlin. (Or you could say "prototyped and shown valuable in Kotlin".) They are still hampered by lousy nullable support. You didn't ask, but Spring still sucks. It's not part of the language but it's a ubiquitous framework.
- tombert 1y agoIt’s amazing that Java has access to really great, high performing web toolkits like Vert.x and even Play, and yet the entire enterprise Java world has converged on Jakarta and Spring. I don’t like Spring but in my mind there is a special place in hell for Jakarta/JavaEE.
- tombert 1y agoGenerics still kind of suck but they’re workable enough. As far as I am aware they’re broadly unchanged and I don’t think they added any kind of new variance. It turns out, though, it’s still good enough for sealed interfaces and the like; I don’t have too many issues with it, though that might just be Stockholm syndrome at this point. Maven is terrible as always but Gradle is generally fine. I use IntelliJ community edition solely for Java and it works well enough for what I need. It’s not like Java is going to replace F# for me or anything, but I do genuinely think it’s more fun to write now than it used to be.
- michaelrpeskin 1y ago> I don’t think Java makes people into bad programmers, but I do think it selection-biases for intellectually unambitious engineers. They learn exactly enough Java in college to pass their courses, and then get a job at a BigCo that doesn’t strictly require ever learning anything more than what they were taught in their “intro to data structures” course. I think that's a fair comment, but also there's this perspective: I first touched Java 1.1 in 1997 in college, and only for a semester. Then for the next 22 years never looked at a line of Java, working mostly in C++ and Python plus dabbling in FORTRAN for high performance stuff that needed to be written there. I generally consider my self not intellectually unambitious. Then I moved to a Java shop who specifically needed high performance math (well at least as high performance as you can get in Java, which is actually pretty good now). But we stick to Java 8 compatibility because we have some BIG customers who require that because of LTS on Java 8. There are some nice constructs that would help make the code more readable and modern, but when you need to support people and actually make money you do what you need to.
- tombert 1y agoSure, I am not claiming that you have to use every new feature every day 100% of the time. Obviously there are cases where you can’t upgrade for legal or compliance or “customer is just being difficult” reasons. A lot of Java jobs aren’t that though, especially internal applications. A lot of places are running Java 17 or Java 21 on all their servers, literally have no plans to ever support anything lower, but the engineers are still writing Java like it’s 2003. That is what’s maddening to me.
- javanonymous 1y agoI think it has a lot to do with work culture. Many tend to mimic what others are doing in order to not stick out. At my previous job some were able to change that by consistently using "modern" features of Java. It inspired others to change and eventually we ended up with a good code base. Be the one to start the change by implementing new features using good code. This will give others "permission" to do the same. Also try to give soft suggestions in code reviews or pair programming of simpler ways to do it (don't push too hard) At my current job all of us were eager to try the latest features from the start, so we never had to convince new hires.
- pyrale 1y agoYeah, people often underestimate the importance of community when they discuss programming language. In fairness to the Java crowd, you rarely see codebases looking like the team was trying to fit every new concept from some blog they read somewhere in the codebase, like you do in e.g. Scala or Haskell.
- latchkey 1y ago> The biggest issue, though, is that Java programmers won’t use the new features. My old CTO boss swore he wouldn't ever use annotations because they were too much magic for him. "No! Writing out gobs of XML to configure Spring DI is the only way!"
- tombert 1y agoI generally hate when people use the “magic” excuse for not doing things. Most of these tools are open source and/or can be readily viewed in IntelliJ. It really isn’t hard…cmd+click on what you want to look at. If you’re an engineer you should be able to easily read the code to see what’s going on. Most of the time the “magic” can be understood in less than 30 minutes and then it’s not magic anymore.
- latchkey 1y agoYou're right, "magic" is generally when someone doesn't take the time to understand things. A busy CTO may not have time, so more things seem like magic to them. What's inexcusable is to inflict the rest of your team with your nonsense.
- tombert 1y agoYep, completely agree. I got in a bit of a disagreement with teammates at a previous job. I liked these teammates, they were very smart and nice people, but for a specific project I wanted to use LMAX Disruptor, and the excuse for not using it was very literally “we don’t want to make people learn anything”. That stuff blows my mind; aren’t we engineers? If we’re not willing to learn new things and adapt, what exactly are we offering that a high school kid who bought an “Intro to Java” and “Intro to Spring” book can’t?
- kleyd 1y agoI wouldn't dare say XML is better in this regard, but a good reason to be conservative with the use of annotations is exactly that cmd+clicking them doesn't easily lead to where the behavior is implemented.
- golyi 1y agovar was introduced in Java 10 not 8.
- tombert 1y agoYep, just looked it up and you are right! I misremembered. I stand by my overall point though.