logoalt Hacker News

Ninja is a small build system with a focus on speed

89 pointsby toshlast Friday at 10:23 AM50 commentsview on HN

Comments

ozgrakkurttoday at 5:00 PM

Ninja is one of the best tools I have used. It is extremely simple and always works flawlessly.

Some blog posts from the creator of ninja:

https://neugierig.org/software/blog/2018/07/options.html

https://neugierig.org/software/blog/2011/04/complexity.html

Also there was a post about why just generating ninja using python can be a good option. I do this in my project and it has been very productive so far. I couldn’t find this post now but it was saying to use ninja_syntax.py from ninja codebase and just doing something minimal for a project

show 1 reply
bsimpsontoday at 4:18 PM

Evan Martin (evmar) started Ninja when he was working on Chrome at Google:

https://neugierig.org/software/chromium/notes/2011/02/ninja....

Hence, it's used in a lot of Google projects.

aidenn0today at 6:26 PM

Ninja is possibly the best example of the "Do one thing and do it well" philosophy. All it does is execute commands based on a static build graph.

It's syntax is simple enough that it's trivial to e.g. write a shell script to generate the build items if you need dynamic dependencies.

Conscattoday at 5:51 PM

An under noticed ninja feature I adore, which was implemented relatively recently, is the ability to configure how its build progress is printed. In my fish config, I have the `NINJA_STATUS` envvar:

    set -x NINJA_STATUS "STEP: %f/%t  
    [%p / %P] 
    [%w + %W]
    "
Which prints the time elapsed and projected in a readable multi-line format.
woctordhotoday at 8:12 AM

If someone sees this: The ninja package on PyPI [0] currently stays at version 1.13.0 . There is an issue in 1.13.0 preventing it building projects on Windows. The issue is already fixed in 1.13.1 almost a year ago, but the PyPI package hasn't got an update, see [1], and many downstream projects have to stay at 1.11 . I hope it could update soon.

[0] https://pypi.org/project/ninja/

[1] https://github.com/scikit-build/ninja-python-distributions/i...

show 2 replies
throwaway2046today at 7:03 PM

Ninja is great and feels natural coming from Make. What it lacks in features it makes up for with speed, which is what ultimately matters.

Also worth mentioning is samurai[1], a pure C implementation of Ninja that's almost as fast yet easier to bootstrap needing only a C compiler.

[1] https://github.com/michaelforney/samurai

mizmartoday at 4:05 PM

Similar to make, it does mtime chronological comparison of dependencies with target to determinate if dependencies changed. This is just so flawed and simple to fool by operations on filesystem that do not change mtime (move, rename):

1) pick a source file and make a copy of it for for later 2) edit selected source file and rebuild 3) move the copy to it's original location 4) try to rebuild, nothing happens

show 5 replies
jbonatakistoday at 3:27 PM

Postgres uses Meson+Ninja in their builds. That seems like a pretty big endorsement.

show 1 reply
HiPhishtoday at 5:57 PM

Serious question: how can a build tool be fast or slow? From my understanding all it does is delegate the build steps to other tools, so wouldn't those be the bottleneck? Is it the resolution of order of build steps that takes so much time that a different build system can make a difference?

show 1 reply
p4bl0today at 4:15 PM

I used ninja only a few years ago when contributing to KDE software (Dolphin, Kate, KTextEditor, etc.). I had no prior experience with it and it was easy to apprehend, so a rather good experience.

sluongngtoday at 1:27 PM

My teammate has a great time reimplementing Ninja (slop-free) in Go here https://github.com/buildbuddy-io/reninja to make it even faster with Remote Build Execution.

show 1 reply
shevy-javatoday at 9:58 AM

All the main build tools (cmake, meson/ninja and GNU configure) have different benefits. For instance, I expect "--help" to work, but only really GNU configure supports it as-is. I could list more advantages and disadvantages in general here, but by and large I prefer meson/ninja. To me it feels by far the fastest and I also have the fewest issues usually (excluding python breaking its pip stack but that's not the fault of meson as such). ninja can be used via cmake too but most uses I see are from meson.

show 2 replies
Svokatoday at 5:00 PM

Ninja religions following of treating timestamps (mtime) as 'modified' marker makes it useless with Git and large projects.

You switched some branches back and forward? Enjoy your 20 minutes rebuild.

* https://github.com/ninja-build/ninja/issues/1459

show 2 replies
jonstewarttoday at 12:16 PM

The absolute best thing about coding agents is not having to waste time on build systems. I had Claude code port my autotools scripts to meson (which uses ninja) and it’s been a huge quality of life improvement.

show 2 replies
throwaway613746today at 2:53 PM

[dead]

chmorgan_today at 12:40 PM

[dead]

ameliustoday at 2:30 PM

I can remember having to uninstall ninja temporarily because it messed with building packages. I only use it because other packages need it.