top | item 42268310

The success and failure of Ninja (2020)

297 points| quincepie | 1 year ago |neugierig.org

82 comments

order

willvarfar|1 year ago

> we talk about programming like it is about writing code, but the code ends up being less important than the architecture, and the architecture ends up being less important than social issues.

A thousand times this! This puts into words something that's been lurking in the back of my mind for a very long time.

nuclearnice3|1 year ago

Strongly agree. Peopleware 1987 [1]

> The first chapter of the book claims, "The major problems of our work are not so much technological as sociological in nature". The book approaches sociological or 'political' problems such as group chemistry and team jelling, "flow time" and quiet in the work environment, and the high cost of turnover

[1] https://en.wikipedia.org/wiki/Peopleware:_Productive_Project...

mihaaly|1 year ago

Considering that programing and tools used for it are not for computers but humans, and that apart from most trivial things more than one people is necessary to make something that work on/with computer(s), it is no surprise that SE is much more social science than many would like to admit or feel comfortable with, over-emphasizing its natural science part to the level of failure eventually (on the product level aimed at addressing needs of the people). Probably because social sciences are very fluid and much less reliable than natuaral sciences, so we have an inner tendency avoiding the social bit, or handling it on a very primitive level? I do not know, this is a feeling. So much focus on atomic details of technology yet the group effort of the product is still rubbish too many times.

transpute|1 year ago

https://en.wikipedia.org/wiki/Conway's_law

> Organizations which design systems (in the broad sense used here) are constrained to produce designs which are copies of the communication structures of these organizations. — Melvin E. Conway, How Do Committees Invent?

Swizec|1 year ago

In my experience roughly 80% of technical issues are because 2 people (or teams) didn’t want to just sit down together and talk it out.

zelphirkalt|1 year ago

It is not a dichotomy though, as a good architecture manages to fulfill the requirements people have for the system _and_ keeps it understandable for human beings.

IgorPartola|1 year ago

This precisely describes why Google Glass failed.

dang|1 year ago

Discussed at the time:

The Success and Failure of Ninja - https://news.ycombinator.com/item?id=23157783 - May 2020 (38 comments)

(Reposts are fine after a year or so! links to past threads are just to satisfy extra-curious readers)

defer|1 year ago

This is hilarious to me:

  Android, which uses it for some large component of the system that I've never quite understood
