Live data from Hacker News

Don’t call it a comeback: Java is still champ

github.com

471–480 of 557 posts

Re: Don’t call it a comeback: Java is still champ

#471
post #405

Earlier quoted context omitted.

Low pauses, low memory overhead, low CPU overhead. In Java world, pick one. In C/C++/Rust/Zig you can have all three at once.

Malloc and friends have much more CPU overhead than a modern GC, so if you do choose all of these, brace yourself to a really micromanaged programming.

That's a common wisdom, but there is little if any evidence to support it. True GC costs are simply more hidden and harder to measure. A malloc/free pair might be slightly slower than Java's new (not by much really - go measure), but invoking `new` is not the only cost of GC.

https://arxiv.org/abs/2112.07880

Also modern low pause GCs have way higher CPU overhead than the old STW ones. Try to set a low pause GC pause target to 0.1 ms or set the heap limit to 110% of live memory and see what happens to CPU consumption. Last time I tried, the app didn't even start - got OOM nearly instantly. There is a reason the study above measures at 3x oversized heap.

The cost of GC is lower than malloc/free only if you give it a lot more memory than you actually need. Which in many cases is a good tradeoff to make, but it is good to know such tradeoff between memory and CPU exists.

And finally there is one more thing that's not particularly a trait of GC, but rather a limitation of current Java - it is much easier to write a C++/Rust program with low number of heap allocations than in Java. The fact that malloc is slightly slower does not matter if you invoked it 10x less frequently.

Re: Don’t call it a comeback: Java is still champ

#472
post #455

Earlier quoted context omitted.

MS still controls it in practice, and MS is still playing a complicated game with Linux, with goals that have nothing to do with "MS <3 Linux".

Yes, the scandalous SCO lawsuit and subsequent Linux patent racket make it impossible to believe M$'s Linux fud.

What

Re: Don’t call it a comeback: Java is still champ

#474
post #285
post #142

Earlier quoted context omitted.

My main problem with Java is that it's picky, and has some static typing, but it also has heaps and heaps of loopholes in the type system (that turn into runtime exceptions), so it's this weird compromise where everything is substandard. I've found that Go "feels" a lot more like a dynamically typed language, but still has the good IDE support that you're talking about. If you want to see how much progress there has…

> In addition to being memory safe without a GC, the compiler also confirms that your code is threadsafe. No, not at all. Rust verifies that your code has no data-races . That is an absolutely tiny subset of all race conditions, that are simply not verifiable statically.

Data races, in my experience, are not a particularly small subset of practical race conditions, particularly in Rust which tends to shy away from unnecessary mutable aliasing. YMMV of course.

Re: Don’t call it a comeback: Java is still champ

#475

Earlier quoted context omitted.

I don't think this is an issue with Java, it's an issue with Spring. I'm baffled by the popularity of Spring.

I think it depends a lot on where you work and what sorts of projects you work on. I've been programming professionally in Java for the last 16 years and I have never encountered Spring. Nor do I typically see the stereotypical sort of FactoryFactoryManagerImpl complexity bloat. It is something you need to watch out for and steer clear of, in particular when selecting frameworks / libraries, but you can definitely li…

> I think it depends a lot on where you work and what sorts of projects you work on.

Agreed, even if my experience has been the exact opposite of yours. I've seen Spring be used in my country a lot, although recently Spring Boot.

