Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Whatever Java is doing seems a few orders of magnitude smoother and saner than C++ (and I like C++).


It depends on how you look at it.

C++ is very different since it is native.

Java is a VM.

This affects lots of decisions in weird ways.

But in essence both commit to backwards stability at the end.

C++ goes for performance, JVM for a more full-featured bytecode vm, etc. but still.


The JVM goes for performance, too, only with an emphasis on the performance of larger programs. It's designed to address some of the serious performance issues that large C++ programs tend to suffer from (I originally made the switch to Java because it was getting hard to keep the large C++ applications we were working on fast enough; Java does some optimisations that are hard for a C++ compiler).


Well, yes. True that for long-running apps JVM seems to be tuned.

I meant the kind of "perf-to-the-instruction" thst native can generate vs other considerations.


One thing we C++ programmers know, though, is that direct control over instructions helps performance in small programs but can hurt it in larger programs. E.g. it is really hard to enjoy the performance benefits that moving collectors and JITs can bring in large C++ applications.

I am not sure of the real life difference of this. You can tweak C++ a lot, you can make caches, etc your own with memoization and others.

True that you would need to build it by hand and, at that time, maybe it is better to just pick something tried and tested for that use case.


It's not so easy. The pattern you'd want to try and match or beat moving collectors is arenas, and they're really not trivial to use in C++ (or Rust). The only low-level language that supports them well is Zig. But even then, evolution of the program can often require large architectural changes.

So yes, in principle it's possible to match and perhaps somewhat exceed Java's performance in C++, even in large programs (just as, in principle, it's possible to match and exceed C++'s performance in Assembly), but we don't care about what's possible in principle; we care about what we can achieve with the budget we have. Or put another way, C++ has better performance/effort than Assembly, and Java has better performance/effort than C++ in large programs (perhaps not in all domains, but in important ones). The JVM was designed to (among other things) specifically make it easier to overcome some known performance problems that large C++ programs experience.


> we care about what we can achieve with the budget we have

100% agree on this. This is the last driver for everything else in professional environments.

Related: I think C++ safety being driven by profiles and not the Safe C++ stuff that was proposed violates the economic assumption in so many ways that it was the wrong choice for C++.


None of that prevents Java from blowing up their language with complex features. They are somehow able to sit back and work on proposals for years and end up with what makes sense for the language.


One thing the Java architects have said is they let most of the complex feature development happen outside of Java, which is pretty nice.

They let the likes of Kotlin, C#, C++, Scala, Haskell, etc all explore their own little features then they figure out if it could be integrated with Java and what it'd look like.

I really like that approach because it's slow, methodical, and the features typically are very well aligned with Java. None of them feel particularly out of place.

Java's preview system also works pretty well to get these features refined over time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: