Hacker Newsnew | past | comments | ask | show | jobs | submit | noelwelsh's commentslogin

This would be far better without the slop and just the widget with a little bit of explanatory text.

I also have one [1]. It's a good name :-)

[1]: https://github.com/creativescala/gooey


not the maintainer, but at first I thought it was python :D

https://github.com/chriskiehl/Gooey


I've always loved this project, I've used it a lot for making my scripts into internal tools for everyone in the team, even non-technical staff

We need to make a gooey family of UI frameworks!

Interesting project, but needs documentation. In particular, what's the model it uses? I.e. how are events, state, etc. handled? Normally I'd just work it out from the code examples, but the example in the README is over 200 lines which is too long for me.

(Don't tell me here. Make your docs better, so everyone benefits!)


The JVM is currently pretty bad for memory allocation. Every object (i.e. not a primitive) has a header that IIRC is 12 bytes. But there is good news in JVM land: this will be reduced to 8 bytes in the next JVM release, and Project Valhalla will give the tools to do away with headers entirely in some cases. Project Valhalla also has tools to manage off-heap memory, which is important in many cases.

The JVM is an odd place where it requires too much heap to compete with the AOT compiled languages, but its startup time is too slow compared to interpreted languages. I think these enhancements are essential to keep the platform relevant.


> Every object (i.e. not a primitive) has a header that IIRC is 12 bytes. But there is good news in JVM land: this will be reduced to 8 bytes in the next JVM release

Since JDK 25 it's already 64 bits with the `-XX:+UseCompactObjectHeaders` flag [1], but in JDK 27 it will be the default [2].

> where it requires too much heap to compete with the AOT compiled languages

Not to compete but to beat, and not too much, but the right amount. Low level languages are optimised for control, not performance (that control translates to better performance in smaller programs, and to worse performance in larger programs), and their particular constraints prevent them from enjoying certain important optimisations, especially those offered by JIT compilation and moving collectors, which remove some overheads that AOT compilers and free-list allocators incur. Their memory management is forced (by their constraints) to optimise for footprint rather than speed.

There are common misunderstandings about memory management and why moving collectors were created to reduce the CPU overheads of malloc/free, especially in large programs, in exchange for what is effectively free RAM. This is why moving collectors are chosen by the languages that are unconstrained enough to use them and have the resources to implement them (Java, .NET, V8). With the exception of Zig (and even there it requires some effort), it's hard for low level languages to use the basic optimisation that's behind moving collectors. I gave a talk about how moving collectors optimise memory management at the last Java One, and it should be available on YouTube soonish [3].

> but its startup time is too slow compared to interpreted languages

That hasn't been the case for some time. You are right, though, that startup/warmup time is worse than in AOT compiled languages, and that is the tradeoff of optimising JITs: reduce the overheads associated with AOT compilation in large program in exchange for warmup.

Both startup and warmup have already been improved thanks to Project Leyden's "AOT cache" [4], but it will never be as low as C.

In general, the tradeoff is between optimisations that help large programs vs optimisations that help small programs.

[1]: https://openjdk.org/jeps/519

[2]: https://openjdk.org/jeps/534

[3]: I can't reproduce the full talk (which goes into the maths of memory management) here but what happened with moving collectors was that until very recently (open source low-latency moving collectors are newer than ChatGPT), they required pauses and so weren't suitable for programs requiring low latencies. As a result, many developers either forgot or never learnt just how incredibly efficient moving collectors are. But the key is that because accessing RAM by necessity requires CPU, using CPU effectively captures RAM even it's not used by the program. Bringing the CPU and RAM usage into a good balance is more efficient than trying to minimise one or the other. This is also the reason why hardware (physical or virtual) is packaged within a very narrow band of RAM/core ratio.

[4]: https://www.youtube.com/watch


    In general, the tradeoff is between optimisations that help large programs vs optimisations that help small programs.
Do you have concrete examples of large scale Java programs that are significantly more performant than comparable programs in native languages like C++? My understanding was that this dynamic hadn't fundamentally changed much since the 2010s, when Java was able to occasionally edge out a win in 1-2 benchmarks and would lose handily in others. My experience is that large scale Java programs remain a bit of a bear even after significant optimization effort (e.g. Bazel).

There are of course plenty of optimizations the JVM does that aren't possible AOT, but that that doesn't imply an automatic win at large scales, as Rust demonstrates.


> Do you have concrete examples of large scale Java programs that are significantly more performant than comparable programs in native languages like C++?

Yes. I was working in a place that made large sensor-fusion applications, air-traffic control applications, and logistical planning, each in the 2-8MLOC range. Over time, we ported all of them from C++ to Java because C++'s performance overheads were too annoying to work around.

Of course, in principle it's always possible to match and perhaps even exceed Java's performance in a low-level language, but in practice it becomes ever more difficult as the program grows (and the cost remains with maintenance forever). The reason is that as programs grow, patterns become less regular (e.g. the variance in object lifetimes grows), the need for concurrency grows (and so the need for sharing objects among threads and for lock free data structures), and more general constructs are used (e.g. more dynamic dispatch). Improvements in modern allocators, as well as LTO and PGO have helped, but not enough to match the extent of optimisations you can do once you're free of the design constraints of low-level control and the focus on the worst case.

Java's thesis (not initially, but from very early on) was to rely on optimisations that can't be effectively employed by low-level languages because of their constraints, such as efficient memory management that benefits from being able to move most pointers in a program, and highly aggressive speculative optimisations (that are nondeterministic and can fail, resulting in deoptimisation). These optimisations tend to be global, and so they don't restrict program structure much, keeping maintenance costs lower, but they do help the average case at the cost of harming the worst case, which is a tradeoff that programs written in low-level languages don't want, and of course, it doesn't give the low-level control that's the entire point of low-level languages. Proving that thesis took a while, and longer in some aspects than others (moving collectors that don't pause were first released to a wide audience three years ago).

Of course, the differences aren't huge because the hot paths are typically small enough that they can be improved without adding too much cost (and hot paths require some manual optimisation in all languages), but gaining some performance as a side effect of significantly lowering costs is nice.

> There are of course plenty of optimizations the JVM does that aren't possible AOT, but that that doesn't imply an automatic win at large scales, as Rust demonstrates.

I don't know what it is that Rust demonstrates given how few large scale projects have chosen it, but I've seen nothing to indicate that it doesn't suffer from the same performance issues as C++ compared to Java. In fact, someone I know who works at one of the world's largest tech companies told me that his team lead really wanted to do something in Rust, so they ported a small-to-medium service from Java to Rust. The result was such a huge performance drop that it wouldn't meet their minimum requirements. They were then forced to spend an additional 6 to 12 months carefully hand-optimising their Rust code until it matches Java's performance, but the result is such that all future maintenance will be more expensive. This is the exact same pattern I've seen with C++.

It's interesting that 20 years ago the people who said Java can't beat C++ on performance were experienced low-level programmers who had little or no experience with Java (and they were also right on several axes at the time). Today the people who say that are those with little experience with low-level languages (and are under the impression that low level languages are universally fast), but they will eventually learn about their fundamental performance issues just as we did decades ago.

I think that Rust in particular has made people without much experience in low-level programming (among which Rust has made much more inroads than among those with a lot of experience in low-level programming) believe a certain story, namely that the problem with low level languages was memory safety and that that was the reason so many large programs switched to Java despite the performance sacrifices they had to make. Now that Rust fixes that problem, they can have their cake and eat it too! In reality, memory safety was indeed one of the several significant problems with low level languages that Java sought to fix, but another was the performance issues low level languages suffer from as they get large (making good performance ever more costly). The tradeoff isn't performance (in large programs there might even be a performance gain) but low-level control, as that is what low-level languages are about. That was what they offered back then, and it's still what they offer now. Rust was first designed twenty years ago, back when things still looked a certain way (which is why, IMO, it repeated most of C++'s design mistakes), but these days I think that a better, more modern design of low-level languages is more focused on control, leaving large programs to high-level languages. Lack of memory safety has, without a doubt, been one of the things that made low-level languages less palatable to "ordinary" applications, but it was far from the only one.

Anyway, I'm sure the debate of which is faster, C++ (/Rust/Zig) or Java, will continue, and frankly, due to the nature of modern hardware, compiler, and runtime optimisations these days (when the question of the cost of some individual operation is all but meaningless and out ability to extrapolate from the performance of one program to another is close to nil), it largely comes down to empirical questions such as which program patterns are more or less common in the field and in which domains, as there are code and workload patterns that could give an advantage to either one.


”they ported a small-to-medium service from Java to Rust. The result was such a huge performance drop that it wouldn't meet their minimum requirements”

That result would say less about performance of languages than it would about competency of developers with a language.

I just don’t buy that a task could be assigned to two teams with comparable expertise and domain knowledge in Rust and Java, and have the Rust result be at a “huge” performance deficit.

No, don’t believe that was an apples to apples comparison.


It may well be the case that it's not an apples-to-apples comparison, but as someone with over two decades of experience in both Java and C++, I find it not only unsurprising, but as a case of both Java and Rust doing exactly what they're designed to do.

Rust is designed to be a low-level language, i.e. a language with maximal control with all of its pros and cons (albeit with memory safety, which C++ doesn't have), while Java is designed to address the performance issues low level languages have, particularly as they get larger, due to their control constraints. Without such constraints, it is easier to offer better performance for less effort especially as programs grow.

In that particular program I was told that the differences were due to needing more locks in the Rust version. As has always been the case, they managed to achieve parity with much more effort (that is expected to continue over the lifetime of the software), but again, this is the explicit tradeoff of the approaches.

Thirty years ago, and even twenty years ago (when Rust was first being designed) many still believed that more control is the only path to good performance, even if it comes with a lot of effort. Today it's clear that it's not the only path, and the debate is mostly around which program and workload patterns that happen to work better with one approach or the other are more common.


> That result would say less about performance of languages than it would about competency of developers with a language.

> B-b-but skill issue!

That's one of the dimensions of the language too. Not only raw performance matters.


    I don't know what it is that Rust demonstrates given that few large scale projects have chosen it, but I've seen nothing to indicate that it doesn't suffer from the same performance issues as C++ compared to Java. 
The point of bringing up Rust is that it also gives the compiler much more information to optimize on than C++, but actual performance is comparable or slightly worse in most benchmarks because the quality of C++ codegen is so high. Some of those Rust advantages are exactly the same things that have been touted as major advantages for Java over C++, like escape analysis and lifetimes.

    Of course, in principle it's always possible to match and perhaps even exceed Java's performance in a low-level language, but in practice it becomes ever more difficult as the program grows (and the cost remains with maintenance forever).
Sure, which is why I asked for real examples of whatever you consider a "large scale" program. I wasn't able to find anything via search before I replied, and the wiki page on Java performance [0] is repeating what I understood.

[0] https://en.wikipedia.org/wiki/Java_performance


> Some of those Rust advantages are exactly the same things that have been touted as major advantages for Java over C++, like escape analysis and lifetimes.

These aren't the biggest advantages. I would say that the biggest ones are aggressive speculative optimisations that allow inlining of virtual calls (by default, up to a depth of 15 calls) and the ability to freely move pointers, which allows alternatives to free-list-based memory management. Low-level languages can't afford pervasive speculative optimisation (as they're focused on the worst case) and can't allow most of their pointers to be moved (because they often share them directly with the hardware and/or device drivers).

> and the wiki page on Java performance [0] is repeating what I understood.

That may be because the information on that page seems to be up to date to 2011-2. Java is now on version 26, BTW.


LLVM does speculative devirtualization as well these days, though it's not as aggressive as Hotspot. High-performance native code tries to avoid deep dynamic hierarchies anyway, so it's mitigated by cultural practices.

GCs are definitely a strong point for Java, but most high-performance code can be rewritten to avoid pummeling memory management. This used to be common for Java in financial applications, not sure if it still is.

C++ has evolved its own compacting GCs like oilpan [0] for applications where high performance is inherently tied to allocation. Oilpan runs into pointer issues and isn't remotely comparable to G1GC or ZGC, but I think the speed of V8 speaks for itself. Rust allows you to drop in non free-list based allocators and GCs (e.g. Bumpalo), but they're relatively immature.

    That may be because the information on that page seems to be up to date to 2011-2. Java is now on version 26, BTW.
The last time I dove into JVM internals was around the same time. I figured that someone who's worked with it more recently might have better examples than what's easily searchable.

[0] https://chromium.googlesource.com/v8/v8/+/main/include/cppgc...


> LLVM does speculative devirtualization as well these days, though it's not as aggressive as Hotspot. High-performance native code tries to avoid deep dynamic hierarchies anyway, so it's mitigated by cultural practices.

Sure, AOT compilation also didn't stand still, and overall I'd say that Java and low level languages are closer today than they were 20 or even 10 years ago on all fronts: both have improved in areas where they were behind.

> This used to be common for Java in financial applications, not sure if it still is.

Given that low-latency collectors are only 3 years old, I'm sure some existing Java applications still do it, but new ones no longer need to (and it may turn out to be counterproductive with the new collectors)

> Rust allows you to drop in non free-list based allocators and GCs (e.g. Bumpalo), but they're relatively immature.

The problem isn't the immaturity but the integration with the standard library that requires significant code changes (e.g. you need to use different string and collection implementations). However, even where there is good integration - as in the case of Zig - arenas impose limitations (due to the care that needs to be given to lifetime) that make the program less flexible. But yes, when all the stars are aligned, arenas can beat moving collectors (that's about the only thing that can), but moving collectors aren't standing still and resting on their laurels, either.

> I figured that someone who's worked with it more recently might have better examples than what's easily searchable.

I don't know about a single unified resource, but you can find everything here: https://openjdk.org/jeps/0

JIT improvements are usually too low-level to merit a JEP, but all the major GC changes are there. For a taste of what's going on in the JIT these days, see this recent talk: https://youtu.be/J4O5h3xpIY8


Slightly off topic -- java-related wiki pages are notoriously bad and possibly biased for some reason. They are laughably outdated and have a bunch of non-objective sentences that paint a much worse picture of the language than deserved.

I have even tried removing/rewriting some of the questionable sentences but my edits weren't accepted.


I’ve done performance-engineering for decades in Java, C++, and C for both data analytics and supercomputing/HPC. Java performs significantly worse than C++ in all cases without exception. This is the result you should expect from first principles; something has gone horribly wrong with your software optimization if Java is faster than C++ or even Rust.

There are good reasons to use Java in environments that care about performance. Absolute performance can be traded for other concerns while still being good. It is why I did so much performance-engineering work in the language.

Most performance is architectural in nature. Extremely granular control of scheduling is a prerequisite. System languages provide that control if you want it, Java does not.

When you design software in Java, you accept that some software architectures are not available to you. If you care about performance, you would not port a software architecture optimized around the limitations of Java to a systems language.


> I’ve done performance-engineering for decades in Java, C++, and C for both data analytics and supercomputing/HPC. Java performs significantly worse than C++ in all cases without exception.

I've done similar work (not supercomputing/HPC, but yes for soft and hard realtime software, including safety-critical software) and I couldn't disagree more. Of course, we didn't get to write every program in both Java and C++, but the main question was how much effort it took to achieve the required performance. Over multiple projects it was clear that hitting the performance targets was, on the whole, significantly easier in Java.

> This is the result you should expect from first principles; something has gone horribly wrong with your software optimization if Java is faster than C++ or even Rust.

Strong disagreement here, but we need to be specific about what we mean when we say performance.

It is undoubtedly true that for every Java program there exists a C++ program with the same performance, and the proof is simple: every Java program is a C++ program with the classes being input. But that C++ program is close to 2MLOC long. The same could also be said about a C++ program vs. an Assembly program, as every C++ program could be written as an Assembly program.

But when I talk about performance, I refer to what I think most programmers care about when it comes to performance. Not how fast can a program hypothetically be given enough effort and expertise, but how fast can my program be in my budget.

Both speculative compiler optimisations and memory management optimisations are simply not an option for low level languages due to their constraints, and they are very powerful global optimisations. Given a lot of expertise and effort (that must continue throughout the software's lifetime, and often increases as it evolves) you can work around these limitations, but Java was designed so that you can benefit from them, which means more performance per unit of effort.

In large programs more general constructs (e.g. dynamic dispatch) and patterns (concurrency, great variance in object lifetime) grow in prevalence, and low level languages require more effort and discipline to work around their shortcomings in these areas. Optimising JITs that allow aggressive speculative optimisations and moving collectors were invented and adopted to address these shortcomings. You could claim that the advanced mechanisms that were developed to address C++'s performance issues have failed to achieve their goal, although it won't be easy and much of it comes down to empirical questions of which patterns arise more or less frequently in software, but given that this is what these mechanisms were at least intended to achieve, you certainly can't claim that they fail to do so "from first principles". Some compilation optimisations need speculation; some memory management optimisations need moving pointers. Not having these optimisations available in a program you can write without a lot of special effort cannot make it faster "from first principles".

So no, I don't believe at all that something has to go wrong for a Java program to be faster than a C++ program given a certain budget for the program. Indeed, in larger, more complex programs, I believe the very opposite is true. In most situations, if you get the same performance in C++ as you do in Java, then something has gone terribly wrong with your Java program.

As someone who's worked on a pretty famous JVM feature (virtual threads), I can tell you that we and the designers of low-level languages consciously make different performance tradeoffs because we optimise for different programs and people, and have different preferences when it comes to average case vs. worst case, but there is no universal dominance in performance to either one of these approaches over the other.

One obvious example was our decision to remove Unsafe from Java. Some Java developers voiced opposition, citing a program speed competition (the "one-billion-row challenge" [1]) where Unsafe improved the performance of an entry (which was later cloned and tweaked by others) by 25%. But we saw it as further motivation for the decision. Among over a dozen performance experts who submitted entries, only one was able to write a program efficient enough for Unsafe to make a big difference, and the variance in the results even among the top 20 or so entries was larger than Unsafe's improvement. By removing Unsafe, we would harm that one expert's program, but it would allow us to perform more aggressive constant-folding optimisations that would result in much greater performance improvements over the entire ecosystem. Even from a design philosophy perspective alone, this removal of control to the detriment of some programs "for the greater good" of performance over the entire ecosystem is almost unthinkable in low level languages, because control is what they're for. Did that decision make Java a faster or a slower language? That depends on how you look at performance.

[1]: https://github.com/gunnarmorling/1brc


If what you are saying is correct, the performance of Java has to be the best-kept secret in the industry. Because you are the only person I've ever heard making such claims seriously.

But this looks more like an apples-to-oranges comparison. You might be talking more about performance in complex business logic, while others are talking about performance in computation.

I can imagine that Java could be faster than C++ or Rust (for the same effort) when the number distinct active tasks is large. But in more traditional performance-critical work, such as HPC or video game engines, there are usually only a limited number of distinct combinations of performance-critical tasks that can be active at the same time. Even if the codebase itself is huge, the performance-critical subset is simple, and the performance advantages from increased control over the execution are cheap.


> the performance of Java has to be the best-kept secret in the industry

Is it, though? It's the first language of choice for a large number, if not most performance-critical applications.

> Because you are the only person I've ever heard making such claims seriously.

Your sources must be very limited, then, because in serious compiler and runtime design and memory management circles this is quite common. There is a debate, but it is an empirical one over whether the circumstances that favour Java over C++ are more or less common in practice or vice-versa. And again, given that it's the first language of choice in most performance-critical applications (and even if you don't believe it's number one, surely you agree it's in the top two or three) one or two more people probably think its performance is at least competitive with C++.

> But in more traditional performance-critical work, such as HPC or video game engines, there are usually only a limited number of distinct combinations of performance-critical tasks that can be active at the same time

I wouldn't say HPC and video game engines are "traditional performance critical work". Not because they're not performance critical, but because the range of performance critical programs is far larger - think bank card transaction processing; think mobile phone routing, and there are many more examples (also, AAA video game engines are indeed very traditional in their design and tech choices, but their performance-sensitivity these days is not so much around CPU-related optimisations but about scheduling the GPU, and their tech choices are much more constrained by the consoles they need to support than by performance).


It sounds like we are not even talking about the same thing when we talk about performance.

HPC and video game engines are examples of traditional performance-critical work. Performance-critical, because they typically run in a resource-constrained environment. (If they don't, the user is likely to request the system to do more work.) And traditional, because it's more about algorithmic performance than system performance. The kind of performance people cared about long before computers became capable enough to run complex software systems.

I would not consider card transaction processing performance-critical. The total number of transactions is very low relative to the amount of resources available to process them.

As for Java, it stopped being a general-purpose language a long time ago. Most people who care about the performance of the software they write don't consider it, because almost nobody in their field uses it or talks about it. If it's actually a good choice for performance-sensitive applications in those fields, the people who are using it have done a good job keeping it secret.


You're right, because I certainly don't consider resource-constrained programs to be the only performance-sensitive applications. I consider an application performance-sensitive when it has severe performance requirements (either on throughput or latency or both) that aren't easily or sufficiently met with horizontal scaling. This typically involves situations where high volumes of data must flow and be processed on the same machine (my own journey with Java began when we ported a large C++ application that did distributed, soft-realtime sensor fusion, synchronised with atomic clocks, to Java, and it was very much performance-sensitive).

If you are running in a resource-constrained environment, you might have no choice but to have complete control over hardware resources, in which case you may need to use a low-level language, but your optimisation budget is very high. A different and more common case is where the hardware isn't too resource-constrained, but the performance requirements aren't easily met, either. In these situations, the performance challenge isn't necessarily to optimise at all costs, but to find a way to meet the performance requirement while staying within budget. In these areas, Java has already displaced C++, and continues to be the first language of choice.

Of course, the people who write such applications (in any language) don't often talk about their architecture, but here's one example when they do: https://www.infoq.com/presentations/java-robot-swarms/ In this case, as in many others, the performance requirements are strict (and aren't easily met with horizontal scaling), but the constraint under which they must be met isn't the hardware but the budget and speed of development/evolution.

More often, the performance challenge is how to get the best performance per unit of effort (while meeting the performance requirements, of course) rather than how to get the last 1-5% of performance at any cost. Or sometimes I put this question as not "how fast can a program be?" but "how fast can I practically make my program?"

The optimisations Java offers are precisely intended to maximise the latter, because that's exactly where low-level languages suffer performance shortcomings. They could get that performance or perhaps better with a lot more effort (that needs to be continuously spent throughout the software's lifetime), but many performance-sensitive applications don't have or would rather not spend the time, money, or expertise to do that, and are looking for the best performance per unit of effort.


>I wouldn't say HPC and video game engines are "traditional performance critical work". Not because they're not performance critical, but because the range of performance critical programs is far larger - think bank card transaction processing; think mobile phone routing, and there are many more examples (also, AAA video game engines are indeed very traditional in their design and tech choices, but their performance-sensitivity these days is not so much around CPU-related optimisations but about scheduling the GPU, and their tech choices are much more constrained by the consoles they need to support than by performance).

In "business oriented" contexts, the usual culprits are database access and serialization/communication overheads. If you use Rust with serdes, you get access to one of the fastest ways to turn JSON documents into struct accessible data on the entire planet. The same implementation effort could be spent on any industry specific data formats.

I am struggling to think of any scenarios where Rust is supposed to be uniquely unsuited and Java would have an obvious win to make the broad and sweeping statements you've made.

If everything you said is true, people would be building JVM backends for C++/Rust the same way LLVM has been used as a backend and there would be constant discussions about JVM vs clang vs gcc. It just doesn't add up.


> If you use Rust with serdes, you get access to one of the fastest ways to turn JSON documents into struct accessible data on the entire planet.

Yeah, because most people who choose Rust are those coming from JS, Python, or Ruby, and almost no one has written large systems in Rust yet, I see why you'd think that, because that's indeed the main challenge in the kind of programs normally written in JS, Python, or Ruby. In automation control, the bottleneck isn't the DB; in distributed sensor fusion the bottleneck isn't the DB; in telecom routing the bottleneck isn't the DB (I actually don't know what the bottleneck is in transaction processing, but I'm pretty sure it's not just the DB). These are just some areas where Java is the top choice.

> I am struggling to think of any scenarios where Rust is supposed to be uniquely unsuited and Java would have an obvious win to make the broad and sweeping statements you've made.

In all the same places where Java displaced C++ and continues to do so: large systems. I think few even consider Rust, TBH.

> If everything you said is true, people would be building JVM backends for C++/Rust the same way LLVM has been used as a backend and there would be constant discussions about JVM vs clang vs gcc. It just doesn't add up.

First, Java is far more popular than C++ (let alone Rust), so there would be little point (although there is an LLVM backend for the JVM, though I doubt many people use it). The people who want Java's benefits over C++'s benefits have been using Java for a long time now.

Second, you can't have a JVM backend for C++ and Rust and fully enjoy the performance benefits of Java, because the JVM's optimisations are enabled by the language not having the constraints that low-level languages have. The people who just need the performance choose Java anyway, and the people who choose low-level language choose them because they need the control the JVM doesn't offer.


Low level CPU-related optimisation is absolutely still a thing. The GPU is always filled to the brim trying to get as much quality out of a graphics frame so a lot gets offloaded to the CPU. When I was doing this I was doing a lot of low-level CPU optimisation. GPU optimisation was usually more about transform process topology but there was plenty of low-level work to do there too.

Games are both high throughput AND low-latency and C++ is still king there


C++ is no doubt king in games (for reasons that aren't necessarily primarily performance [1]), but not only are there plenty of high-throughput low-latency applications in C++, I believe there are more than in C++.

BTW, "low latency" is relative, and in most games the relevant latency is the frame, which is usually between 5-15 ms. I worked at a place that did large low-latency software, some soft realtime and some safety-critical hard realtime, where the cutoff between Java and low-level was whether the required latency was under 10us (tha's microseconds!). That's an order of magnitude below what's in games. We did use specialised versions of Java (and specialised kernels), but these days, on normal OSes and plain Java, the cutoff is usually around 1-3ms (although at that point you often need special kernels anyway).

Something that C++ people often don't know is that there's nothing in Java that makes it any harder to compile and run with optimisations at least as good as those offered by C++, but the opposite isn't the case: there are fundamental problems that make it hard to perform some optimisations in C++. Of course, the tradeoff is predictability. Some aggressive optimisations require speculation, which means a fallback to deoptimised (even interpreted) code and then recompilation. I pure compilation and memory management terms, Java has the advantage, but it aims to make the average-case faster than C++ at the expense of the worst case.

[1]: E.g. AAA games are extremely conservative when it comes to technology choices; more conservative than even the military. AAA games often need to target limited consoles where there are few alternatives to C++ available.


I'm a Java developer now, amongst other languages. The advantage of Java is that it takes A LOT less time to develop something, so there is the whole bang for buck for sure. I have had a few problems where I would love shared direct memory access and some atomics (because it would be a lot easier). But for the most part developing in Java is a lot quicker.

I don't think game developers are more conservative than any other developers. We do have large C++ codebases and so it's hard to change.

All modern engines have a few scripting languages tacked on too.

Something like Lua usually is the sweet spot: most of the people developing scripts are not developers. We even had a Java interpreter for scripting once, but it lost favor for this reason.

There were exceptions, but I found that developers generally preferred C# over Java anyway. Our assets pipelines are generally in C# already.

Any speculative optimisation we were doing by hand. There is the whole deferring allocations / moving allocations, both of which we were already doing (e.g. copying every frame).

A lot of our C++ code is intrinsics (including memory primitives like _mm_stream_ps and barriers) and you HAVE to have good control over how memory is laid out (e.g. knowing that data is split between cache lines so that you you don't get contention). Lots of spin locks too. I just don't see how you can do this kind of low level work in Java.


> A lot of our C++ code is intrinsics (including memory primitives like _mm_stream_ps and barriers)

Java has such intrinsicts, too: https://docs.oracle.com/en/java/javase/25/docs/api/java.base.... They may not look like intrinsics that compile to a single machine instruction, but the are (I don't think we offer stream access, simply because there hasn't been demand for it; if there is, we can add it. I actually added a streaming array copy to the JVM because I thought I could use it for something, but the results weren't what I expected, so I took it out)

BTW, here's a list of our intrinsics:

https://github.com/openjdk/jdk/blob/master/src/hotspot/share...

As you might notice, they include SIMD intrinsics offered through https://docs.oracle.com/en/java/javase/25/docs/api/jdk.incub...

> and you HAVE to have good control over how memory is laid out (e.g. knowing that data is split between cache lines so that you don't get contention)

We have the `@Contended` annotation precisely for that: https://github.com/openjdk/jdk/blob/master/src/java.base/sha... You have to use a flag to tell the JVM to respect this annotation, but the people who write high performance code know this: https://www.baeldung.com/java-false-sharing-contended

> Lots of spin locks too.

We have an intrinsic for spin locks: Thread.onSpinWait() https://docs.oracle.com/en/java/javase/25/docs/api/java.base...()

> I just don't see how you can do this kind of low level work in Java.

There's no reason you should if you're not writing high performance code in Java, but the people who write such code in Java know how to do these things in Java.

To be clear, Java certainly doesn't offer as much precise control as a low-level language, but it does offer everything you need for high performance (except array-of-struct, but that will arrive soon). The reason for that is that there's high demand for these constructs because so much of the worlds performance-sensitive software is written in Java. Traditionally, not games (which often have to run on platforms for which we don't offer Java) but manufacturing automation, defence, and trading.

> There is the whole deferring allocations / moving allocations, both of which we were already doing (e.g. copying every frame).

Yes, you can certainly do some memory management optimisations in C++, although with some effort (it's especially hard to use some standard library stuff, but when I write high performance code in C++ I don't use std at all). The low-level language that makes it easier is Zig.

> Any speculative optimisation we were doing by hand.

It's hard to do speculative optimisation by hand, unless you're generating code on the fly. The way speculative optimisations work is that we observe that something has been true so far (e.g. think about a specific branch that's always taken or a dynamic dispatch that only hits a certain target at a certain callsite) but the compiler can't prove that it's necessarily true. So we emit machine code that assumes it's true with special traps that would trigger some fault signal if the assumption is invalidated. If the trap is hit, we capture the signal, deoptimise the subroutine and then recompile it differently (without the assumption).

In C++ what I do is do some of the same optimisation results by hand (typically using templates), but of course, they're not speculative and I need to be careful. There's also code size and I-cache implications, but while we try to keep an eye on the I-cache, Java doesn't always get this balance right, either.


I'm not sure I understand what exactly you're talking about. I personally moved away from Java to Rust, because of the obvious and immediate performance benefits and this is possible because Rust manages to stay safe despite the lack of a garbage collector.

I am not GP poster. I find pron points interesting even if I work in the gamedev on game engines. If you don't mind I will try to explain how I see them interesting. Since I have not worked on Rust systems I will stick to C++.

Note his example elsewhere in this discussion of 2 projects done at same time in Java and Rust and the complaint that Rust system used too many locks. This can happen in C++ too. But why it does not happen in (my) practice? Because C++ evolved to not use locks in large scale parallel systems. This was said from mainstage conferences keynotes at least since 2013 [1]. So there is "normal C++" and "C++ that works at large scale" and they are not the same C++ languages. The performance scales between them are many orders of magnitude. Imho it does not mean that Java anywhere near the best of what C++ can do. So here we are talking past each other. pron is correct that Java is not bad and you are correct that you have no reasons to leave Rust.

1. https://sean-parent.stlab.cc/presentations/2013-09-11-cpp-se...


> The performance scales between them are many orders of magnitude. Imho it does not mean that Java anywhere near the best of what C++ can do.

I don't think you're aware of where Java is today. Here's a recent talk about some of the issues we're working on now: https://youtu.be/J4O5h3xpIY8

I said that in the past the people who believed Java can't match or exceed C++'s performance were typically those with a lot of low-level programming experience and little or no experience with Java, while today it's mostly people with little experience with low-level programming, but I think you may be in the first group. To people in that group, the question I pose is: what is exactly that you'd think makes Java harder to compile in an optimised way than C++? That's not hard to answer for JS or Python, but you'll find that it is hard to answer for Java. (I don't have a question to ask the people in the second group because they are typically people who don't know much about software performance to begin with, don't have any informed intuition about it, and just say nonsensical things like "runtime overhead").

On the whole, the range of optimisations available to our compiler is larger than to a C++ compiler, and we have a wider selection of memory management optimisations, too (this matters mostly in large programs with a wide variety of object lifetimes).

So if you were to ask me why I would speculate that C++ can't be as well-optimised as Java, I could tell you that it's because it can't inline as aggressively and it can't move pointers (due to its constraints and intended domains).

I think an answer for why Java wouldn't be as optimised at C++ could refer to things like "Java has an interpreter" (true, but that design was chosen to support more aggressive speculative optimisations in the compiler), or "Java has moving-tracing GCs" (true, and that was chosen because they offer an optimisation of memory management in a wide variety of situations). The JVM was designed to address specific performance shortcoming of low-level languages; true, they don't result in a win in all situations, and in some they even lose, but these mechanisms were chosen because they do win in many situations.

In general, when we (the JVM's developers) see something that C++ can do faster, we treat it as a performance bug and solve it. What John (the chief JVM architect) is talking about is related to the last area where Java suffers (arrays-of-structs) to which we'll start delivering the solution very soon.

There are some intentional performance-related tradeoffs that both our team and the C++/gcc/LLVM teams make, but they are about offering better or worse performance under different circumstances, and definitely not universally.

As an example I was personally involved with, the C++ team and us intentionally chose differenet approaches to coroutines that give better performance in some situations and worse in others, and we both opted to prioritise different situations (i.e. situations where cache misses are more or less likely).

In general, C++ offers better performance than Java in some programs, and the opposite is true in other programs. On average, their performance has come closer over the years, each improving the areas where they were weaker.

As to "the best of what C++ can do", it's hard to define, because, as I said, every Java program can be seen as a C++ program, so technically C++ can always match the performance of a Java program given enough effort and expertise. But when talking about performance, what's practically possible matters much more than what's hypothetically possible, and in those programs where Java wins, achieving the same performance in C++ is just far more costly.

But also, given that both languages can and do come close to the maximal hypothetical hardware performance, they're rarely too far apart (unless we're considering warmup time), and they're both very much "anywhere near" each other almost all the time.


as for my experience, yep I do not have Java experience and a long list of C++ projects.

> what is exactly that you'd think makes Java harder to compile in an optimised way than C++?

In games C++ is doing some simulations and data delivery for GPU. Code that does work on GPU is not mixed with rest of C++ code. So invoking Cuda (or the likes) in the middle of computation is a cheat code that Java does not have. Simulations on the CPU need to be efficiently parallel ( think 12 hardware threads for last gen or 4-6 threads for smaller platforms) and most likely specialized for hardware SIMD ( think AVX2 for last gen or SSE2 like for smaller platforms). To wrangle multi GB data efficiently a lot of compression/decompression and data structures are needed. Does Java still has overhead per class instance? It might force designs with arrays of primitive data types that are more verbose.

Add there per platform I/O and everything. It means that games force people to unlearn everything that language ever thought about standard I/O. Even more about being cross platform. In C++ it means something completely different. In C++ you can't trust language implementation vendor with anything. From your comment I assume that Java teams rely on language implementation in lots of ways. In C++ being efficient means do it yourself. How efficient our memory allocation is? Answer can only be per engine/project. There is no 'average' because 'vendor provided' is the bottom of the barrel quality. No one is improving vendor provided exactly because no one is expected to use it.

In short there are hard to compare many different C++. I can't see them compare to each other much less to other programming languages like Java. This might be not the answer you wanted but that's all I have.


> So invoking Cuda (or the likes) in the middle of computation is a cheat code that Java does not have.

It does (and has since JDK 22). But what we're working on now is JIT-compiling Java code to CUDA (not arbitrary code, but certainly code that's suitable for a kernel): https://openjdk.org/projects/babylon/articles/hat-matmul/hat...

> and most likely specialized for hardware SIMD ( think AVX2 for last gen or SSE2 like for smaller platforms)

Yep, we've had good SIMD support for a few years now. (https://javapro.io/2026/04/09/java-vector-api-faster-vector-...)

> Does Java still has overhead per class instance? It might force designs with arrays of primitive data types that are more verbose.

That is the last area where Java is still behind but the work on arrays-of-structs (with no headers) is nearly complete. A first release of that is imminent.

> In C++ being efficient means do it yourself

Right, and that's precisely what I meant about low-level languages being optimised for control and not performance. You could do things at such a low level in Java, but the main problem is not the performance but that it's just less convenient than in C++.

Anyway, aside from some outdated (or soon-to-be-outdated) things, what you pointed out is mostly about lack of convenient direct low-level control rather than general performance, and that is exactly when low-level languages can be a better fit.


We compiled one of our Java app to native binary using GraalVM (for encyption and secret managment needs). Side effect is the Java native binary performance is excellent, app startup time also significantly less compared to JVM version.

I am not sure how it compares with C++, Rust and Zig, but we made a benchmark with a similar Go binary, Java native version performance (load tests) is similar to Go binary. Only RAM usage of Java native binary is 3 times to Go binary (and JVM app took almost 10 times more RAM than Go version).


The RAM difference is primarily because both Native Image (what you call Graal VM) and Go use much simpler and less efficient memory management techniques. HotSpot uses much more RAM by design as there are inefficiencies caused by using too little of it. Memory management - and especially very sophisticated approaches that are only used by the best resourced teams - is an especially misunderstood aspect.

I gave a talk on the subject that I hope will be published soon, and while I can't reproduce it here, let me give an example that offers some basic intuition. Imagine needing to do some computation in two ways on a machine with 1GB of free RAM. You could run for 10s, taking up 100% CPU and consuming 80MB of RAM, or for 9s, taking up 100% CPU and consuming 800MB of RAM. The second is more efficient, despite taking up 10x more RAM and saving "only" 10% of CPU, regardless of the relative cost of RAM and CPU. This is because taking up 100% of the CPU effectively captures 100% of RAM (as no other program can use it), so both programs capture the entire 1GB only the second one captures it for a second less. This scales to non extreme situations because accessing RAM requires CPU, so using CPU means capturing RAM whether you use it or not. So HotSpot uses it if it can use it to balance the CPU utilisation.

In some situations it may not matter, and I assume that if Native Image and Go work just as well for you, then the workload isn't very high, but under high workloads, this can matter a lot.


> This is because taking up 100% of the CPU effectively captures 100% of RAM

Isn’t that only true though specifically at 100% CPU utilization?

If it were at 90% CPU, then you have no RAM capture, and then you can’t say anything about whether 80 or 800MB should be taken; it’s only a freebie if and only if literally no other program can do work on the machine.

I don’t see how you can map X% CPU utilization to Y% RAM capture.

Like a program could be network heavy, CPU light and mmaps a large file? Or streaming a file from disk with a constant memory allocation, but doing heavy nonstop CPU work.

The CPU / RAM capture ratio would be wildly different; the ideal for your program, while other competing programs of unknown behaviors exist, I don’t see any way for hotspot to approximate


> Isn’t that only true though specifically at 100% CPU utilization?

No. Because any RAM access requires CPU, using up any CPU effectively captures some ability to use RAM.

> I don’t see how you can map X% CPU utilization to Y% RAM capture.

You're right that there isn't a fixed formula, but the most efficient balance can have a narrow range, because CPU and RAM are typically sold as a package with a rather narrow RAM/core ratio (usually between 0.5 and 4GB, where the lower end is usually when you have slow cores). This is also because of the intrinsic relationship of RAM and CPU.

> Like a program could be network heavy, CPU light and mmaps a large file? Or streaming a file from disk with a constant memory allocation, but doing heavy nonstop CPU work.

A program that is very CPU light can't make use of a lot of physical RAM at any one time (again, because using RAM requires CPU). Once exception is caching, but memory access patterns for caching are easily detectable, and you can (and Java does) offer a different balance for them. I covered that in my talk, which will be eventually published on YouTube.


> I covered that in my talk, which will be eventually published on YouTube.

Any idea how I get myself notified once it’s up? Or a YT account to poll


https://www.youtube.com/java

Don't confuse it with the interview about my talk, which is already up, but doesn't cover any of the important details.


>HotSpot uses much more RAM by design as there are inefficiencies caused by using too little of it.

Ah yes, the swapping induced by IntelliJ overflowing my system RAM is supposed to reduce the inefficiencies of using too little memory. Great...

Thanks pron, you've fully bought into all the JVM kool-aid talking points without ever trying to question them. One of the reasons I upgraded to 32 GB RAM in 2019 was to run a Minecraft modpack. Minecraft is one of the most memory intensive games I've ever played.

When you consider that the smallest cloud instances that cost $4 per month only give you like 512 MB of RAM and have refused to upgrade for at least a decade, the idea of using more than 512 MB to be "more efficient" is ridiculous. It raises your minimum costs to $10 per month.

>I gave a talk on the subject that I hope will be published soon, and while I can't reproduce it here, let me give an example that offers some basic intuition.

>Imagine needing to do some computation in two ways on a machine with 1GB of free RAM. You could run for 10s, taking up 100% CPU and consuming 80MB of RAM, or for 9s, taking up 100% CPU and consuming 800MB of RAM.

This is the "wasted RAM is unused RAM" mentality and it doesn't work, because you usually have multiple competing programs and when you run out of RAM, your system will start swapping. This will then require you to buy more RAM, leading to more leftover RAM, which is then wasted and gets consumed by the applications again. It's nonsense.

Then there is the fact that the vast majority, basically 99.9% of algorithms are not scalable in the naive way presented. Nobody will waste resources on writing the same algorithm twice for these two cases. Databases are usually designed to either be primarily file system backed or in-memory backed. They will use the extra memory to hold indices and let the OS do the caching or they will reserve all the memory up front, intentionally leaving nothing for other applications.

>The second is more efficient, despite taking up 10x more RAM and saving "only" 10% of CPU, regardless of the relative cost of RAM and CPU. This is because taking up 100% of the CPU effectively captures 100% of RAM (as no other program can use it), so both programs capture the entire 1GB only the second one captures it for a second less.

Ok, now you're just writing nonsense. Nowadays people have CPUs with multiple cores and use an OS with a scheduler. If you have two programs taking up 100% of the CPU, the OS will give each process some of the hardware resources. You can't just assume some 100% CPU blockage here just because it is convenient for your argument. It's especially dishonest since even a 99% CPU blockage basically makes your argument fall apart completely.

If you have two programs decide to 10x the memory consumption to save one second, you'll most likely run into swapping issues, which will actually lock up your system for several seconds at a time and if you're unlucky, the OOM killer strikes or the compositor freezes up and you have to reboot. You're saying that a 1 second savings is worth an endless amount of inconveniences.

>This scales to non extreme situations because accessing RAM requires CPU, so using CPU means capturing RAM whether you use it or not. So HotSpot uses it if it can use it to balance the CPU utilisation.

Again, this is completely incorrect in so many ways that you're bragging you know nothing about how modern computers work.

CPU cores have their own local memory resources called caches. Depending on how your code is written, you may tile your data so it fits entirely in cache and operate within the local memory.

When performing inter thread communication, there are often situations where the data often doesn't even get written and then loaded to main memory, since atomic operations can make use of the MESI cache coherency protocol to pull the data directly from another cores' cache.

Nowadays DMA is the standard way to perform large data transfers to hardware peripherals. If you load a file from an HDD, the SATA peripheral will communicate via DMA to copy whole sectors or file system blocks. The same applies to sending data to an SSD, network interface, GPU or basically anything else that performs bulk transfers (1 KiB+). The DMA engine is a separate component independent of the CPU and it may write data directly into cache as well.

Then there is the fact that RAM is a form of storage and storage is usually characterized by the fact that it takes up an area and said areas can be subdivided. When RAM is used, the portion of used RAM is considered blocked for the duration of how long it is stored, independently of whether it is accessed or not. This means that the most important objective is having sufficient amounts of RAM to store all data, not to occupy all of it preemptively even when it is not really needed.

The same can't be said of CPUs. Occupying the CPU usually means actively using the CPU. The only exception to this is things like spinlocks which should be avoided like the plague. By what the CPU is occupied is determined by the OS, therefore your logic is backwards. It's not the program blocking the CPU and therefore blocking the memory. The OS decided to stop running your process to run another process. Progress is slowed down, but it is not blocked.

Actual blockage only occurs when two processes compete for a fixed resource so that it is not possible to run both processes simultaneously, so that one process has to be closed to run another process.


> Ah yes, the swapping induced by IntelliJ overflowing my system RAM is supposed to reduce the inefficiencies of using too little memory. Great...

That's like me saying, oh great, so the swapping introduced by MS Word or Outlook shows just how efficient C++ is...

> Thanks pron, you've fully bought into all the JVM kool-aid talking points without ever trying to question them.

Oh I didn't just "buy" them. As a low-level programmer who's suffered for a long time from intrinsic inefficiencies and C++, I became a compiler and runtime engineer working on the JVM to solve the problems I had in C++.

> This is the "wasted RAM is unused RAM" mentality and it doesn't work, because you usually have multiple competing programs and when you run out of RAM, your system will start swapping

No, it's actually more involved and interesting than that, but you'll have to wait for my talk.

> Ok, now you're just writing nonsense. Nowadays people have CPUs with multiple cores and use an OS with a scheduler. If you have two programs taking up 100% of the CPU, the OS will give each process some of the hardware resources. You can't just assume some 100% CPU blockage here just because it is convenient for your argument

I didn't. I specifically said it was just an example to demonstrate the inter-relatedness of RAM and CPU since accessing RAM requires CPU. To understand why every single language that can isn't limited by other constraints and has the engineering resources to do so uses the same basic memory management algorithm as Java I guess you'll have to watch my talk when it's published.

> Again, this is completely incorrect in so many ways that you're bragging you know nothing about how modern computers work.

Wow. I guess it doesn't take much to be an engineer working on safety critical realtime applications and then on one of the worlds most advanced optimising compilers and you can get pretty far without knowing how computers work.

> CPU cores have their own local memory resources called caches. Depending on how your code is written, you may tile your data so it fits entirely in cache and operate within the local memory.

The data you need to access at any one time and the overall memory consumption of your program are two very different things. Maybe you don't know this, but CPU caches don't work by caching a large contiguous portion of the address space.

> When performing inter thread communication, there are often situations where the data often doesn't even get written and then loaded to main memory, since atomic operations can make use of the MESI cache coherency protocol to pull the data directly from another cores' cache.

I find it hilarious that you're trying to teach me about MESI, given that designing algorithms and data structures that are efficient on top of MESI was one of my jobs [1], and I advised Intel on architecture, but okay, maybe I know nothing about computers, as you concluded from a paragraph where I tried to give people who may not be compiler or memory management experts some intution about modern memory management design.

FYI, modern malloc/free allocators are also intentionally less footprint-optimised than older ones to get better performance (although they can't offer all the optimisations of moving collectors because they're not allowed to move pointers), but maybe none of the people writing the compilers or memory management mechanisms you use know computers as much as you do, and you know all there is to know.

[1]: I later even wrote, for a general audience, about data structures over distributed MESI (well, MOESI to be precise) protocols: https://highscalability.com/the-performance-of-distributed-d...


This looks to be the end of the conversation now. Just wanted to drop in and thank you for your time commenting, pron.

The common discourse is that "XYZ language is close to the metal and therefore Blazing Fast (tm)" people become tribalistic and forgot that this there are engineering considerations and trade-offs all the way down. I appreciate you making the argument for the JVM delivering performant code when a budget matters.


Your Project Leyden's "AOT cache" Youtube link is broken, did you mean to link to https://www.youtube.com/watch?v=fiBNDT9r_4I?

Oops, thank you, but I actually meant to link to this one about how Netflix uses it: https://youtu.be/4kEh8hxAP4U. But your link is good, too.

What do you mean by “control”?

Most of real world use of Java platform has next to 0 concerns like those. Some more niche use case may benefit, good, but overall success map isn't changing anytime soon. Reasons for its long term success lie elsewhere.

Android Java apps' memory consumption is definitely a relevant concern.

It doesn't even run "JavaTM", but some bastard child that is in like ~5 years delay compared to OpenJDK.

It uses ART, which is not a Java platform.

While this is true, it is true because the applications where it might be a concern avoid using Java.

Not true. Lots of large Java deployments with millions to billions in cloud spend. The Java part of it isn’t 0.

Memory isn’t free. CPU isn’t free.


And java uses very little CPU compared to most other languages. It's right after manual memory managed languages like C/C++, and is the first managed language according to a paper about how "green" each language is.

But there is a semi-fundamental tradeoff here, you either use more CPU to use less memory or the reverse. Java can be dynamically configured for either end (though defaults to less CPU by not running the GC unnecessarily).


Coincidentally I'm working on my own TUI framework for my book [1], so it's always interesting to see how other people approach it. I wouldn't, for example, use windows and drop-downs in the terminal; I think there are better approaches. Some of the most interesting text-focused UI experiments are taking place in Emacs and Vim, so that's where I'm taking inspiration from.

My framework is demonstrating the capability-passing approach to effects, which is the underlying architecture in most modern JS frameworks, Jetpack Compose, and "immediate mode" toolkits (though the authors are not necessarily aware of capability-passing as a concept). If you've read recent posts on "algebraic effects" or "effect handlers" it's in the same space. It makes for a quite pleasant user experience. I'm enjoying the work uniting theory and practice; one of the benefits of writing the book is I can justify these excursions.

[1]: https://functionalprogrammingstrategies.com/


I’ve actually implemented a TUI in Prolog (because there wasn’t anything in the space and I wanted to make sure it respected the relational/logical nature of Prolog). I’m happy with performance and developer ergonomics. But before I publish it, I want to firm up some opinions on how TUIs should behave for end users. Do you have any suggestions other than “use Vim/Emacs and think about it”?

TUIs in Prolog sounds fun.

The great thing about TUIs is that a simple text component is a universal widget. If the user can display text and capture events they can implement any interface components they want in terms of that.

That said, whatever the framework provides pushes users in a particular direction. The core of the things I'm thinking of (some links below) is providing easily accessible context for the user right at the point where they are working. This can be completions at the cursor, or a quick key to pop up a command palette. Fuzzy search is standard.

Here are some examples:

* Corfu: https://github.com/minad/corfu

* Vertico: https://github.com/minad/vertico

* which-key: https://github.com/justbur/emacs-which-key

* LazyVim: https://www.lazyvim.org/

I've included links that have screenshots showing how they work. The list is biased to Emacs, because I'm an Emacs user (Doom Emacs in particular) and so more familiar with that ecosystem.

Hope that helps!


It's also the technology that will allow software to run without a continuous connection to the server. If you want to break out of a world where companies own your data it's the tech that is needed.

You can precisely define any particular model, but not all work in the area shares the same model. I think you know about the capability-passing model, which is quite different to the algebraic effects (e.g. row types) models.

The general ideas are:

* effects are handled by handlers (called capabilities in the capability-passing model)

* function signatures describe the effects that are used

* effectful code is written in direct style, not monadic style


Thanks! This begins to make more sense to me

> effects are handled by handlers

OK, and in the general case a handler allows its body to "perform" an action, and when the action is performed it has the ability to "respond" to it in (in some cases) a very flexible way, running it never, or multiple times, or in a modified environment, or possibly even passing it out of the scope of the handler entirely.

> function signatures describe the effects that are used

Would you say this is not possible in an untyped language then?

> effectful code is written in direct style, not monadic style

I don't understand the distinction here


> OK, and in the general case a handler allows its body to "perform" an action...

Yes, although not all systems allow this, as implementing full continuations is involved and can hurt performance.

> Would you say this is not possible in an untyped language then?

You can definitely implement the ideas of algebraic effects in an untyped language, but you lose one of the benefits.

> I don't understand the distinction here

Monadic code is code where the order of evaluation is specified by bind / flatMap. Direct-style just uses the language's built-in control flow. See https://noelwelsh.com/posts/direct-style/ for more


Cats Effect is monadic effects. What is discussed here is sometimes called "direct-style" effects, and is an alternative representation.

I think you've missed the point regarding effect systems. Concurrency and resource handling, implemented in a way that is composable and reasonably easy to reason about, are two of the big ticket features.


> Those adults who met the 150 minute a week guideline on exercise experienced a modest 8-9% reduction in cardiovascular risk, the study found. This was consistent across all levels of fitness.

> In order to achieve substantial protection, classed as a greater than 30% risk reduction, between 560 and 610 minutes of moderate to vigorous exercise a week was needed.

So 30 minutes a day is still good, but more is better. Seems reasonable.

Also exercise doesn't mean planned / scheduled exercise, like going to the gym. Daily activities can count, like cycling to the train station for example. Which gets to one of my favorite hobby horses: increasing exercise at the population level is an urban design problem.


Urban design can help, but only for those who actually want to take the 'hard' route. Most people I know would rather take a subway or call an uber for anything above 20 minutes of walking (which makes me sad).


The trick is to make the healthy option the easy route. That's what Paris did (creating more bike lanes, getting rid of parking spots, closing roads to cars) and cycling is now more popular than driving [1].

[1]: See, for example, https://bicyclenetwork.com.au/newsroom/2026/03/11/how-paris-...


Indeed after the pandemic many more bike, for what I've seen a considerable percentage e-bikes, maybe understandably given the hills and distances in Paris, but imho not the everyday cardio exercise one needs.


I got a group of 5 or so friends looking at me like I just came out of a spaceship when I told them me and my wife go for walks almost every evening for 30-60 min... walking for the sake of walking was truly alien to them.


Walking to subway station and from destination subway station to final destination is significantly more walking time than using a car from home to final destination.


I used to live in a very walkable part of Victoria BC, which was great! Unfortunately I was eventually priced out, and the job market there was very competitive so I had to move

I wound up in a fairly walkable part of Calgary. But Calgary is not a super walkable or bikeable city. Transit here is at best ok, and winter gets very cold. There are some good bike paths but you have to be pretty determined to use them when it snows or it's -40 out.

I guess what I'm saying is urban design is super important, but geography has a say too. We don't all get to live in the relatively mild west coast weather.


Calgary could be much better, but the river pathway is really good. It doesn't snow that much and it is rarely -40 (as in pretty much never unless you go in for wind chill). They do a very good job of clearing snow from the core pathways; way better than they do the roads! I think the biggest challenges are that it's likely the non-car options are all managed by car driving bureaucrats. Things like commuter pathways that just end in construction, with convoluted or no detours; slow & widespread construction that seems to be focused on pretty landscaping vs. functional infrastructure; what it's like to ride a bike or scooter in close proximity to big volumes of massive trucks. This is not unique to Calgary, but if we made city managers walk, roll or bus to work for a month it would help IMO.


> It doesn't snow that much

I'm from Vancouver Island originally so Calgary snows a ton in comparison. :)

You're right it could be worse. It could be better too. That basically describes everywhere though! Overall I do love living here

> if we made city managers walk, roll or bus to work for a month it would help IMO.

Agreed. I think public servants should be encouraged (maybe required?) to dogfood public services now and then


I think ebikes are amazing but it is more than a bit sad to me that less than half the people moving around in my neighborhood put in any energy. There's like two bicyclists under 25. Many many many scooters and ebikes.

Very torn on this one. I love it for them, but also, it seems super sad to me. I can't even really explain why it's so saddening.


i think that's a chicken and egg cultural problem. build cities in a way where bicycles/walking is encouraged, then over time you'll have people that want to do exactly that.


20 minutes of walking is a perfect bicycle distance.


example: Calgary is currently debating removal of the free fare zone for the DT transit line. It's like 10 blocks of straight, flat walking but you hear things like "nobody will go out for lunch and support downtown businesses if we get ride of this!" Currently it's mostly used by homeless people to stay warm in the winter.


9 hours of moderate to vigorous seems like a lot. When I do vigorous (2 times a week HIIT) I cannot do vigorous the next day, my body clearly needs recovery. I can do moderate. But I wonder what scientists mean by vigorous at this point. I am starting to suspect I set the bar too high


I think the definition of vigorous is roughly 75% of max heart rate. HIIT would generally be more strenuous than that. Roughly speaking for a lot of people, running faster than about a 10:00/mi pace is probably vigorous.

In the WHO recommendations, they say to get 75 minutes of vigorous or 150 of moderate per week. I believe in this study they use the same double counting of vigorous minutes.

I’ve seen other studies that say you get most all of the cardio benefit you can with about 150m vigorous/300m moderate. You could roughly get that by running about 2.5 miles per day.


Light and moderate are mostly just "activities of daily life" (walking, commuting), and vigorous is whenever you exercise explicitly (running, swimming, speed cycling, soccer, etc). So it's more like 9 hours of active movement, or 4.5 hours of exercise (40 mins a day).


"exercise doesn't mean planned / scheduled exercise, like going to the gym."

Most of the people I see in the gym are sitting on the benches on their phone 9 minutes out of 10. I'm pretty sure going to the gym is not helping at all...


If you're doing heavy compound exercises like 3x5, 5x3 squats, you kind of need to wait three minutes in between! Even adding something in between like press or pullups is quite hard on the nervous system.

The people who walk 45m on the treadmill while watching a show, or people who sit around chit chatting, yes... A waste of space.


So what sort of exercise regime legitimizes 10-minute pauses between short sets of moderate weight?

Calling it 'the gym' sort of conflates its two distinct sections: the one containing cardio equipment, and the other containing strength training/bodybuilding equipment. So-called 'work capacity' aside, there's almost zero overlap between the two sections.

Whether someone's effectively strength training/bodybuilding or not, which is the section I think you refer to—nobody reasonably believes that does anything significant for cardiovascular health, which is the topic being dicussed here.


At certain times of day the London underground deliberately directs people to longer paths around the stations to alleviate congestion. This kind of thing could be a health benefit.


There are plenty of examples of cooperation in nature.


Which though, are not a sign of harmony- its more a sort of horrific balancing act at the abyss having clear winners and losers, the losers becoming cattle, organs or worse and usually they do not defect only because then some horror from the abyss eats the whole gametheory board and their abilities have atrophied -aka cooperation usually is a sort of slavery.


> its more a sort of horrific balancing act at the abyss having clear winners and losers

No need to appeal to emotions this way. At the individual level there are only losers, and we all die. At the universe level, whatever happens, happens, and it’s up to us to find beauty in it.


and it's up to us if those ugly old seals murder those pups or not :)


Well, yeah. Murder requires intent and, at least in human populations where cannibalism is not a problem, the separation with predation is clear. It’s less clear in this cases where the killing also involves eating (parts of) the victim. We don’t understand why they do it, therefore we cannot really condemn this as murder, therefore whether we should intervene and what we should do are not obvious.


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

Search: