←back to thread

392 points mfiguiere | 1 comments | | HN request time: 0.386s | source
Show context
shaman1 ◴[] No.35476103[source]
Excuse my ignorance but what are the advantages of using such a system over the standard build systems of various languages (vite, gradle, maven, pip, etc)?
replies(2): >>35476212 #>>35476453 #
i-use-nixos-btw ◴[] No.35476453[source]
If you only use one language, and that language has a reliable, reproducible build system that gives you the guarantees and functionality that you require, then not much.

Here’s how I used Bazel (and how I now use Nix).

I am provided a configuration file that specifies what a given instance of my program must do. I use language A that can natively understand this configuration to code-generate a file in language B (which is significantly more suited to the performance requirements of the program)

This file is then built along with generic program code. It is used to process a lot of data.

As an interface to this program, I have a HTTP interface that can communicate with it. It needs to understand the kinds of outputs the program will produce, so some of this HTTP interface is also code generated in language A. The interface is interactive so typescript is generated and then compiled too.

In order to process the output from the program, I need to produce extensions for languages that users of the output use: Python and R. These need to understand the kinds of data being used, so are also code generated - then built. They’re then tested against requirements defined by the config (so the tests are also code generated).

Each of these stages have dependencies required when building and dependencies required when running, and there are several languages involved.

I also need to be able to express the entire process as a function, because it’s something that needs to be run very frequently on different configs - sometimes in collections of configs that need everything built at once. It needs to be build on several different machines, sometimes desktops and sometimes remote servers, sometimes on clients’ hardware (depending on the needs). I need confidence that something that works on my development machine will work, in entirety, on a completely different machine with minimal prior setup. And I need it to be easy to do, easy to maintain, and I don’t want to mess around with many different build systems that have entirely different use cases, entirely different ideas of how build/runtime environments should be handled, entirely different languages to configure them - and many of them are rigid and don’t have a concept of functions, they’re just “state your dependencies, kthxbye”.

All of the above is absolutely trivial with bazel if you know where to tread lightly (e.g. surrounding Python environments). It’s also very easy with Nix once you get used to it, and you don’t need to tread lightly there - it has stronger guarantees.

replies(2): >>35478887 #>>35480222 #
1. kostarelo ◴[] No.35480222[source]
That's very interesting, I've never exposed to such a development environment. Is there maybe a GH repository or something that I can see the above in action? Thank you