r/cpp • • Jul 05 '26

Formatting vs Architecture: How formatters are erasing visual cues and hurting codebases

I’m preparing a presentation on how automatic formatters can actually ruin code management over time. This relates heavily to the ongoing discussions about C++ memory safety and why some people see it as a critical issue while others don't get the fuss since basic memory allocation isn't that hard.

Memory issues are usually just a symptom of architectural failure, not a lack of developer skill in handling allocations. A messy architecture turns minor oversights into catastrophes. That's when hidden memory leaks or memory corruption become critical safety flaws and crashes.

I often think about the (nowadays) hated Hungarian Notation. Love it or hate it, it made developers extremely efficient because it provided immediate visual cues. Developers who actively care about the visual shape of text think completely differently about code structure. If you look at Charles Simonyi's other work, it’s clear how much focus he had on architecture.

Formatters can be an absolute disaster for architecture. It has become a religion in development teams that everything must be run through Prettier or Clang-Format to the letter. But the price we pay is that formatters erase all opportunities for visual cues regarding architecture and layers.

Architecture is WAY more important than formatting.

Code is text. By deliberately allowing flexibility in how to format, we can highlight major patterns and make code much easier to reason about. When a formatter forces all code through the same rigid, mechanical template, all code looks identical. The architecture becomes invisible. Ironically, this causes codebases to rot because developers in the team can no longer see where the architectural boundaries actually are.

Formatting in itself isn't bad, but it must be a formatting style that elevates the architecture and allows for human semantic grouping. The opposite is dangerous.

As far as I know, there is no formatter out there today that is anywhere near capable of handling the flexibility required to actually make architecture visible in code.

What are your thoughts on this? Have formatters made us blind to the actual structure and layer belonging of our code?

EDIT

To those of you who only see problems with this approach: what is your actual alternative for managing cognitive load at scale?

The common stance seems to be "just write code however you want, as long as the automatic formatter makes the layout look consistent."

But formatting only fixes cosmetic consistency, it doesn't fix structure, architectural boundaries, or intent. If you believe that naming conventions, prefixes, and semantic text layouts are useless, you are essentially advocating for visual anarchy disguised as "clean text". How does a mechanical linter help a new developer navigate architectural layers in a large codebase if the code itself provides zero visual cues about where the boundaries go?

0 Upvotes

130 comments sorted by

View all comments

Show parent comment

-4

u/gosh Jul 05 '26

If a company has a selected style, you follow it. That's not what this is about.

This isn't a petty fight over curly braces or tabs vs spaces, that is purely cosmetic. My point is about structural layout. If a team doesn't have a rigid formatter flattening everything out, you can actually use the visual structure of the text to understand boundaries and improve the architecture.

Reducing an architectural discussion down to "where you put your brackets" completely misses the point of how visual cues affect cognitive load.

0

u/[deleted] Jul 05 '26

[deleted] — view deleted comment

-5

u/gosh Jul 05 '26

You are completely misunderstanding my point. This is not about individual engineers using their own personal "feelings" or styles to format code. That obviously causes chaos in a team.

It is about the team establishing a shared, semantic visual pattern, precisely like the engineering philosophy behind Hungarian Notation.

You mentioned primitive types. Take standard prefixes like b, i, u, d, p (bool, int, unsigned, double, pointer). The massive benefit of a shared notation like this isn't actually to read them; it is to skip them. If a method has 15 variables and 12 are primitives with clear prefixes, the developer's brain instantly filters them out to focus on the 3 complex domain types that actually matter.

This is about cognitive efficiency. The ultimate goal of software architecture and semantic formatting is to write code in recognizable visual patterns so that it does not need to be read line-by-line to be understood.

Human brains scale through pattern recognition, not by parsing raw text like a compiler. When an automatic formatter forces a flat, mechanical style across every single layer, it destroys those patterns. If your only tool for communication is a text comment or a wiki entry, you are relying on a medium that actively rots and slows down development in a 200k+ line codebase.

Dismissing visual ergonomics as "healing candles" just shows a lack of understanding of how human cognition operates at scale.

0

u/[deleted] Jul 05 '26

[deleted] — view deleted comment

-2

u/gosh Jul 05 '26

You are still missing the core point. This has nothing to do with my "preferred" style or personal feelings.

The medium we are using right now is a Reddit text thread. I am skim reading and replying quickly. But in a real software team, there is more time and I know how reddit "works". Very hard to have deep conversations

My point is, and always has been, about architecture. It is not about a specific style.

The problem with automated formatters is that they make developers stop thinking about the visual structure of their code. When a machine flattens everything into an identical, mechanical template, the architectural boundaries disappear.

If you want to know what my actual personal preference is: it would be to not use formatters at all, just turn them off.

