Startup Showdown

2024-04-08

When is a program’s execution dominated by its startup cost?

How does the answer differ across programming languages?

Why? How do we know?

The little question

I use a lot of command-line tools when I’m developing software. Some are the GNU tools, mostly written in C; some are in Python, Go, or Rust. (Those happen to be languages I’m familiar with, too!)

Most of the time, I’m running these interactively– waiting for them to show me something before I can make my next decision. Most of the time they’re transient: not a daemon that runs in the background, but a process that exits quickly once it’s done.

I get annoyed when my CLI programs are (perceptually) slow. Waiting for multiple seconds for some output gives me time to think… and to come up with questions like this one:

All else being equal, how much does the choice of language impact the startup cost of the program?

Of course there are a lot of other factors in the speed of the program: the work the program is doing, how the language maps to hardware, the size of the task it’s invoked for. There’s other factors in the startup too: file caching, system load, dependencies. And in a lot of cases, the startup time will be lost in the noise: servers, clients, compute- or IO-heavy workloads.

But this question hooked my curiousity. I want to know:

From computer theory to computer science

I think investigating these questions offers some neat things to learn and practice.

In the grand scheme, of course, I’m going to spend longer answering the question than I’ll ever save by “optimizing” any tool. The point is learning, not the outcome.

These posts are my mildly-polished notes about these experiments. I’m going to be wrong about some things – sorry! If you have any corrections – or any tips, clarifications, or other feedback – please do reach out via email or Mastodon.

Sections

  1. Hello:

    How long does a program in $language take to start writing to its standard output?

Acknowledgements

Thanks to Meg, Claire, Nic, and Aditya for reviewing this.

Much of the work for this series was done at the Recurse Center.