Live data from Hacker News

Java is becoming more like Rust, and I am here for it

joshaustin.tech

61–70 of 71 posts

Re: Java is becoming more like Rust, and I am here for it

#61

I'm surprised there aren't more people using Java nowadays. The JVM is rock solid, the speed is really good, and the latest changes are making the language much more modern. Maybe people are actually using it but not talking about it? Not sure.

Who's not using it? Rhetorical, but Java is everywhere still, especially near anything that's making money. (As opposed to, perhaps, hobbyist solo projects, which if that's your only sample size perhaps it looks like Java isn't as popular?)

These days it's actually more interactive and dynamic to develop applications with than a lot of dynamic languages, thanks to the improvements over the years.

Re: Java is becoming more like Rust, and I am here for it

#62
post #35

Earlier quoted context omitted.

Everyone hasn't forgotten, they just aren't learning things from the bottom-up. It's Rust-like to the author because that's probably where he learned about it in the first place.

> It's Rust-like to the author because that's probably where he learned I like about HN that everyone is so friendly about this type of thing. I personally don’t have a lot of patience for people who think new things are the greatest inventions and ‘the old is catching up’ (in this case Java catching up with Rust) while everything came from elsewhere originally. If you want to openly say these things, please research…

I feel the same lack of patience often, but in the end I respect anyone for putting themselves and their knowledge out there for critique.

Re: Java is becoming more like Rust, and I am here for it

#64

Earlier quoted context omitted.

In what way was the language async? It has no threads outside workers, which have strict limits regarding data sharing. You would see a lot of code that registers callbacks as event handlers, but I don't think that makes the language async. That's just the nature of event handlers. They are invoked later, when the event happens. In a way, the lack of threading allowed `async` to be implemented without gotchas. In lan…

I think you have async mixed up with concurrency / parallelism. Async is all about events as opposed to blocking wait. As an example, Java had predominantly sync programming model, because the thread would be block-waiting for stuff, no matter the fact there can many such threads block-waiting.

I don't think so. Any language that had event handlers would be just as "async" as the OG javascript. First class thread support matters because sometimes it matters which thread the event/continuation runs on.

Re: Java is becoming more like Rust, and I am here for it

#65
post #52

Earlier quoted context omitted.

In what way was the language async? It has no threads outside workers, which have strict limits regarding data sharing. You would see a lot of code that registers callbacks as event handlers, but I don't think that makes the language async. That's just the nature of event handlers. They are invoked later, when the event happens. In a way, the lack of threading allowed `async` to be implemented without gotchas. In lan…

Async and multithreading are not the same thing. Async is about non-blocking execution between functions. JavaScript is inherently async because the concept of the event loop is baked into the very language runtime itself. In Java you can achieve a single threaded async runtime by instantiating a SingleThreadExecutor and having all your application code running as jobs posted to this executor. But because you can opt…

I know they're not the same thing. But first class thread support can make asynchrony harder to implement since it sometimes matters which thread the continuation runs on.

> JavaScript is inherently async because the concept of the event loop is baked into the very language runtime itself.

Ok, I hadn't thought about it this way. Early UI frameworks for java had this property as well. I don't know about the implementation. But there was some kind of message loop running, and you'd register event handlers, and events would get dispatched to your handlers.

You could argue that was the framework, not the language. Maybe I'm wrong, but I think of the message loop as being a property of the execution environment (DOM/node) rather than the language. Maybe that's not a real distinction though.

Re: Java is becoming more like Rust, and I am here for it

#66
post #57

Earlier quoted context omitted.

In what way was the language async? It has no threads outside workers, which have strict limits regarding data sharing. You would see a lot of code that registers callbacks as event handlers, but I don't think that makes the language async. That's just the nature of event handlers. They are invoked later, when the event happens. In a way, the lack of threading allowed `async` to be implemented without gotchas. In lan…