On one hand, I really dislike how code is sometimes exchanged for annotations that cannot be debugged with breakpoints easily (unless you dig in to the code where the breakpoint is defined and then come up with breakpoint conditions that are triggered exactly for your code, but not the other 500 places in your app where that annotation is used) and don't allow for easy customization (vs just changing a few lines of code in the actual method body), or sometimes just don't work altogether (e.g. trying to log method execution times with something like AOP, which didn't work with Spring calls sometimes).

On the other, it's better than some of the in-house frameworks that I've seen, with sparse comments written in Lithuanian (which I really don't speak) and just bad in most respects. Honestly, most off the shelf open source frameworks/libraries that are actively supported should be good enough, be it Quarkus, Dropwizard, or something else entirely. Though at least something that's widely known and has lots of questions and answers surrounding common use cases in places like the documentation and StackOverflow. Otherwise, you're in for a bad time.

Re: Don’t call it a comeback: Java is still champ

#476

Earlier quoted context omitted.

I think it depends a lot on where you work and what sorts of projects you work on. I've been programming professionally in Java for the last 16 years and I have never encountered Spring. Nor do I typically see the stereotypical sort of FactoryFactoryManagerImpl complexity bloat. It is something you need to watch out for and steer clear of, in particular when selecting frameworks / libraries, but you can definitely li…

> I think it depends a lot on where you work and what sorts of projects you work on. Agreed, even if my experience has been the exact opposite of yours. I've seen Spring be used in my country a lot, although recently Spring Boot. On one hand, I really dislike how code is sometimes exchanged for annotations that cannot be debugged with breakpoints easily (unless you dig in to the code where the breakpoint is defined a…

> comments in Lithuanin

As a polish-russian lithuanian I do read Lithuanian, russian and bits of polish but... it really is super surprising to see how people abuse unicode-encoded source code. Linux drivers with comments in Chinese are evil!

Re: Don’t call it a comeback: Java is still champ

#477
post #409

Earlier quoted context omitted.

Well, then consider deterministic failing a plus, as your C program may just continue along silently, with corrupted application state, and you might never learn of the problem (you are not likely to meet truly nullptr null pointers, they are just likely uninitialized, where all bets are off whether they are valid addresses) Being able to handle it correctly is just an additional benefit.

Ok, but now you're speaking about a different thing - memory safety. And that is an obvious advantage of Java over C. But C is a very low bar to compare to. There are dozens of other languages which are memory safe and some of them offer stronger guarantees than Java. Your Java program may continue along silently, with corrupted application state, because it invoked a race condition, and you might never learn of the…

But even race conditions are well-defined in Java: you can’t get so called out-of-thin-air values. Some updates may not be visible from another thread, and of course dead/live locks are on the table (but they are everywhere, even the actor model doesn’t solve those).

Re: Don’t call it a comeback: Java is still champ

#478
post #27

The only problem Java has is experienced C programmers don't build servers from scratch with it yet. Once they take that responsibility, the debate will be over because: "While I'm on the topic of concurrency I should mention my far too brief chat with Doug Lea. He commented that multi-threaded Java these days far outperforms C, due to the memory management and a garbage collector. If I recall correctly he said "only…

Reading your message brought flashbacks of 2006, when C and C++ programmers were politely but passionately explaining to Java programmers why the Java ecosystem was a hopeless pile of bloat.

I would have thought that in 2022 the failure of Java to conquer any kind of market on the most popular platforms and 2nd most popular or any kind of popular plus the rise of languages like Swift, Go or Rust would have made that point perfectly if not painfully clear. Even in Android, Java’s big success story, both the VM and the language were either outright replaced or made legacy.

I suppose it’s a matter of perspective, but I like to think of the server not as Java’s last kingdom, but more as Java’s last refuge before being finally banished.

Note that I don’t dislike Java. I’ve used it successfully on Android and it helped us achieve our goals of writing a passably performant application. Neither do I think it’s a bad technology, like many would argue. It is very uninspiring and bureaucratic though…

Re: Don’t call it a comeback: Java is still champ

#479

Earlier quoted context omitted.

Old school xml based Spring is horrible and if that was your only exposure, I understand your aversion. But spring-boot has an almost zen like quality once you get that it favor convention over configuration. When I was a Java developer, I'd usually use spring-boot with the following dependencies to make the experience better: - lombok: to generate the boilerplate: constructors, getters, setters, equals, hashcode...…

Sorry, but the popularity of tools which generate boilerplate for you is, in my opinion, one of the biggest indictments of the whole ecosystem.

> Sorry, but the popularity of tools which generate boilerplate for you is, in my opinion, one of the biggest indictments of the whole ecosystem.

I couldn't disagree more. I can understand disliking the fact that we need getters/setters in the first place, or perhaps dynamic things like annotations which aren't "normal" code, but static code generation is something that the industry absolutely should embrace.

Model driven development should be more common.

For example, if you can just draw a few ER diagrams and have MySQL Workbench forward engineer SQL migrations for you to check them over (especially if you need to change 20 tables), why shouldn't you take advantage of that? Having a model of your schema that you can generate from the live schema and then transform it into either a set of fresh migrations or just a delta for bringing an older schema version up to date.

I've actually used these two approaches to save bunches of time for personal projects in the past, even though I took the SQL output and put it into dbmate migration tool.

  Reverse engineer: https://dev.mysql.com/doc/workbench/en/wb-reverse-engineer-create-script.html
  Forward engineer: https://dev.mysql.com/doc/workbench/en/wb-forward-engineering-sql-scripts.html
But databases are just one example. Remember SOAP?

Despite being hard to use, one of the best points of SOAP was WSDL - Web Services Definition Language files which allowed you to have a fully functional description of a particular API contained in a single file. Back when REST started replacing it, there was also WADL, but that didn't really go anywhere. The claim that web service endpoints (REST or otherwise) should be largely dynamic/schemaless is basically a lie, because in most languages you'll indeed want to work with particular fields for the objects that you expect to be returned, or domain classes that shouldn't be that different in practice from what you expect.

The beauty of WSDL was that you could get the file from a live version of an API, feed it into something like SoapUI and get a fully working API client, upon which you could build a test suite. Or even better, generate client code for your language of choice, so instead of making HTTP calls and wondering about how to initialize the client, you could start using library code much sooner, with parameters and methods already created for you.

Some time later, OpenAPI came along, but the wisdom of SOAP was basically lost, since it took a while for projects like OpenAPI Generator to pop up and even now the approach of generating client (or even server!) code based on some specification seems to be utterly lost on the industry.

  WSDL: https://en.wikipedia.org/wiki/Web_Services_Description_Language
  WADL: https://en.wikipedia.org/wiki/Web_Application_Description_Language
  SoapUI: https://www.soapui.org/
  OpenAPI: https://en.wikipedia.org/wiki/OpenAPI_Specification
  OpenAPI Generator: https://openapi-generator.tech/
Want more examples? What about database schemas and mapping them to your ORM/other persistence layer solution? I think if you're writing your own model code, you're doing something wrong, regardless of the language that you use. You'll probably mess up or miss relation mapping with something like Hibernate, will miss out on some comments for autocomplete in Laravel and just generally will have an inconsistent persistence layer that will make you waste time.

In most cases, starting with the schema first and using one of the available generation solutions to fill in the application side of the persistence layer seems like the only sane options. Sure, some might prefer to handle migrations in the app side, like Ruby's Active Record Migrations, or something like Liquibase, which are also passable approaches, as long as you don't create a bad schema just so it fits your application.

  Java JPA entity generator example: https://github.com/smartnews/jpa-entity-generator
  Java generator to get DDL from JPA: https://github.com/Devskiller/jpa2ddl
  PHP (Laravel) generator to get models from schema: https://github.com/krlove/eloquent-model-generator
  Ruby Active Record Migrations: https://guides.rubyonrails.org/active_record_migrations.html
In most cases, when you integrate two systems, APIs or just bits of code, one side should be the source of truth and the other should match it as closely as possible (problems with data types aside). Somehow the industry doesn't really know how to do this well, though thankfully projects like gRPC prove that it's perfectly doable in a modern setting.

When this isn't done, you end up with either technologies that are a bit too green to be used successfully (e.g. picking GraphQL to supposedly deal with dynamic data and then being a month late with actually shipping), or having to waste your own time writing "boilerplate" that you will actually need, because although it could and should be generated, it is actually needed (to query that API, access that database, migrate that schema).

I do agree in regards to the pointless Spring XML boilerplate, which is indeed useless.

Re: Don’t call it a comeback: Java is still champ

#480

Earlier quoted context omitted.

> I once worked on a Java-based server at Google This is kind of a fair comment, but kind of not, because Java performance and GC internals have really advanced a lot in the last decade. It would really help if you qualified approximately when this was. > Sadly the garbage collection debate is full of people who want GC to be the answer to everything Good point. I think more recently, the Java world is very aware of…

I agree with all this. Java is a great application programming language. But bullen was arguing that Java is the best for servers of all types, which is what I object to.

If one considers applications as GUI programs running on consumer hardware like desktops, laptops or smartphones Java is in reality not at all great at this task. It’s better than Rust sure, but definitely worse than C++, C#, Swift or Objective-C which have access to the native UI frameworks of their respective platforms.

I’ve had the opportunity to observe Java’s floundering in this area for a couple of decades now and the only decent Java application that I can tolerate is an IDE from Jetbrains. I’m not happy with the performance or UI, but the alternatives are often worse, because in an unexpected twist they’re written in JavaScript.

Post reply on HN