News for hackers. Stuff that matters.
Re:Java 20: A Sneak Peek on the Panama FFM API by gavinray on Wednesday December 07, 2022 @07:28PM (#33902435)
Java after JDK 17 is a completely different language, almost like the difference between Javascript pre-ES6. It got:

- Pattern matching

- Sealed types

- Records (immutable, succinct data-classes)

- Multiline strings

Among other things. It's almost as nice to use as Kotlin, and I say this as a huge Kotlin fan. Its pattern matching in most recent releases is actually more powerful than Kotlins, since it allows deconstruction-bindings in patterns.

Re:Java 20: A Sneak Peek on the Panama FFM API by oangemangut on Wednesday December 07, 2022 @08:21PM (#33902868)
I feel like this is going to be to kotlin's disadvantage going forwards as languages features are slowly added into Java, they will be more 'complete'.
Re:Java 20: A Sneak Peek on the Panama FFM API by Alupis on Wednesday December 07, 2022 @08:28PM (#33902910)
Java can never be Kotlin without breaking a lot of backwards compatibility. That is the "edge" a newer JVM language like Kotlin enjoys.

Since Java's history is very focused on not breaking things (and folks got really grumpy on the few occasions something has been broken), Java cannot ever match the feature pace of languages like C# either.

But the folks writing Java code (most of you here on HN by all metrics), mostly don't care. They enjoy backwards compatibility and stability far more than new features. The overwhelming majority of newly written Java code is targeting Java8 still - which doesn't use any of these new features anyway.

Backwards compatibility is also why things like lambda's and streams are the way they are in Java (and most FP folks would sneer at), and things like Records took years to release (still technically in the Preview stage).

The advantage Kotlin has, and the reason it's growing in popularity in backend development is you get all the FP tasty features you want right now, but maintain near drop-in compatibility with existing Java libraries and frameworks. This was the most brilliant move by the Kotlin designers in my opinion...

Re:Java 20: A Sneak Peek on the Panama FFM API by pron on Thursday December 08, 2022 @06:03AM (#33906613)
> The overwhelming majority of newly written Java code is targeting Java8 still - which doesn't use any of these new features anyway.

Java 8 users are now a minority. Some libraries still target it (although Spring 6 targets 17 as the baseline), but most Java code is in applications.

> Java can never be Kotlin

Java doesn't want to be Kotlin because it aims at a much wider audience. Back in the nineties James Gosling laid out a strategy of an innovative runtime wrapped in a conservative language that only adds the most beneficial features, and only after they've been successfully tried in other languages, and this has worked very well.

Also, the Java language has the advantage of controlling the runtime, which allows us to add a smaller number of features, which are more powerful (e.g. compare records with data classes, or virtual threads with syntactic coroutines), while Kotlin can neither change the runtime nor have a significant impact on the ecosystem, and so is more limited in what it can achieve. Moreover, Kotlin's features are increasingly mismatches with the evolution of the platform.

Nevertheless, we are happy that the platform offers more feature rich languages to the minority of developers that do prefer them (or languages with radically different approaches, such as Clojure), so the platform can cater to programmers with different language preferences.

Re:Java 20: A Sneak Peek on the Panama FFM API by za3faran on Thursday December 08, 2022 @01:38AM (#33904925)
> Java cannot ever match the feature pace of languages like C# either.

That's by deliberate choice. They are going down the route of having the last mover advantage. Lots of people have complained about C#'s kitchen sink type of approach for example. And the more features you have, the more chance that they won't fit together neatly and cleanly.

A couple of examples that come to mind, Java's pattern matching/destructoring and upcoming string templates (JEP 430) are much more fully fledged compared to their Kotlin counterparts.

It also has the advantage of being the platform language. Now that we have virtual threads on the JVM, async/await immediately becomes irrelevant. However, Kotlin now has to maintain coroutines even though the platform offers a better way of doing things.

Re:Java 20: A Sneak Peek on the Panama FFM API by oaiey on Thursday December 08, 2022 @02:19AM (#33905165)
As a C# advocate I have to say, that the C# design team is doing an excellent job.

The amount of syntax I see literally 1:1 taken over by dozen other languages is really impressive and evidence for that.

Re:Java 20: A Sneak Peek on the Panama FFM API by pron on Thursday December 08, 2022 @06:05AM (#33906622)
> As a C# advocate I have to say, that the C# design team is doing an excellent job. The amount of syntax I see literally 1:1 taken over by dozen other languages is really impressive and evidence for that.

That would be the case for pretty much any language that has lots of features (provided that most of those features aren't completely terrible). A good design (at least for a mainstream language) also strives to minimise the number of features, not adding everything you can but only adding things you absolutely need. In the case of C#, many of its features are not widely adopted, and Java in particular will never adopt them.

Java's philosophy has always been to wrap an innovative runtime in a conservative language that only adds features late, after they've proven their worth elsewhere and when most mainstream programmers are ready for them, with the realisation that every added feature adds a cost to learning the language. That strategy has worked very well for Java, but .NET has a different strategy (a more adventurous language built on top of a less adventurous runtime). We'd rather spend two years thinking about how to avoid adding a new language feature than spend six months adding it. This "last-mover" strategy has helped us maintain our philosophy and keep the number of features small compared to C#. We strive to only add features that have a big bang-for-the buck and that, preferably, solve many problems at once, rather than add many features, each addressing a relatively small problem. For example, virtual threads have allowed us to avoid adopting async/await; records are allowing us to avoid adopting properties, and will likely help us avoid adding named and default parameters as a separate feature (which, in languages like C#, Swift, and Kotlin breaks binary compatibility/separate compilation).

Re:Java 20: A Sneak Peek on the Panama FFM API by oaiey on Thursday December 08, 2022 @05:16PM (#33914474)
I posted that in parallel. C# tries to be both, a system and application language. Java does not try that. Therefore, they can skip all the memory related topics quite quickly. And that wades out like 80% of the average joe unused features.
Re:Java 20: A Sneak Peek on the Panama FFM API by za3faran on Thursday December 08, 2022 @01:31PM (#33911316)
> and will likely help us avoid adding named and default parameters as a separate feature

Very cool. Is there any material available about this for further reading?

Re:Java 20: A Sneak Peek on the Panama FFM API by pron on Thursday December 08, 2022 @04:58PM (#33914201)
Not really, except for speculation on my part on how we might end up doing it: https://old.reddit.com/r/java/comments/siv00z/named_and_opti...
Re:Java 20: A Sneak Peek on the Panama FFM API by pjmlp on Thursday December 08, 2022 @03:14AM (#33905563)
I would rather that they would give more support to F#, and improving the story on the Common Language Runtime between all existing MS languages, instead of rebooting the whole experience into C# Language Runtime.
Re:Java 20: A Sneak Peek on the Panama FFM API by gavinray on Thursday December 08, 2022 @02:39PM (#33912209)
F# goes right up with D as "most under-rated/under-recognized language of all time"

A lot of its features for functional programming got swallowed up in later C# versions, and it's the Red-Headed Stepchild of the CLR (let's pretend VB.NET doesn't exist).

MS allows it to exist but it's a second-class citizen on the CLR, and, I think, always will be =(

Re:Java 20: A Sneak Peek on the Panama FFM API by oaiey on Thursday December 08, 2022 @05:14PM (#33914450)
their numbers are simple .... C# has millions of developers, VB.NET 100ks and F# 10ks. They put their focus where their users are. They presented a slide deck once about that.

And F# was created as a research project and is a lot more community driven than C#. So if Microsoft starts putting more people onto that, I think a part of that community will also scream that they should stay out.

Re:Java 20: A Sneak Peek on the Panama FFM API by pjmlp on Friday December 09, 2022 @01:59AM (#33918427)
There were no users when C#, VB.NET and Managed C++ (replaced by C++/CLI on .NET 2.0), likewise there were no users per se when WinRT was created with another tooling and API surface than its Win32 and .NET counterparts.

I know those numbers, and can even refer to the blog post they were presented, if a big company like Microsoft wants people to use language XYZ, they can make it happen if management cares about it.

However they aren't caring enough to sort out the GUI civil war, so why would the .NET languages by any different, regarding coherent management across the board.

Re:Java 20: A Sneak Peek on the Panama FFM API by kaba0 on Thursday December 08, 2022 @01:40AM (#33904933)
> Java cannot ever match the feature pace of languages like C# either.

Thank God. Don’t get me wrong, C# is a cool language but languages suffocate under so many features, most devs will simply never ever learn most of them. And some of these features while invaluable in certain rare cases, I would rather prefer a better, more fundamental feature that takes more time and single-handedly solves for many situations.

Unfortunately modern languages really like to throw in everything they have seen from other languages ever, and even with very smart language designers these features will inevitably tangle (khm, swift).

Re:Java 20: A Sneak Peek on the Panama FFM API by oaiey on Thursday December 08, 2022 @02:21AM (#33905181)
C# tries to be a system language (for writing servers, runtimes, and even operating systems) AND an application language (for writing your favourite apps). So you have now a huge feature set which is focused on efficient memory handling and then you have another feature set on writing nicely applications (think pattern matching etc).
Re:Java 20: A Sneak Peek on the Panama FFM API by gavinray on Thursday December 08, 2022 @02:40PM (#33912230)
It's actually crazy what you can do with C# as far as systems programming nowadays.

I recently wrote a database buffer pool with it, allocating raw aligned memory and directly casting bytes from DB files into in-memory struct pointers.

It's very nearly a systems language in terms of capabilities.

Re:Java 20: A Sneak Peek on the Panama FFM API by pjmlp on Thursday December 08, 2022 @05:28AM (#33906380)
While WinDev keeps ignoring such improvements and rather doubles down on the C++ / COM combo, including forcing everyone else to deal with writing .NET bindings to those APIs.

CsWinRT and win32metadata are still quite far from a great usability experience.

Re:Java 20: A Sneak Peek on the Panama FFM API by Macha on Thursday December 08, 2022 @12:18PM (#33910430)
I don't think it can be Kotlin, but I don't think it needs to put a serious dent in Kotlin adoption, as it just needs to stop driving people away so hard and then the friction to do something different will keep people in Java if Kotlin is say, only 30% nicer. See for example coffeescript getting limited by ES6.
Re:Java 20: A Sneak Peek on the Panama FFM API by vips7L on Friday December 09, 2022 @10:29AM (#33922289)
IMO Kotlin is barely nicer than Java currently. Java has for the most part implemented better or equivalent versions of a lot of Kotlin's features (e.g. virtual threads, pattern matching, sealed classes).

The last things missing are properties (which should be coming with reconstructors), and nullable types. For me, nullable types are not worth the switch.

All that being said, I don't think the languages are mutually exclusive. As a JVM developer you retain all your knowledge of the JVM and it's standard library. Lastly, a language doesn't have to be the dominate language on a platform to be usable and employable (just look at Scala).

Re:Java 20: A Sneak Peek on the Panama FFM API by zaphirplane on Thursday December 08, 2022 @12:26AM (#33904527)
Adding features doesn’t mean breaking backwards compatibility, I can only think of modules since Java 8 that can maybe be.

What Kotlin features are possible because of that freedom ? Genetics can be an example I can’t say it’s impossible for Java to add in out refied keywords

Re:Java 20: A Sneak Peek on the Panama FFM API by mike_hearn on Thursday December 08, 2022 @08:47AM (#33907849)
The obvious one is putting types on the right, which is a useful syntax for more pervasive type inference.
Re:Java 20: A Sneak Peek on the Panama FFM API by kaba0 on Thursday December 08, 2022 @11:03AM (#33909380)
I don’t know, in theory replacing types with ‘var’ would work just as well for Java, the advantage (or more like elegance) of ident: type syntax comes from a parser perspective.
Re:Java 20: A Sneak Peek on the Panama FFM API by pjmlp on Thursday December 08, 2022 @03:16AM (#33905569)
Kotlin has made its pack with the Chocolate Factory, as such they need to now live with the consequences of being a language whose main purpose is to write phone apps where compatibility with Java isn't taken seriously.
Re:Java 20: A Sneak Peek on the Panama FFM API by dxxvi on Thursday December 08, 2022 @01:10PM (#33911060)
Does anybody think that the Java collection api needs to be re-written to catch up with Kotlin's or Scala's? And String should not be String but a collection of characters? And arrays should not be arrays but a collection? And records are not the only thing that can be decomposed but arrays, lists, EntryMap (tuple2) ... should be decomposable as well?
Re:Java 20: A Sneak Peek on the Panama FFM API by vips7L on Thursday December 08, 2022 @03:14PM (#33912691)
Strings implement CharSequence fwiw.
Re:Java 20: A Sneak Peek on the Panama FFM API by Twisol on Wednesday December 07, 2022 @10:26PM (#33903774)
I'm still waiting (agonizingly) for pattern matching in switch to actually land as a non-preview feature. We're looking at a fourth preview in Java 20 (March 2023), so we probably won't get it for realsies until at least Java 21 (September). And that's assuming the associated record patterns JEP is also ready to go after just two previews; it seems like they want them to land together.
Re:Java 20: A Sneak Peek on the Panama FFM API by kaba0 on Thursday December 08, 2022 @01:35AM (#33904903)
Many of these projects actually wait for Valhalla before finalizing. It would be a real shame if they couldn’t all boil together a bit to get it absolutely perfect.
Re:Java 20: A Sneak Peek on the Panama FFM API by topspin on Wednesday December 07, 2022 @09:31PM (#33903355)
New style switches as expressions are pretty nice as well.