Ninja is really a huge part of AOSP, the build system initially used makefiles. Things got complex really fast with a custom declarative build system (soong) and a failed/aborted migration to bazel. Google developed kati (https://github.com/google/kati) which converts Makefiles to ninja build files (or should I say file), which really is huge:

  λ wc -l out/build-qssi.ninja    
    3035442 out/build-qssi.ninja
Going from makefiles/soong to ninja is painful, it takes several minutes even in a modern machine but it simply flies once ninja picks it up.

zelphirkalt|1 year ago

As someone, who has not used Ninja, what advantage is there, compared to Makefiles? And is it worth introducing yet another tool, to translate one to the other? Especially, when the Ninja files are that huge, possibly human-unreadable.

high_priest|1 year ago

> I also believe that programmers feel latency and it affects their mood even if they don't notice it. (Google has recently done some research in this area that kinda confirmed my belief, here's hoping they'll publish it publicly!)

Anyone knows if it happened? Has the google research on latency been published?

jacobgorm|1 year ago

The 400ms Doherty Treshold applies to builds too.

forrestthewoods|1 year ago

Ninja is pretty popular with gamedevs.

I was amused by this line:

> But Windows is still a huge platform in terms of developers, and those developers are starved for tools.

As a primarily Windows dev I feel that it is poor Linux devs who are starved for tools! Living life without a good debugger (Visual Studio) or profiler (Superluminal) is so tragic. ;(

It does feel like in recent years the gap between the two platforms is increasingly minimal. I definitely like all the Rust utilities that generally work crossplatform for example.

marcosdumay|1 year ago

Every time somebody puts "Visual Studio" on the same sentence as "good" I get that strange feeling the Universe is a simulation and other people are interacting here, but do come from a different one.

I can't make for any other explanation. I can't think on any interaction with it that I would describe as "good". I can think of a few "minimally ok", but debugging isn't one of them. (But at least on the 2022 the debugger isn't full of bugs anymore. Maybe that's what this is about.)

3836293648|1 year ago

In what world do you live in where the visual studio debugger in considered good? Or have they finally got around to fixing it? Last I tried it was unbearably slow, like seconds to step a single line

pjmlp|1 year ago

There is a community that thinks UNIX is the be all, end all of developer tools, and then they miss the trees from the forest.

I know UNIX pretty well, since being introduced to Xenix in 1993, used plenty of variants, and yet my main use of WSL is to run Linux docker containers and nothing else.

mgaunard|1 year ago

I switched to samurai for the few things I have that still used ninja; it's an improvement in every possible way.

But regardless, I think those kinds of build systems are just wrong. What I want from a build system is to hash the content of all the transitive inputs and look up if it exists or not in a registry.

dikei|1 year ago

Yes, basically any build system that supports distributed caching use digest instead of timestamp when checking modification: Bazel, Pants, Buck, etc.

They're all hugely complex though.

For local build only, I think SCons and Waf both use hash for changes detection.

Sesse__|1 year ago

You might be interested in n2, from the author of ninja.

TOGoS|1 year ago

I think that was the idea behind NetKernel.

I've built something similar, a Deno library called "TDAR"[1], and it works well, but it takes some work to wrap up all the command-line tools that expect to work in some mutable filesystem so that you can pretend you're calling pure functions.

[1] I haven't got around to pulling it out of the parent project[2], but I talked about it in this youtube video: https://youtu.be/sty29o8sUKI

[2] If you're interested in this kind of thing you could poke me to open up the source for that thing. togos zero zero at gee mail dot comb

chubot|1 year ago

What’s better about Samurai? I thought it was a compatible subset of ninja

Also, “not the thing I wanted” doesn’t mean “wrong”, simply because there are other people in the world with different preferences

bonzini|1 year ago

Is Samurai still alive? I have sent a pull request to improve signal handling but it has been sitting ignored for over half a year.

phyrex|1 year ago

That's how metas buck2 works

dima55|1 year ago

That's called "ccache"

pjmlp|1 year ago

Given that ninja is required for C++20 modules when using CMake, it is going to stay around for quite a bit.

edflsafoiewq|1 year ago

Most interesting point to me

> You must often compromise between correctness and convenience or performance and you should be intentional when you choose a point along that continuum. I find some programmers are inflexible when considering this dynamic, where it's somehow obvious that one of those concerns dominates, but in my experience the interplay is pretty subtle; for example, a tool that trades off correctness for convenience might overall produce a more correct ecosystem than a more correct but less convenient alternative, if programmers end up avoiding the latter.

bakudanen|1 year ago

This is goldmine. This is why Pyhon, Go, and TypeScript/JavaScript is way more popular than Haskell/OCaml.

zX41ZdbW|1 year ago

> Relatedly, please forgive me for the embarrassing name.

The name is great!

PS. It's possible to make it even faster if we implement this: https://github.com/ninja-build/ninja/issues/2157 But you explained in the article that the tool intentionally lacks state, even tiny hints from previous runs.

grobibi|1 year ago

I thought this was going to be about people buying less air fryers.

Krastan|1 year ago

I thought this was going to be about the Fortnite streamer

airstrike|1 year ago

I thought of the smoothie blenders first too, but I can't see how they would ever have failed given how great they are. My life has changed since buying the first such blender about 4 months ago

bakudanen|1 year ago

I had my stint with build systems. Nx, Bazel to name a few. In the past I was always the go to guy to configure these stuffs.

OP said that ninja is small enough to be implemented in your favorite programming language. I wonder if there is step by step tutorial to create your own build system?

emmanueloga_|1 year ago

Short answer: write a ninja configuration generator instead.

> ... Where other build systems are high-level languages, Ninja aims to be an assembler.

> ... Ninja is intended to be used with a separate program generating its input files.

> ... Ninja is pretty easy to implement for the fun 20% of it and the remaining 80% is "just" some fiddly details.

There are many ninja generators out there already [1] but writing a simple, custom one shouldn't be too hard [2] and could make sense for some projects.

BTW, ninja is great but I wish the configuration file had used a more standard format, easier to parse and generate from any language. JSON would have been a better option I think, given the abundance of tooling around it.

--

1: https://github.com/ninja-build/ninja/wiki/List-of-generators...

2: https://ninja-build.org/manual.html#ref_ninja_file

santoshalper|1 year ago

Man, I was so afraid this was going to be about Fortnite. Turns out it was a fantastic read. I feel really sad but unsurprised about his description of what it's like to be an Open Source maintainer.

einpoklum|1 year ago

### Statistics ###

ninja has ~26 kloc, ~3,100 commits, and only a quarter of them by the original author (although by loc changed their weight is higher). Interesting!

https://github.com/ninja-build/ninja/graphs/contributors

### Bunch of other comments ###

> users of ninja ... all Meson projects, which appears to increasingly be the build system used in the free software world;

So, AFAICT, that hasn't turned out to be the case.

> the code ends up being less important than the architecture, and the architecture ends up being less important than social issues.

Well... sometimes. Other times, the fact that there's good code that does something goes a very long way, and people live with the architectural faults. And as for the social issues - they rarely stand in opposition to the code itself.

> Some pieces of Ninja took struggle to get to and then are obvious in retrospect. I think this is true of much of math

Yup. And the some of the rest of math becomes obvious when some re-derives it using alternative and more convenient/powerful techniques.

> I think the reason so few succeed at this is that it's just too tempting to mix the layers.

As an author of a library that also focuses on being a "layer" of sorts (https://github.com/eyalroz/cuda-api-wrappers/), I struggle with this temptation a lot! Especially when, like the author says, the boundaries of the layers are not as clear as one might imagine.

> I strongly believe that iteration time has a huge impact on programmer satisfaction

I'm pretty certain that the vast majority developers perform 10x more incremental builds than full builds. So, not just satisfaction - it's just most of what we do. It's also those builds which we wait-out rather than possible go look for some distraction:

https://xkcd.com/303/

OTOH, the article doesn't mention interaction with build artifact caching schemes, which lessen the difference between building from scratch and building incrementally.

> Peter Collingbourne found Ninja and did the work to plug it into the much more popular CMake ... If anyone is responsible for making Ninja succeed out there in the real world, Peter is due the credit.

It is so gratifying when a person you didn't know makes your software project that much more impactful! Makes you really feel optimistic again about humanity and socialism and stuff.

a_t48|1 year ago

Im going to have to give your CUDA wrapper a look later. :)

burrish|1 year ago

Damn and here I was expecting real Ninjas