Sounds like parent was using async to mean that JS has single-threaded concurrent functions by default. Disclaimer: I'm just the messenger here so you might hate what follows, the community is choosing the words. Concurrency as a keyword is increasingly being used to differentiate single-threaded event handling from parallel processing (threads). As long as event handling is quick enough, it can give the illusion of…

I'm not an expert or anything, but I've never seen an implementation of event handling that was anything other than STCFBOHEH. (hadn't heard the term)

My understanding of "async" as a language feature is basically support for an `await` keyword. Having a message loop and event dispatcher seems like a less useful definition, but good to know, I guess.

Re: Java is becoming more like Rust, and I am here for it

#67
post #60
post #11

Earlier quoted context omitted.

The OpenJdk team has said multiple times that their inspirations are coming from ML and not Scala or Kotlin.

This seems hard to believe. If true, it seems very odd that they wouldn't be studying successful languages with enormous real world adoption targeting the same platform as theirs.

To quote Brian Goetz [0], the language architect:

> It is super-common to observe "I saw feature F in language X, then I saw it come to Java, they must have gotten their inspiration from X." And while sometimes this is true, it is far more common that both are drawing inspiration from a common source or literature, sometimes even one that predates either language. (It is also super-easy to confuse "Language X was the first place I saw feature F" with "X invented F.")

Another in reference to getting inspiration from OCaml [1]:

> This is exactly the reaction that I was describing by "might elicit strong reactions from some", which is what I would call a "who moved my cheese" objection. Good, now we've got it out of the way. I had the same concern for the first few seconds after seeing this idea (the inspiration came from work being done in OCaml), but it didn't take much longer to see how it fit into the bigger role of switch.

Another from Ron Pressler [2]:

> Obviously, we do borrow features from less popular languages (primarily ML, which was never popular), but only when we think they're the best way to address a real need of Java's millions of mainstream developers and not just because those languages' self-selecting users love them.

This has all been discussed multiple times on the /r/java subreddit.

[0] https://www.reddit.com/r/java/comments/11322uy/jep_draft_imp...

[1] https://www.reddit.com/r/java/comments/18hglp5/effect_cases_...

[2] https://www.reddit.com/r/java/comments/18ynhn1/which_kotlin_...

Re: Java is becoming more like Rust, and I am here for it

#68
post #45

Earlier quoted context omitted.

A better way to say it is that Java is becoming more like Kotlin, which in turn was halfway between Java and Scala.

“Java is becoming more like Kotlin” lands you on the lower half of front page at best. “More like Rust”? Instant upvotes, #2 right now.

Except its not becoming more like Kotlin. It's becoming more like ML and OCaml

Re: Java is becoming more like Rust, and I am here for it

#69
post #19

[flagged]

The modern belief is that [] should be reserved for generics[0]. In fairness, I've never seen a language actually stick to that and that's also a bit hollow when Java itself uses for generics in the first place. [0] https://soc.me/languages/stop-using-angle-brackets-for-gener...

What I meant is that Java by design refused to add operator overloading, because "this would decrease code readability", I mean I feel likeJava designers are trying to save me from myself, while other languages just implemented operator overloading and it works fine. When I did my M.Sc. project in Java that involved mathematics it was pain in the bum to write these matrix multiplications by methods... Almost like Reverse Polish Notation vibes

Re: Java is becoming more like Rust, and I am here for it

#70
post #3

The article is using immutable records and sum types as “more like Rust” and I am just sitting in the corner, wondering whether everyone has forgotten that these things came from FP in the first place. In my mind, a language isn’t “Rust-like” because it uses concepts we learned in FP. We have languages like Haskell and, before it, ML. And I know ML didn’t invent it. We also have Scala, and for Scala, we don’t even ha…

Isn't F# more like a nephew of OCaml and cousin of C#? F# "originated as an OCaml implementation", which runs on .NET with some C# interop support?

You can have more than one cousin. C# and Java are cousins, obviously, I don’t think I need to explain that one. F# and C# are also cousins, naturally.
Post reply on HN