ability to adapt their code's layout to highlight its architectural layers, the architecture becomes invisible, and the codebase eventually rots. That is the only thesis here.

0

u/[deleted] Jul 05 '26

[deleted] — view deleted comment

-2

u/gosh Jul 05 '26

Since you are out, I'll leave you with a very practical question to think about: How many legacy codebases across different companies have you actually audited?

If you had audited as many as I have, you would know that it is an empirical fact, not a mere "claim", that the vast majority of corporate codebases are in a abysmal, rotting state. And guess what? Many of those broken, unmaintainable systems run automated formatters and linters to perfection.

0

u/[deleted] Jul 05 '26

[deleted] — view deleted comment

0

u/gosh Jul 05 '26

That isn't an argument. And goes back to what I said that your vision of your claim isn't enough to convince others that that claim holds merit.

Don't you think I know how hard this is to explain to developers today? It wasn't this hard to explain 20+ years ago, but today it is almost impossible.

Some understand it, and they are the ones who become those "10x developers". But it is extremely difficult to get through today because the groupthink is massive, and modern software development is completely dominated by Big Tech dogmas.

-1

u/gosh Jul 05 '26

That question is teetering pretty close to appeal to authority, but since you asked, and I have said this in the past in this sub.

And what have you learned from auditing all those engines and browsers?

Look at Chromium, which you mentioned. We live in a world where one browser engine essentially holds a monopoly. Why? Because the codebase has become so overwhelmingly complex and architecturally rigid that it is nearly impossible for anyone to build a modern competitor from scratch.

When codebases reach that scale, teams are forced to introduce extreme administrative overhead, rigid automated formatters, and layers of QA just to keep the system from collapsing. But that proves my exact point: those tools are introduced as an emergency brake because the code itself has become visually stum. The text layout no longer gives the developer any native, human semantic cues about boundaries, so you have to let a machine enforce safety via formatting.

0

u/[deleted] Jul 05 '26

[deleted] — view deleted comment

→ More replies

5

u/ts826848 Jul 05 '26

We live in a world where one browser engine essentially holds a monopoly. Why? Because the codebase has become so overwhelmingly complex and architecturally rigid that it is nearly impossible for anyone to build a modern competitor from scratch.

OK, sure, let's assume Chromium's codebase is indeed "overwhelmingly complex and architecturally rigid". I strongly suspect that people don't decide to use Chromium because of that, though.

A significant portion (if not majority?) of Chromium (or Chrome/Electron/etc.) users rely on its output/behavior, like how webpages/UIs render/behave/perform/etc., and those users pick Chromium+derivatives for function/uniformity/consistency/etc. instead of having to deal with browser/engine-specific breakage/quirks. In these cases the quality of the codebase has zero direct impact on a potential user's decision to use Chrome since they aren't directly interacting with the C++ code.

In addition, web standards are complex and they're not getting simpler any time soon. It's a lot of work to implement a web browser even with "perfect" code, and few would have the time/energy/interest in doing so, especially if a browser isn't your main product.

Because the codebase has become so overwhelmingly complex and architecturally rigid that it is nearly impossible for anyone to build a modern competitor from scratch.

This seems like a non-sequitur. Why would the complexity of Chromium's codebase have any impact on an independent codebase, especially since compatibility is generally dictated by web standards and not C++ APIs?

2

u/serviscope_minor Jul 06 '26

Many of those broken, unmaintainable systems run automated formatters and linters to perfection.

Sure? But also, so what? They also pass all the type checks built into the compiler cleanly, but having them be bad isn't a justification for abandoning type checking.

Firstly I have no idea what your architecture through formatting looks like.

Secondly as someone else pointed out, autoformatting prevents bikeshedding. That alone is reason enough to use it. Some people care way, way too much about the exact positioning of braces and whatnot. I've worked in enough codebases that I barely see it anymore[*]. I used to care a lot. Now I don't. Every so often I do use formatting to show something, usually making things aligned to make it easy to see similarities, so maybe a few extra spaces are needed.

No tools will fix fundamentally broken processes but they can help make things a bit better. If I never have to argue a bikeshedding formatting comment on a PR again I will be happy. If I never have to debug a silly bug which was caught by running basic checks again I will be happy.

[*] FSF I love what you've given us, but good god your house indent style makes my eyes bleed.

1

u/gosh Jul 06 '26

Secondly as someone else pointed out, autoformatting prevents bikeshedding

How?

way too much about the exact positioning of braces and whatnot.

This is not about braces, far from it

1

u/serviscope_minor Jul 06 '26

Well if auto formatting puts braces in the same place there's no arguing about that on PRs.

So ok not about braces but you've never said what it is about except in general terms. Please provide a concrete example, because I don't understand what you've written so far.

→ More replies