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?
View all comments
Show parent comment
3
u/JVApen Clever is an insult, not a compliment. - T. Winters Jul 09 '26
I think we have the same understanding of Hungarian notation. You encode information about the type in your variable name with some prefix. Whatever the actual prefix is doesn't matter for me. I'm also used to having
m_for members, which isn't part of Hungarian (although regularly used together, causing confusion), such that semantics are exposed. Though let's ignore the naming. If you feel better having a p in front of every pointer, just make sure clang tidy is configured correctly, or any other tool that can do this.I read through your code. In the first example, you have several statements followed by an assertion on the same line, just falling off my small screen. You might think this is good design, though it's surprising to anyone not used to the pattern. The pattern also only works for post-conditions for single statements. I'd say it's good that a formatter would be preventing this. Though more importantly, I don't consider this part of architecture.
In the same example, there are several remarks to be made about architecture, like having string and size being 2 separate parameters. I see you already constructing string_view in the function. At least, use a struct for putting the 2 together, such that you have less technical dependencies between parameters. Similarly, you have a value and a type. Also this should be abstracted in a separate type.
The use of align32_g (which also works with 64 integers?) looks also a bit strange to me and distracts from what you try to code. At least one of the functions has a tag to request the aligned value. However, even better would be having a type that knows about the alignment. I'd also wonder if the code is correct, as the new size is not aligned.
Later in the function, you are packing multiple pieces of information in a single integral value. I would expect a class (template) that abstracts this packing. Then it can also assert that all bits expected to be 0, are actually 0. It would prevent magical values like 24 for the shifting.
Then, you are constructing some kind of pstring. I would also expect that in its own type.
Given the remarks above, I believe formatting to be the least of your concern when it comes to architecture/design. If you would submit this for code review with me, I'd send you back to rework.