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
1
u/JVApen Clever is an insult, not a compliment. - T. Winters Jul 11 '26
I find it strange that you don't find readability a prerequisite for debugability. If you can't read the code in a easy way, how are you going to debug efficiently? Readability is all about the cognitive load. The harder it is to read, the more load you need for it.
I don't see how searchability becomes worse due to formatting, unless you only use text/regex search. I'm using clangd in vscode, which perfectly allows me to search whatever I need. The results of that are much more reliable than regex.
I'm open for your argument of cognitive load. It's exactly why I would like to run the clang modernizer checks on our code base. However, you are missing a piece of the puzzle here. Something I also only learned/accepted after years in always-auto. If your types are well-designed, the details don't matter.
Let me come back to a previous example. You are packing 2 (or more) numbers in a single integer field. You seem under the impression that having these bit operations in your function is important. This however is exactly the thing stealing your attention. If you have a decent type for it, it doesn't matter how it's stored. It can be a packed integer or a pair of integers. It will have assertions/contracts to check all preconditions. If you have such a common type, you are also much more inclined to write assertions. A debug visualizer on that type can help debugging much more than seeing the operations. And your code becomes: "store this value". Much easier to understand, making the cognitive load less and the code more reliable and testable. Instead of dealing with details, you can now focus on the flow of your program. This makes debugging much easier.
This holds for about everything in your Hungarian prefix. Make sure you have a good/clear type and it doesn't matter. Wether something is a pointer of not, will be clear from using it with
.,*and->. Though it doesn't matter in the flow of your function. It only matters when changing your code, where your LSP or compiler will tell you if you did it wrong.Let me end by circling back to what I said before: you have bigger problems with architecture/design than formatting. I'm quite sure I won't be able to convince you right now of that. Though I do hope you understand my reasoning, even if you disagree.