News for hackers. Stuff that matters.
Re:Java 20: A Sneak Peek on the Panama FFM API by Waterluvian on Wednesday December 07, 2022 @06:52PM (#33902103)
I touched Java in school and rarely since. Is it the kind of language where you can be production-level productive with just a text editor and CLI, or do you need an IDE to manage everything?

The last time I poked at it, there were just so many config and generated files and so much complexity that it felt like I must use an IDE that hides a layer of “magic”.

Or am I just confessing ignorance and this isn’t a thing and it’s no more complex and magical than Rust or JavaScript or Python?

Edit: thank you all for the helpful responses.

Re:Java 20: A Sneak Peek on the Panama FFM API by dr_faustus on Wednesday December 07, 2022 @07:01PM (#33902189)
Well, you certainly can use it with just an text editor. However, due to the maturity of the language and platform, the IDE support of Java is pretty much unsurpassed and you would certainly be quite a bit more productive if you used an IDE like IDEA or Eclipse.

In terms of complexity, it really depends on what you want to do. Using a powerful framework like Spring can entail some config (albeit much less than it used to). Also you would typically use a build tool like maven or gradle to manage dependencies, build artifacts, etc.. Especially maven can be a little arcane. But another major upside of the aforementioned maturity is that there are reams of docs and stackoverflow answers which will almost certainly contain solutions for any problems you might encounter.

Re:Java 20: A Sneak Peek on the Panama FFM API by TedDoesntTalk on Wednesday December 07, 2022 @08:29PM (#33902925)
> reams of docs and stackoverflow answers which will almost certainly contain solutions

This is both a blessing and a curse. Some answers and docs are decades old and although still work, are not “fashionable java” (think streams, for instance).

Re:Java 20: A Sneak Peek on the Panama FFM API by silisili on Wednesday December 07, 2022 @09:25PM (#33903313)
This is why I gave up on Java years ago. There seemed to be a lot of cruft left in the language and libraries that you were just supposed to know to not use anymore. I guess for backwards compatibility, but as a learner it's rather frustrating.

Has that gotten better recently? It's been years since I've toyed with it.

Re:Java 20: A Sneak Peek on the Panama FFM API by tadfisher on Wednesday December 07, 2022 @09:52PM (#33903524)
A lot of cruft has been split into modules, so you no longer have AWT/Swing/smartcardio/etc. in your classpath unless you want it.

A lot of cruft is still there; Date, File, InputStream/OutputStream, sun.misc.Unsafe, and the entire legacy reflection API are the bunch that stick out to me. Newer releases are actively mentioning their legacy status in documentation, and there are certainly JEPs to remove them or make them opt-in/opt-out.

If you look at OpenJDK internals, or even the foreign function/memory APIs as described in the article, it looks almost nothing like the Java I learned on and wrote for several years. Most of the Panama API is piggybacking on additions to the language made post-JDK9 or so, such as MethodHandle, VarHandle and @PolymorphicSignature methods. So I'd say the language and runtime is evolving nicely, even under the thumb of Oracle.

Re:Java 20: A Sneak Peek on the Panama FFM API by ahtihn on Thursday December 08, 2022 @01:43AM (#33904962)
> InputStream/OutputStream

I think I missed the announcement of those being "legacy" APIs? They show up all over the place including in libraries, what is the replacement?

Re:Java 20: A Sneak Peek on the Panama FFM API by tadfisher on Thursday December 08, 2022 @02:33AM (#33905254)
The modern versions of these are Channel APIs in java.nio. The "N" in nio stands for "New" even though it was introduced in Java 1.4.
Re:Java 20: A Sneak Peek on the Panama FFM API by kaba0 on Thursday December 08, 2022 @12:38PM (#33910697)
But the old ones aren’t superseded the same way Date is, though. You are perfectly fine using them and in fact will perform similarly well due to Loom (which has actually reimplemented them on top of async APIs)
Re:Java 20: A Sneak Peek on the Panama FFM API by ohgodplsno on Thursday December 08, 2022 @04:24AM (#33906002)
>legacy reflection API

Did I miss something somewhere ? java.lang.reflect is still the standard way of doing Reflection.

Re:Java 20: A Sneak Peek on the Panama FFM API by TravelPiglet on Thursday December 08, 2022 @06:42AM (#33906842)
You can use Method Handles now for better performance in a lot of cases
Re:Java 20: A Sneak Peek on the Panama FFM API by dotancohen on Thursday December 08, 2022 @07:58AM (#33907390)
I occasionally have to touch Java though I'm far more at home in e.g. Python. If you don't mind, a consist mention off the top of your head of things that people in my position should know about, as we Google our Java issues. I'm not cutting and pasting Stack Overflow answers, but even so they often do form the basis of ideas of the code that I write in the end. So pitfalls and modern replacements for ancient practices would be appreciated. Thank you!
Re:Java 20: A Sneak Peek on the Panama FFM API by code_runner on Wednesday December 07, 2022 @08:38PM (#33902982)
I’m new to Java so I just want to confirm… are you saying streams are or are not fashionable? Is there a better api out there?
Re:Java 20: A Sneak Peek on the Panama FFM API by yCombLinks on Wednesday December 07, 2022 @09:40PM (#33903434)
No, there are pre-streams answers, but streams are now fashionable.
Re:Java 20: A Sneak Peek on the Panama FFM API by erik_seaberg on Thursday December 08, 2022 @12:30AM (#33904549)
And streams are part of the reason checked exceptions are now unfashionable. Java doesn’t infer that a generic function arg should affect the caller’s exception signature.
Re:Java 20: A Sneak Peek on the Panama FFM API by code_runner on Thursday December 08, 2022 @05:20AM (#33906332)
Checked exceptions are the bane of my existence
Re:Java 20: A Sneak Peek on the Panama FFM API by plandis on Thursday December 08, 2022 @12:48AM (#33904651)
What’s not fashionable about streams in Java? I’ve seen many modern open source Java projects using them.
Re:Java 20: A Sneak Peek on the Panama FFM API by kaba0 on Thursday December 08, 2022 @01:30AM (#33904876)
Parent might mean it in the negative, that those answers won’t use streams.
Re:Java 20: A Sneak Peek on the Panama FFM API by frant-hartm on Wednesday December 07, 2022 @07:07PM (#33902262)
> Or am I just confessing ignorance and this isn’t a thing and it’s no more complex and magical than Rust or JavaScript or Python?

This is it. There are things which are better in Java than in the other ecosystems you mentioned (e.g. dependency management) and there are things which are worse (the language is more chatty, maybe the designs tend to be more convoluted, but this differs project to project). Even enterprise Java has come a long way, it's different to what it has been a decade ago, it's definitely more lean.

Every sane developer uses either Jetbrains' product for JS, Python or Rust, or they use VS Code, which, after installing all plugins to reach the same productivity as with Jetbrains, becomes an IDE as well.

Re:Java 20: A Sneak Peek on the Panama FFM API by dysarray on Wednesday December 07, 2022 @07:14PM (#33902325)
> Every sane developer uses either Jetbrains' product for JS, Python or Rust, or they use VS Code, which, after installing all plugins to reach the same productivity as with Jetbrains, becomes an IDE as well.

You seem to vastly overestimate the usage of IDEs with scripting languages. In my experience, the vast majority of developers working with scripting languages such as JavaScript, Python or Rust, still use plain text editors such as Vim or Sublime Text. They find these editors to be more convenient and faster than IDEs.

Even people who are on VS Code seem to be using only the built-in language support for scripting.

Re:Java 20: A Sneak Peek on the Panama FFM API by lolinder on Wednesday December 07, 2022 @08:18PM (#33902846)
The Python Software Foundation did a survey (in partnership with JetBrains) and found that 66% of Python developers use VSCode or PyCharm.

https://lp.jetbrains.com/python-developers-survey-2021/#Deve...

State of JS doesn't seem to include the question any more, but it found in 2019 that about 70% used one of the two (mostly VSCode).

https://2019.stateofjs.com/other-tools/

VSCode may not be a full IDE without extra plugins enabled, but it's a far cry from a plain text editor.

Re:Java 20: A Sneak Peek on the Panama FFM API by estebank on Wednesday December 07, 2022 @07:43PM (#33902578)
> scripting languages such as JavaScript, Python or Rust

one of these, is not like the others :)

> They find these editors to be more convenient and faster than IDEs.

FWIW, survey responses from 2021 imply that 54% of Rust devs use VSCode, 28% use a vi variant and 21% use IntelliJ[1].

[1]: Page 19, https://raw.githubusercontent.com/rust-lang/surveys/main/sur...

Re:Java 20: A Sneak Peek on the Panama FFM API by mat_epice on Wednesday December 07, 2022 @08:22PM (#33902879)
They counted 103% of users and couldn’t find a single one using emacs!!! /s
Re:Java 20: A Sneak Peek on the Panama FFM API by Macha on Thursday December 08, 2022 @11:12AM (#33909517)
Probably people like me who use either vsc or vim depending on circumstance
Re:Java 20: A Sneak Peek on the Panama FFM API by satvikpendem on Wednesday December 07, 2022 @08:14PM (#33902814)
> In my experience, the vast majority of developers working with scripting languages such as JavaScript, Python or Rust, still use plain text editors such as Vim or Sublime Text.

Definitely not in my experience, most people I know use VSCode, which I wouldn't call a plain text editor (not necessarily an IDE either though). Most people will use the plugins for each language since those are auto-recommended when you open a new file in that language, such as Pylance for Python, and most people will click "install recommended plugins" and call it a day.

Vim users are few and far between in my experience, and Sublime Text even more so, most everyone has migrated to VSCode at this point that I know of.

Re:Java 20: A Sneak Peek on the Panama FFM API by hotpotamus on Wednesday December 07, 2022 @08:28PM (#33902917)
I tend towards simple GUI text editors (Sublime and gedit), but I'm not really a developer. That said, I do use VSCode for anything that has to touch a git repository because screw trying to manage that on the command line. I wonder if that's what tends to push people towards an IDE if they weren't already using one.
Re:Java 20: A Sneak Peek on the Panama FFM API by weatherlight on Wednesday December 07, 2022 @08:52PM (#33903087)
I use VSCode, but still use the command line for managing git. Old habits die hard, I guess.
Re:Java 20: A Sneak Peek on the Panama FFM API by redditor98654 on Thursday December 08, 2022 @05:43AM (#33906483)
Me too! Although I am playing with Sublime merge lately - it is pretty handy for creating branches off of specific commits, looking at diffs across branches etc.
Re:Java 20: A Sneak Peek on the Panama FFM API by krinchan on Thursday December 08, 2022 @01:17AM (#33904805)
Most vimdevs (myself included) have a plethora of plugins cobbling together a custom and comfy IDE. Almost no one is using a plain text editor now.

And emacs users never had a plain text editor, never claimed as such, and woe be to you if you call it such in front of them. Lol.

Re:Java 20: A Sneak Peek on the Panama FFM API by kaba0 on Thursday December 08, 2022 @01:33AM (#33904893)
I don’t know, I can count on one hand all the websites that still just sprinkle a bit of vanilla JS written in notepad.. JS frameworks absolutely need an IDE, so does python frameworks.

But surely, for advent of code scripting you don’t need it, but neither does Java.

Re:Java 20: A Sneak Peek on the Panama FFM API by indymike on Wednesday December 07, 2022 @09:39PM (#33903416)
The nice thing is being able to use the IDE or a simple text editor and be productive. There are times where a text editor is just right. There are times where the IDE is just right. And with Java... well, very rarely does the text editor fit.
Re:Java 20: A Sneak Peek on the Panama FFM API by jfengel on Wednesday December 07, 2022 @07:12PM (#33902308)
Java doesn't require any config files, and the only generated files are .class files that are equivalent to .o files in C.

There are all kinds of things that you can pile on top of it, usually for managing big projects. Those can seem arduous when you're at the Hello World level. If you got introduced to those it will seem daunting and unnecessary (and for many projects, it is).

But basic Java is no more onerous than Python or JavaScript. About the only difference at that scale is that Java requires type notation, but no more so than C.

And I wrote Java for over a decade with vi. IDEs make it better, but they are not necessary. (And good ones are free anyway.)

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.
Re:Java 20: A Sneak Peek on the Panama FFM API by RHSeeger on Wednesday December 07, 2022 @06:54PM (#33902126)
Using an IDE for Java will, in general, make you orders of magnitude more productive. Not because of generated files or anything like that, but because it can recommend methods, auto-fill in details, add imports, etc. That kind of things saves a lot of time over the long run.
Re:Java 20: A Sneak Peek on the Panama FFM API by Waterluvian on Wednesday December 07, 2022 @06:58PM (#33902159)
Ah. I mean that’s somewhat true for any language. Is Java still super boilerplatey?
Re:Java 20: A Sneak Peek on the Panama FFM API by speed_spread on Wednesday December 07, 2022 @08:31PM (#33902934)
Java's libraries, coding conventions and culture made it verbose more than the core language itself ever required. Starting from scratch and eschewing "good practices" it was always possible to write much leaner code. Get rid of getters and setters, make every field public and final, use anonymous classes to implement interfaces inline, that sort of thing. Obviously wouldn't pass a code review at any "serious" shop ten years ago. But look at Java 20 now, with immutable records and closures and type inference? Well now that code style is now ok! But obviously my ten year old PR is still not approved...
Re:Java 20: A Sneak Peek on the Panama FFM API by papercrane on Wednesday December 07, 2022 @07:03PM (#33902224)
Depends on when you last touched Java. Lambda's (Java 8) have significantly reduced the ceremony needed to do things you'd use anonymous inner classes for. Java 14 introduced records, which makes building simple immutable data objects trivial.

It's still a fairly verbose language, but it's miles from where it was 10 years ago.

Re:Java 20: A Sneak Peek on the Panama FFM API by Waterluvian on Wednesday December 07, 2022 @07:09PM (#33902282)
My textbook says Java 6. So I guess so!

I’m kind of excited now to try it again.

Re:Java 20: A Sneak Peek on the Panama FFM API by xahrepap on Wednesday December 07, 2022 @08:18PM (#33902845)
The language has definitely evolved a lot from then. But so have the major frameworks. While not perfect, building a web app in spring boot is a whole world better than doing the same using Java-6 era frameworks.
Re:Java 20: A Sneak Peek on the Panama FFM API by kaba0 on Thursday December 08, 2022 @01:44AM (#33904969)
Java is much much shorter than Go, which oddly enough never gets this “complement”. So, take these boilerplate claims for Java with a grain of salt.

But to actually provide an answer, records shorten the language to a great degree in my opinion, there is also type inference with `var`, so on a local scope you can write really short code. The main method is still chatty, but it’s not like you actually have to write all that many times, plus it is just psvm for most IDE users.

Re:Java 20: A Sneak Peek on the Panama FFM API by peterashford on Friday December 09, 2022 @03:29AM (#33918994)
Yes! I work programming in Go. I like it a lot - its a very pragmatic language. But I couldn't believe that people who derided Java for verbosity were raving about Go. It's pretty good, but the boilerplate is extreme
Re:Java 20: A Sneak Peek on the Panama FFM API by jjfoooo4 on Wednesday December 07, 2022 @07:40PM (#33902539)
The strong typing system in Java means the recommendations and general code assistance is much more accurate and powerful than that if scripting languages
Re:Java 20: A Sneak Peek on the Panama FFM API by kelnos on Wednesday December 07, 2022 @08:44PM (#33903027)
I do know people who write Java in vim, with some plugins installed to give them IDE-like features. I've tried it, but, frankly, it's just so much easier to use something like IntelliJ IDEA, that it feels silly not to. The non-IDE ways of doing things are still pretty unpolished and missing features, while the IDEs are incredibly polished at this point.

I think the whole config/generated files thing is for old-school J2EE "enterprise Java". Most of the frameworks I've used have just involved writing code. Sure, sometimes you need a config file, but that's pretty normal -- most of the time I'd rather specify things like port numbers and logging configuration in a separate config file, rather than hard-code them in the app themselves. If you stay away from the old-school Java Servlet frameworks -- or use a framework that builds on top of servlets and hides the complexity -- then you don't have to deal with that crap.

The build ecosystem is a bit more fragmented than Rust (maven or gradle or sbt or...), and the build tools do require a bit more boilerplate to configure, for the most part (especially maven), but it's not too bad. JavaScript, IMO, has some of the most inscrutable build systems I've ever seen, so I don't think that's comparable to Rust, or even Java. Maybe the complexity of Java build systems is similar to Python, though in different ways.

The recent releases of Java have added a lot of quality-of-life improvements to the language, so it's a lot more pleasant (and less verbose) to write Java than it used to be. I still prefer something like Scala (2; haven't tried 3 yet), but it's a lot easier to build a team around Java than Scala.

Re:Java 20: A Sneak Peek on the Panama FFM API by yedava on Wednesday December 07, 2022 @11:23PM (#33904127)
Once a code base gets big enough to be larger than a handfuls of files, a text editor just won't be able to keep up with the refactoring/reorganizing capabilities of a statically typed language managed by an IDE. This feature of Java alone makes it well worth it (over say JavaScript or Python), despite whatever other issues the language has.
Re:Java 20: A Sneak Peek on the Panama FFM API by narrator on Wednesday December 07, 2022 @07:27PM (#33902427)
You will need to use an IDE to be productive in Java. One thing that Java does better than just about any other language though is it's maintainable. A codebase in Java can exist for decades and not become unmaintainable no matter what lowest bidder IT services contractor works on it. That's because the language makes it hard to write obfuscated spaghetti code and the static typing allows for deterministic refactoring of bad code. That's something you can't easily do in JavaScript.
Re:Java 20: A Sneak Peek on the Panama FFM API by AlphaSite on Wednesday December 07, 2022 @10:46PM (#33903911)
I don’t know if this is true, I’ve seen some truly awful spaghetti g with a dozen modules to implement a trivial web api and it was indecipherable. This was for a “tech” company as well, not just some random internal app (it was built by the sales org though, which explains it).
Re:Java 20: A Sneak Peek on the Panama FFM API by kaba0 on Thursday December 08, 2022 @01:51AM (#33905012)
Everything can be done, but I do believe it is empirically true that Java programs has “long shelf lives”.
Re:Java 20: A Sneak Peek on the Panama FFM API by throwaway2037 on Wednesday December 07, 2022 @10:41PM (#33903878)
This is an interesting comment. When you say "maintainable", I would agree but for different reasons. It would say a single owner for most of the ecosystem (Sun->Oracle) makes it exceedingly stable. (Yes, I know IBM has a parallel universe, but little used compared to Oracle's.) Think about it: A single vendor provides the whole stack: compiler, debugger (including remote!), standard library (immense, well-documented), virtual machine, and IDE (NetBeans). There is also a small army of well-paid, highly skilled developers employed by Sun->Oracle constantly working to improve this ecosystem. Probably, the only thing they don't provide is a build system. They originally wrote Ant, but then let free in the wild. Also, no segmentation faults, full exception stack traces, and mature decompilation tools make it incredibly simple to debug -- even the hairiest legacy libraries. With the exception of Microsoft's C#/.NET, I cannot think of any mature equivalent. Note: Above, I never mentioned the open source community (Maven Central Repo, etc.). I won't touch that because the quality varies wildly.

And, yes, I agree 100% about your reference to low cost developers. From an enterprise view, it is cheap and easy to find (low quality and) low cost developers to maintain legacy Java software.

You also wrote: <<... static typing allows for deterministic refactoring of bad code. That's something you can't easily do in JavaScript.>> Most JavaScript devs would immediately reply: "Oh, use TypeScript for that." As I understand, you can incrementally upgrade a legacy JavaScript project to TypeScript, then slowly add types. Also, I have refactored lots of Java code that uses Object as a substitute for C's void*. That type of code is so difficult to understand without a debugger. Also, very difficult to refactor due to limited typing.

Re:Java 20: A Sneak Peek on the Panama FFM API by kaba0 on Thursday December 08, 2022 @01:49AM (#33905003)
I’m not sure I agree with the single owner part — it surely helps to give that “final touch” stability, but Java’s huge advantage is being an actual standard with an insane number of very independent implementations. Sure, most actual code will run on basically OpenJDK with minor modifications, but features are not added willy-nilly and the semantics are not just “whatever our single compiler outputs”.
Re:Java 20: A Sneak Peek on the Panama FFM API by exabrial on Wednesday December 07, 2022 @09:29PM (#33903342)
Speaking language agnostically… If you’re developing prod projects without an IDE, you are likely not being as productive as you could be. Can you frame a house without a framing nailer? Sure. But why? You’ll spend 30x the time and the quality won’t be as good.

I worked take a second look at IntelliJ and Eclipse; learn the keyboard shortcuts. Modern Java is incredibly well put together.

Re:Java 20: A Sneak Peek on the Panama FFM API by jasmer on Wednesday December 07, 2022 @09:54PM (#33903538)
Java compilation and packaging is actually probably the most clear, well documented of all languages.

Most of the tooling is provided, and it's coherent and robust.

Ultimately - both Maven and Groovy, which are used for production level build and packaging, are a 'weird'. But getting going with them is relatively easy.

Java has introduced the concept of 'Modules' - which if you don't get straight in your head, can be confusing, but ultimately it's not that bad.

Compilation is relatively fast as well.

The 'IDE' tends to 'hide a lot of things' in ugly ways - that is true. All of the JAVA IDEs are weird about that. However - because Java is a well maintained language, the IDE's can be powerful and are actually worthwhile. Jetbrains being one of them.

Sadly, Java on VSCode is a bit of a mess.

On Android, Google has introduced a bunch of odd conventions and complexities which I feel are unnecessary.

Re:Java 20: A Sneak Peek on the Panama FFM API by kitd on Thursday December 08, 2022 @03:03AM (#33905484)
There's a project called JBang that aims to provide a much simpler DX when working with Java projects. For basic projects, the experience is almost Go-like.

https://www.jbang.dev/

Re:Java 20: A Sneak Peek on the Panama FFM API by jayd16 on Wednesday December 07, 2022 @06:58PM (#33902165)
There's never magic in computing. Its always ignorance.

...Although I will admit that whether its feasible or useful to demystify the magic varies from case to case.

As for Java, an IDE helps a lot for Java because the build landscape is quite tedious otherwise.

Re:Java 20: A Sneak Peek on the Panama FFM API by plandis on Thursday December 08, 2022 @12:47AM (#33904644)
> Or am I just confessing ignorance and this isn’t a thing and it’s no more complex and magical than Rust or JavaScript or Python?

If anything I’d say JS has a more complex configuration story than Java.

Re:Java 20: A Sneak Peek on the Panama FFM API by therealeskaton on Wednesday December 07, 2022 @09:23PM (#33903293)
Of course you can use Java with an editor like Vim or Emacs for simple projects but I would advise to use an IDE like IntelliJ IDEA for bigger projects, e.g. for its support for refactoring. As a statically typed language the benefit of an IDE will be much better than for Python or JavaScript. The same is true for Rust. An IDE helped me to get much more productive because it can show the inferred types without invoking the compiler all the times.
Re:Java 20: A Sneak Peek on the Panama FFM API by simpsond on Wednesday December 07, 2022 @06:59PM (#33902167)
You can use a text editor. I’d look at the hello world Java application to see how simple it can be. It’s the frameworks that are responsible for config files, generated code, etc. That said, it’s much easier to manage large applications with an IDE.
Re:Java 20: A Sneak Peek on the Panama FFM API by sonicgear1 on Thursday December 08, 2022 @03:16AM (#33905568)
Java is just a painful language. At that level of abstraction you would expect to work purely on business logic, yet Java makes you just focus on the boilerplate and lacks completely basic features such as tuples, real generics, async/await, anonymous types and more. Spring is another huge pain point, it's slow and verbose in comparison to Go or even .NET. Java is not even close to Kotlin, that's why it was invented in the first place, to not make you want to shoot yourself in the head. Needless to say, I don't see any real use of Java in 2022 and beyond.
Re:Java 20: A Sneak Peek on the Panama FFM API by kaba0 on Thursday December 08, 2022 @11:07AM (#33909437)
So decide, if you want to work on business logic, why do you want to further dig your grave with async/await, which is by definition an implementation detail?

Also, sprint is not slow at all, especially that servers are very famously IO-heavy. Nonetheless, you can expect better performance for these with project loom.

Re:Java 20: A Sneak Peek on the Panama FFM API by BenoitP on Thursday December 08, 2022 @05:06AM (#33906250)
> lacks [...] async/await

I'll take that a a major plus. Sometimes things are improved by what is taken away.

> I don't see any real use of Java in 2022 and beyond.

Well, you see what you see; and the cloud infrastructures sees what it sees.

Re:Java 20: A Sneak Peek on the Panama FFM API by ramranch on Wednesday December 07, 2022 @07:34PM (#33902492)
As a Rust fan, it is not a great experience without an IDE
Re:Java 20: A Sneak Peek on the Panama FFM API by speed_spread on Wednesday December 07, 2022 @08:35PM (#33902959)
Statically typed languages gain a lot by having an editor that understands the code at hand.
Re:Java 20: A Sneak Peek on the Panama FFM API by tonto on Wednesday December 07, 2022 @09:34PM (#33903384)
Just a random note but LSP (language server protocol) support in e.g. vim/neovim allows IDE-like features in a "plain old text editor"
Re:Java 20: A Sneak Peek on the Panama FFM API by throwaway2037 on Wednesday December 07, 2022 @08:21PM (#33902861)
What languages do you normally use? And what editor/IDE? It might help to have points of reference for comparison.
Re:Java 20: A Sneak Peek on the Panama FFM API by foolfoolz on Wednesday December 07, 2022 @07:46PM (#33902601)
using a text editor instead of an IDE is actively sabotaging your own productivity in any language