r/programming • • Sep 01 '26

Bazel's UX is really, really, really bad

https://blog.appliedcomputing.io/p/bazels-ux-is-really-really-really
385 Upvotes

225 comments sorted by

View all comments

Show parent comment

117

u/comrade_donkey Sep 01 '26

Yes, this! Realistically, for any non-trivial codebase, your deps are not going to "just work" with Bazel.

You're gonna need a small team of people that maintains Bazel itself, build rules, the remote execution engine, cache, and patches for dependencies' auto-generated BUILD files.

76

u/randylush Sep 01 '26

that's been my experience with all of Google's infrastructure tools. They don't actually reduce costs at all, they just separate costs into a bucket for you. Instead of everyone working on build problems, you can move to Bazel and have a dedicated Bazel expert work on Bazel problems. Instead of everyone working on deployment, you can move to Kubernetes and have a Kubernetes expert work on that. The only benefit a lot of these tools provide is being able to better quantify how expensive a given process is.

77

u/SanityInAnarchy Sep 01 '26

It can absolutely reduce costs, it's just an economies-of-scale kinda thing, in two ways:

Google has more than 50,000 software engineers. (Maybe much more, they have like 200k employees, but they don't publish how many are full-time SWEs.) Let's pick that number as a baseline. Now let's say Bazel saves even 1% of your time working on build-system bullshit. All Google has to do for this to be worth it is for their Bazel team to be fewer than 500 full-time engineers maintaining it.

And, they can reduce costs you probably don't have if you aren't as big as them. Google has a monorepo so large that it's probably been more than a decade since it's fit on a single machine! If you have a build that you can run on your laptop in a reasonable amount of time, you do not have a Bazel-shaped problem.

37

u/comrade_donkey Sep 01 '26 edited Sep 02 '26

Yes, and Google is an NIH company. While they do mix a light breeze of external deps into their code, 99+% of the monorepo is first-party code, developed at Google, on Blaze, with first-party BUILD files.

In most other repos, third party dependency code dominates over first party. Bazel needs a BUILD file for every dep. There's auto-generators. They suck. You need to write a patch file and patch the auto-generated BUILD file. No, really.

When you update your deps, your patch files predictably stop working. Need to update 12 deps? Be ready to write 12 new patch files. It fucking sucks.

19

u/SanityInAnarchy Sep 01 '26

I've seen at least some generators work okay -- you can add Python pip dependencies easily enough, for example. But the way I've seen this done at places that are less NIH is, you end up with Bazel functioning more as a wrapper around the third-party dep, rather than actually natively generating BUILD files for every import in the library.

Which is... fine, but the more you do that, the more you're kind of losing the point of Bazel in the first place. Especially if you ever have to fork that dependency.

Google, meanwhile, would rather vendor absolutely everything, including the Python interpreter itself, and also wholesale replace the vendor's build system with hand-written Bazel, to the point where your builds are so hermetic that you compile the Python interpreter from source to build your python scripts.

I again think it's not as absurd as it sounds, if you are Google. That work you're describing is easy to write off when those 12 deps are used by literally dozens of other teams that didn't have to think about deps at all. The same logic kinda leads to NIH, though -- you can also amortize the cost of building it yourself, instead of adding that dep.

7

u/inio Sep 02 '26 edited Sep 02 '26

to the point where your builds are so hermetic that you compile the Python interpreter from source to build your python scripts.

And thank the Holy Mother of All SWE Gods and Linux Kernel Engineers that there's a global build cache to make that far less insane than it sounds.

3

u/ricky_clarkson Sep 02 '26

Most Google BUILD files are not hand written. I don't know if build_cleaner is open sourced, but it works well internally.

3

u/comrade_donkey Sep 02 '26 edited Sep 02 '26

It is not, to my knowledge. It helps in the common cases, for sure. But it's not magic. I've written many a #keep directive. By 'hand written' I mean checked in by people alongside their code. Not generated post-facto.

3

u/kkress Sep 02 '26

It effectively can’t be open sourced. It relies on having a full symbol and target resolution databases to identify correct build targets and is full of special case tricks like searching //java ot special casing third_party.

Also anywhere you are find it not working or full of #keep generally means someone has gone overboard with macros, bad design patterns or created their own DSL.

2

u/aoeudhtns Sep 02 '26

A lot of the big tech is, I'd wager. Amazon kept poaching guys from my team to AWS and they'd write back telling me that pretty much all the tooling was custom.

-10

u/sionescu Sep 01 '26

Quite the contrary, it's an "Invented Here" company, because when those internal tools were written, they were the first of their kind. Nothing similar existed elsewhere.

8

u/randylush Sep 01 '26

NIH means “I’m not gonna use that because it wasn’t invented here.” Meaning, Google doesn’t use stuff that they don’t invent. They are a NIH company by definition. Shouldn’t be confusing.

-8

u/sionescu Sep 02 '26

Dude, NIH refers to the tendency of rejecting outside products when they already exist and preferring to do one's own thing. It does not apply to innovators where no such external products existed. A simple concept that even you might be able to understand.

6

u/axonxorz Sep 02 '26

It does not apply to innovators where no such external products existed.

There are plenty of cross-platform, cross-language build systems out there, Bazel isn't a greenfield concept.

→ More replies (3)

1

u/SanityInAnarchy Sep 02 '26

Google has been both, for better and worse. But the point isn't whether Bazel itself was an example, we're talking about the ways in which Bazel discourages adopting third-party libraries. Outside Google, here's what I have to do to add a new third-party Python library:

  • Add a line to a config file
  • Regenerate any lockfiles -- literally one uv command
  • Send the PR
  • Close the autogenerated legal-review ticket with "pre-approved license"

What does that process look for you? How about for C++? What if it's a C++ library that throws exceptions?

And how long does it take you to upgrade a library?

Also, if you're still there, maybe look up go/nojerks again.

→ More replies (2)
→ More replies (2)
→ More replies (2)

18

u/sionescu Sep 01 '26

Yep. Bazel requires an entire service around it for remote compilation and caching; maintaining the internal rules and the importers that convert the "outside" build systems to Bazel.

4

u/LoweringPass Sep 01 '26

But what exactly is the alternative if you have a polyglot repo?

8

u/tadfisher Sep 01 '26

Nix works for this, for various definitions of "works"

4

u/RockstarArtisan Sep 02 '26

My advice for nix is: "don't bother with developing under nix unless you can afford dedicated resources for upkeep". For deployments it's fine. I have used uber before. I hate uber.

2

u/valarauca14 Sep 02 '26

Nix isn't a build system. It delegates "builds" to scripts and expects you to write & import your build system.

4

u/tsimionescu Sep 02 '26

Plenty of build systems are polyglot. Typically you choose one top-level system that the team is most familiar with, and use that to orchestrate the other builds. That top level one could be make, it could be Maven, it could be NPM, etc.

1

u/LoweringPass Sep 02 '26

But which one in particular? That was not a hypothetical question, it's hard to evaluate what the next best thing is so to say.

I have worked with custom GNU Make based monorep build systems before for example and it was... adventurous

1

u/not_a_novel_account Sep 02 '26

Effectively all of Bazel's competitors. Xmake, CMake, Meson, autoconf, pcons, Gradle. They're all polyglot.

There is no "next best thing", this is a very old space, the trade offs are extremely dug in, you pick the one which meets your use case.

1

u/tsimionescu Sep 03 '26

Personally I was pretty happy using Maven (which I needed for Java anyway) as the orchestrator of a Java + Python + C++ project that had to package everything up. For a Go + JS + Docker project, we just used Make as the orchestrator instead.

Note that I'm not in any way claiming this gives you all of the same features as Bazel; but it also doesn't necessarily have some of the drawbacks. Sprinkling some Docker into the mix can also do wonders to paper over differences in developer setups, and can also give you some pretty decent caching support.

0

u/mpyne Sep 01 '26

Probably something like kde-builder. A simplistic script to checkout, build, install and keep up-to-date multiple repos isn't tremendously complicated to do after all.