News for hackers. Stuff that matters.
Re:Benefits of a Monorepo by bunderbunder on Wednesday May 01, 2019 @09:51AM (#19796960)
For my part, I've worked with two long-lived monorepos so far. Both were quite small, all told, but, nonetheless, in both cases I saw the monorepo largely serving as an incubator for bit rot.

All those direct interdependencies, combined with the impossibility of just using package versioning to allow a library's consumers to upgrade at their own pace, meant that developers had a strong disincentive to do any cleanup that might result in a breaking change. They'd tend to prefer patches instead. So the long-term trend was for everything to eventually become a tangled mass of patchwork.

Google has entire teams devoted to combatting this problem. I'm not sure most companies can (or want to) afford that.

This is one of those spots where I think it's wise to be cautious about blog-driven development. By analogy, I've seen experienced woodworkers have fun with mocking the DIY furniture projects that come up in places like Pinterest. One common criticism was that, since wood expands and contracts with changing humidity, but only in certain directions, if you put it together in certain ways, you end up with a product that will literally tear itself apart over time. Of course, this isn't apparent from the Instructable article, because it's a slow process, and all those pictures were taken when the piece was still brand spanking new. It's also not something you're likely to see written in the comments section or anything like that - the people I've known who know this sort of thing aren't generally the type to write Instructables articles or maintain their own DIY blogs.

I suspect something like this also happens with any decent sized codebase: Code is a living thing that expands and contracts with changing business requirements. Over time, it will twist itself out of shape. Weak coupling and fragmented codebases are two different (though related) ways of trying to limit the damage from this effect. They both bring their own challenges, though, and aren't perfect. Monorepos don't have the same drawbacks, but that doesn't mean they don't have any. One, I think, is that you're left directly exposed to the full strength of the forces that cause bit rot.

If you're disciplined enough to recognize this and treat it as another incentive to attack bit rot head-on, then you'll probably end up in a better place for it. If you think monorepos are a panacea, though, you're setting yourself up for the kinds of failure that people generally don't like to blog about.

Re:Benefits of a Monorepo by notacoward on Wednesday May 01, 2019 @10:01AM (#19797032)
> an incubator for bit rot

Genius phrase. Overall, that might be one of the best comments I've ever read on HN. The DIY furniture analogy is a good one. There's so much focus on what seems to work today, and so little awareness of what affects long-term maintainability. I see this at work too, everyone chasing "impact" for the half even when it screws us over any longer time scale. Understanding how code evolves over time is an essential part of being a competent developer. It's much more important than any in-the-moment coding test.

Re:Benefits of a Monorepo by wcdolphin on Wednesday May 01, 2019 @10:29AM (#19797285)
Can you help me understand what bit rot means as you are using it, and why it is different in a mono repo vs an equally large multi-repo system?
Re:Benefits of a Monorepo by bunderbunder on Wednesday May 01, 2019 @11:04AM (#19797637)
Just cherry-picking one rather extreme example: There was a method in a core library that had an argument that was not used. Few people knew this, and it was one that was called at least once by most services.

When I discovered this, I asked the module's maintainer about it. He explained that it used to be used, but requirements changed so that it wasn't needed anymore. He decided to leave it anyway, though, because the alternative would have been an immense effort to track down all the call sites, remove the argument, then trace all the resulting dead code, and remove that as well. It would have eaten up a week, I'm sure. Everyone had bigger fish to fry, and always would have bigger fish to fry.

As I understand it, Google gets around that problem by having a group of people where frying fish like that is their primary responsibility.

Re:Benefits of a Monorepo by sa46 on Wednesday May 01, 2019 @11:49AM (#19798228)
I don't understand how avoiding bitrot is better in a multi-repo setup. With a multi-repo, if you're changing a core-library you can make the change quickly but you can't upgrade clients until they upgrade on their own. You still have bitrot. The difference is that the bitrot isn't visible because it's compartmentalized into separate repos.
Re:Benefits of a Monorepo by bunderbunder on Wednesday May 01, 2019 @02:03PM (#19799890)
So, to me, different things using different versions of the same library isn't inherently bitrot. For one, if you're actively maintaining your code, then everything's going to eventually end up upgraded. It's just a question of whether you want to boil the ocean all at once, in one big pot, or do it in a series of smaller batches.

There are legitimate arguments for both options. The thing I'm trying to say is, you should beware the idea that going monorepo means the ocean's going to just boil itself somehow.

Re:Benefits of a Monorepo by andolanra on Wednesday May 01, 2019 @12:33PM (#19798810)
The reason that a monorepo facilitates this kind of bit-rot is because of one of the advantages of the monorepo setup: that it also facilitates easily making connections between different parts of the codebase. In a multi-repo setup, you need to be intentional about when and how you pull in another repo, because the bar to doing so is so high. In a monorepo, every piece of every part of the code is available to you and no extra action is required to "pull in" that other repo, which means in practice that without tooling or discipline you end up with a codebase with lots of tight interconnections.

So the reason it happens in a monorepo more is that those connections are easier to make and therefore a lot more common, not because those connections are impossible in a multi-repo setup.

Re:Benefits of a Monorepo by sa46 on Wednesday May 01, 2019 @02:12PM (#19799972)
I see, the argument is that monorepo facilitates tight-coupling because it's easy to add dependencies. The multi-repo doesn't have the same problem because it's more difficult to have cross module dependencies.

There's a number of solutions to prevent tight-coupling.

1. Language-level visibility modifiers. 2. Build system visibility. Bazel offers fine-grained visibility. I'm not sure about others. 3. Using RPCs as the primary interconnect between services.

My view is that disadvantages of tight-coupling in a mono-repo is a much better problem to have than the disadvantages of having logic spread across different repos.

Re:Benefits of a Monorepo by joshuamorton on Wednesday May 01, 2019 @12:30PM (#19798754)
> As I understand it, Google gets around that problem by having a group of people where frying fish like that is their primary responsibility.

I'd rephrase this: Google gets around this problem by having tooling (one such tool is the monorepo) that makes fixing issues like these fairly simple. A straightforward example like this one could be fixed with sed/clangtidy/refaster (depending on the language) + Rosie[1] in a few days, even if there were thousands (or 10s of thousands) of uses. But the work of upgrading is borne by the person doing the upgrade, not client teams who suddenly encounter compile errors when they try to version bump. This is much "fairer".

[1]: https://cacm.acm.org/magazines/2016/7/204032-why-google-stor...

Re:Benefits of a Monorepo by user5994461 on Wednesday May 01, 2019 @02:26PM (#19800124)
Funny you mention this as a drawback, while it's actually a strength of mono repo that is perfectly handled.

For a widely used library. Leave the argument. This argument could be defaulted to NULL, the function can be marked @deprecated and it can log a warning message that the argument has no effect (depending on the language). That's how to handle updates with backward and forward compatibility. No need to break user code.

That's a strength of a mono repo. It only lets you do the right thing. You can't ignore other developers in the company and break all their software.

In a typical multi repo, there is the luxury to change anything anytime, as often as a developer feels like renaming a variable or a parameter. Creating a ton of unnecessary work for other developers who have the pain to keep up. That is, if they ever attempt to upgrade any library, there is no benefit to upgrading and it's impossible to keep up with all changes going on in all libraries thus it's rarely done in practice. The more it's behind, the more work there is to upgrade, the less likely it is to be done.

Re:Benefits of a Monorepo by tsss on Tuesday May 14, 2019 @05:00PM (#19913860)
I don't get how people can live like this. In any decent language with a primitive static type system this would take you 15 minutes at most and you could be sure that it works afterwards.
Re:Benefits of a Monorepo by closeparen on Wednesday May 01, 2019 @12:36PM (#19798857)
This is exactly why we are adopting a monorepo: it makes tasks like this tractable. Across thousands of microrepos, they are not.