Hacker News new | ask | show | jobs
by gizmo686 246 days ago
Testing on my machine, Hello World in java (openjdk 21) takes about 30ms.

In contrast, "time" reports that rust takes 1ms, which is the limit of it's precision.

Python does Hello World in just 8ms, despite not having a separate AOT compilation step.

The general guidance I've seen for interaction is that things start to feel laggy at 100ms; so 30ms isn't a dealbreaker, but throwing a third of your time budget at the baseline runtime cost is a pretty steep ask.

If you want to use the application as a short lived component in a larger system, than 30ms on every invocation can be a massive cost.

3 comments

App that actually does something will probably have even larger startup overhead in Java as there will be more to compile just-in-time.
Only when not using either AOT or JIT cache.
I recall that Mercurial was really fighting their Python test harness. It essentially would startup a new Python process for each test. At 10ms per, it added up to something significant, given their volume of work to cover something as complicated as SCM.
10ms?

Did they have like 100k tests?

Found a 2014 thread where 10-18% of the test harness time was spent booting the interpreter for the 13,000 required instances. The deeper thread was showing some 500-700 seconds of test time was just the interpreter overhead. The original point of the article was how much worse the overhead was in Python3 vs Python2.

https://mail.python.org/pipermail/python-dev/2014-May/134528...

That's a lot more extreme than 10ms and yea I get your point better now
I'm trying and failing to imagine a situation where 30ms startup time would be a problem. Maybe some kind of network service that needs to execute a separate process on every request?
30ms is pretty close to noticeable for anything that responds to user input. 30ms startup + 20-70ms processing would probably bump you into the noticeable latency range.
People play midi keyboards with 30 ms latency.
Yeah I don’t think 30ms is very noticeable, but say you have a cli tool with other 20-70ms to bump you up to 50-100ms your tool will have noticeable latency. Death by a thousand cuts.
30ms is the absolute best case. Throw some spring in there and you're very quickly at 10s. rub some spring-soap and it's near enough to 60s
And imagine if you start adding sleep calls! Those could take minutes to hours, or even days!
New HN submission: How I Made My Sleep Function Accidentally Quadratic.
It's not about how long someone is willing to wait with a timer and judge it on human timescales, it's about what is an appropriate length of time for the task.

30ms for a program to start, print hello world, and terminate on a modern computer is batshit insane, and it's crazy how many programmers have completely lost sight of even the principle of this.

Java is a tool, a very good one.