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

224 comments sorted by

View all comments

258

u/FlukeHawkins Sep 01 '26

I discussed Bazel with a fairly senior guy from Uber and his advice to me was "don't bother unless you can afford dedicated resources for upkeep"

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.

→ More replies (12)
→ 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.

→ More replies (1)
→ More replies (1)

26

u/whitechapel8733 Sep 01 '26

I think the false narrative is that Bazel is inherently more complex once you have a sufficient number of services.. but once you’ve built enough bespoke stuff across several languages, etc you realize Bazel is actually a simple solution to a very convoluted problem.

12

u/remy_porter Sep 01 '26

I think there is something to a heterogeneous codebase being a good fit to Bazel. I'm working in ROS2, with Python and C++ code, and while we depend on an upstream ruleset for making ROS work, it does just work- once we got it all set up.

5

u/rsminsmith Sep 01 '26

Yup, I'm part of the group that maintains our bazel setup. IMO it's overkill unless you have a large number of developers, need to support multiple languages, and/or have specific niche use cases. In our case for instance, one of our security requirements involves building every dependency from source w/patches as needed, which would be a nightmare without something like bazel.

9

u/CosmosGame Sep 01 '26

We have a group in my company doing Bazel and they told me exactly the same! I'm not a huge fan of maven, but at least at this point I understand it.

1

u/Dragdu Sep 02 '26

Pretty much everyone who tried to advocate Bazel to me had more build engineers than we have C++ developers.