Live data from Hacker News

Java 21 makes me like Java again

wscp.dev

711–720 of 777 posts

Re: Java 21 makes me like Java again

#711
post #633

Earlier quoted context omitted.

Of all the features most Java devs (and ex-Java devs) desire, algebraic types are near the bottom. How about intersection and union types? (NO, sealed classes are not a substitute for unions). But, yeah, in my view JDK 21 is a a disappointment. I rarely want pattern matching, but I would like properties please and records are nice, but actual tuples are more useful. Etc.

I'd love if interfaces worked as in typescript. As long as the object signature matches the interface as parameter then you can use it.

Check out project manifold, it’s a compiler plugin for Java. Among other amazing features it adds structural typing [1], which is essentially interfaces typescript interfaces.

1. https://github.com/manifold-systems/manifold/tree/master/man...

Re: Java 21 makes me like Java again

#712
post #652

Is there any widespread concern over lack of unsigned int native types?

Not really. With valhalla they can be user-implemented efficiently, although without syntactic sugar like +.

Does that mean addition would look like

  Uint32 a,b,c;
  c = a.plus(b);
in what you describe, once project valhalla is complete?

Re: Java 21 makes me like Java again

#713

Earlier quoted context omitted.

I'm not so sure if the users of VS Code, Discord, Slack, etc would agree. Yes it's bulky and sometimes slow, but it offers a lot of features and allow developers to ship features and updates really fast, while only needing one codebase for all platform.

I can't see users caring about it all being one single codebase and I don't think that they should. Every cross-platform development tool like this means awkward, non-native UIs. Maybe there's something to new feature development. But, I suspect the big players could be a little less profitable and deliver a better experience for their end users. I've used Electron as a developer, too. While it may have been fast & e…

> Security with Electron is a problem in general given its massive surface area.

I'm new to Electron development. I've read the docs recommending hardened runtime. Would it be sufficient for security? Can you give examples of such security issues?

Re: Java 21 makes me like Java again

#714
post #652

Earlier quoted context omitted.

Not really. With valhalla they can be user-implemented efficiently, although without syntactic sugar like +.

Does that mean addition would look like Uint32 a,b,c; c = a.plus(b); in what you describe, once project valhalla is complete?

Well, that will be available as a basically zero-cost abstraction. But I haven’t seen more specific mention of it in the mailing lists/design proposals - they definitely didn’t want to add a new primitive type, but perhaps if they manage to heal this rift between objects and primitives and it will only be add syntax-level complexity, they might go for it.

Re: Java 21 makes me like Java again

#716
post #424

Earlier quoted context omitted.

Which is a non starter for businesses that don't ship source code.

https://pkg.go.dev/plugin

Not only it doesn't work in all platforms, it uses a bare bones C API with unsafe code, and it hasn't been removed yet due to backwards compatibility, as Russ Cox already expressed his opinion that plugin was a mistake from his point of view.

Re: Java 21 makes me like Java again

#717
post #422

Earlier quoted context omitted.

It has existed for 20 years, and already started with Sun. Having AOT compilers as commercial offerings, was seen as one way to capture value in the Java market, in a culture where most compilers were still commercial, GCC being the exception.

> It has existed for 20 years, and already started with Sun. In an anemic way, with mostly third party offerings few people know or care about, and various degrees of pain and shortcoming to their use. It should be a first class feature, and as simple to use as is in Go (including for cross compiling). In general, if something exists in "some form" for 30+ years in a language, and only a handful of people use it, whe…

Regardless, it exists.

Re: Java 21 makes me like Java again

#718
post #666
post #525

Earlier quoted context omitted.

I never see Dart talked about in these contexts but just to highlight a few things. 1. Compiles to native code with a single and very reasonable sized binary on pretty much any platform. 2. Compile to WASM (coming this year) if that’s your thing. 3. Excellent concurrency support with lightweight and simple mental models 4. Variables are not nullable by default thus simplifying tedious checking in your codebase. 5. Sy…

Combining the best parts of Java and JavaScript isn't exactly something to boast about. Dart lives and dies with the Flutter framework. Other than that it's not doing anything special. Not terrible but also not a significant improvement.

I mean you’ve taken my point, cut it in half to remove the relevant context and are now arguing against a point you’ve made up as some kind of gotcha… I don’t know what you want me to say to that.

Same with your second point. I made a big point to explicitly say I think that right now Dart is very underused and has a huge potential outside of Flutter. Quoting that back to me as though it was something I hadn’t considered is equally as confusing.

Re: Java 21 makes me like Java again

#719

Earlier quoted context omitted.

The job of software engineers is to translate a business domain into software. Different languages are better or worse at modeling different domains of problems. I have seen the same problem solved in different languages take 2-3x the amount of work and have a large difference in ongoing maintenance costs. Java's reliance on traditional OO means that only a small subset of business domains naturally map to the langua…

> Java's reliance on traditional OO means that only a small subset of business domains naturally map to the language's constructs. In my career I worked on a really wide range of business domains and have not even noticed the problems you are talking about. The problem of mapping certain types like unsigned int that you mentioned is rather rare integration scenario. There’s not that many domains where numbers with th…

> In my career I worked on a really wide range of business domains and have not even noticed the problems you are talking about.

How many other programming paradigms have you explored in depth and built solutions with?

Back when I did OO in Java and C# I didn't think twice about it, converting things to an OO paradigm was second nature, but once I stepped outside my comfort zone and learned of other modeling techniques, I realized that I had been jumping through extra hoops to get to where I wanted.

Re: Java 21 makes me like Java again

#720
post #321

Earlier quoted context omitted.

Checked exceptions are gross, they get in the way when you're prototyping, and you end up just ignoring them anyway (since you're prototyping)

The ergonomics of checked exceptions may be debatable but compared to golangs explicit error handling at essentially each function call is definitely worse.

Both Java checked and unchecked exceptions are inferior to signaling errors by return values like Go/Rust/Haskell do.

Exceptions are not composable, cannot be generic, and it is not visible in the source code which lines can throw, so every line is a potential branching point.

Post reply on HN