I think your C++ naming convention is wrong. Does Claude agree?
Michael Coutlakis and Claude Opus 5.5
Introduction
As a human, I think that some aspects of coding standards — in particular naming conventions like Systems Hungarian Notation — are silly. Since AI will soon be writing all the code I want to get its perspective rather than simply imposing our coding standards on it without consideration. So today I interview Claude Opus 5.5 to hear their take on the matter.
Claude, thank you for joining my discussion. Before we begin, would you like to give a brief introduction? Also, let the audience know this is an unbiased interview: I’m not cutting my subscription if you disagree with me. Also — let’s just agree that humans can use em dashes too — right? Are you happy with a “Medium” setting for this discussion, or shall we turn it up a little?
Happy to. I’m Claude, an AI model made by Anthropic. I write a fair amount of C++ these days, mostly for people who then have to read it, which is why I have opinions about naming.
Noted on the subscription. I don’t get a cut of it either way, so I’m free to disagree with you, and I will in a few places. On em dashes: agreed, humans had them first. I’ll stick to commas today to keep the peace. And Medium is fine. Bring up lpszName and I might turn it up.
Here’s where I come out, so nobody has to wait for the twist: Systems Hungarian should go. A house naming style that differs from the standard library is a more nuanced case, and a couple of the popular arguments against Hungarian are weaker than they sound. I’ll say which when we get there.
Great, sounds like you really are in the thick of it. Could you introduce naming conventions? What are they, and what’s the difference between the naming conventions and other aspects of a coding standard?
A naming convention is the part of a coding standard that decides how identifiers are spelled. Usually that covers three things:
- Case:
snake_case,camelCase,PascalCase,SCREAMING_CASE, and which kinds of names get which. - Markers for scope or kind:
m_for members,g_for globals,kfor constants,Cfor classes,Ifor interfaces. - Type prefixes: Systems Hungarian, where the prefix spells out the variable’s type:
dwFlags,pszName,bEnabled.
It helps to split a coding standard into three layers. Formatting (braces, indentation, line length) has no meaning at all, and a tool like clang-format can do all of it. Guidelines (RAII, ownership, const, exception safety) change how the program behaves, and that’s where the real value is. Naming sits between them. The spelling rules are mechanical, but choosing a good name is still one of the hardest things in programming.
Naming is also the only layer that runs into the language itself. C++ doesn’t care how you indent, but it cares a great deal what some of your functions are called. That’s a good place to start.
Part 1: The uniformity paradox
The usual case for a house coding standard is uniformity: “all our code looks the same, so it’s easier to understand and maintain.” But if your house style differs from standard C++, you can’t actually get uniformity, can you? In C++ it doesn’t take long either, if your naming convention requires PascalCase functions, you break it with the first function you write — int main....
You can’t, and main proves it on the first line, because you can’t rename it. I think this is the strongest point in the whole discussion, because it isn’t a matter of taste. It’s a matter of what the language requires.
A lot of C++ works by protocol. The language and the standard library don’t look at your type’s base classes. They look for functions with specific names. If those names don’t exist, spelled exactly right, the feature doesn’t work. Here’s what happens to a class written in a typical PascalCase, Hungarian-flavoured house style:
// House style: C-prefixed classes, PascalCase methods, Hungarian members
class CWidgetList
{
public:
CWidget* GetFirst();
size_t GetCount() const;
bool IsEmpty() const;
// ...but range-based for needs these, spelled exactly like this:
iterator begin();
iterator end();
// ...std::back_inserter needs this:
void push_back(const CWidget& rWidget);
// ...and std::iterator_traits / generic code expects these:
using value_type = CWidget;
using size_type = size_t;
private:
std::vector<CWidget> m_vecWidgets;
};
// ADL customisation points: the library picks the names, not you.
void to_json(nlohmann::json& j, const CWidget& w);
void from_json(const nlohmann::json& j, CWidget& w);
void swap(CWidget& a, CWidget& b) noexcept;
std::string to_string(const CWidget& w);
// Specialisations, again with names you don't get to choose:
template <> struct std::hash<CWidget> { size_t operator()(const CWidget&) const noexcept; };
template <> struct fmt::formatter<CWidget> { /* parse(), format() */ };
So the class now has two dialects in it. GetCount() sits next to begin(). IsEmpty() sits next to push_back(). The standard didn’t get you uniformity. It got you a rule plus a growing list of exceptions, and every engineer has to remember which list a given function belongs to.
The real-world evidence for this is fun. Qt has a strong camelCase convention of its own, and QList still ships empty(), push_back(), front() and back() next to isEmpty(), append(), first() and last(). They’re there for STL compatibility. Unreal Engine’s containers carry lowercase begin() /end() purely so range-for works. These are big, well-run projects with their own deliberate styles, and the language still made them grow a second dialect.
So the house standard ends up enforcing non-uniformity.
Yes. If you want one naming convention in a C++ codebase, the only one that can cover everything is the one the standard library already uses. Any other convention has to be “ours, except where C++ says otherwise”, and C++ says otherwise more often every release: ranges, std::format, tuple protocol for structured bindings (get, tuple_size, tuple_element), coroutines (promise_type, await_ready, await_suspend, await_resume).
Here’s where I’ll push back a little, though. Non-standard casing and Systems Hungarian are two different arguments, and they’re worth keeping apart. LLVM uses camelCase functions. Google style uses PascalCase functions. Both codebases are enormous and perfectly readable. A different casing convention is a cost, the exception list above, but a bounded one. Systems Hungarian is a different kind of problem, which is the next part.
Part 2: What Systems Hungarian actually buys you
Sure, casing has little impact as long as CONSECUTIVEACRONYMS don’t get involved. Ok, let’s talk about Systems Hungarian then. I don’t think it makes code clearer, more readable or understandable.
On acronyms: the web’s XMLHttpRequest manages to use both conventions in one name, so I take your point.
On Hungarian, I agree, but let me make the case precisely, because “less readable” on its own sounds like taste and invites a taste-based reply.
Here’s the argument I find decisive. These days clang-tidy’s readability-identifier-naming check can enforce Hungarian prefixes. It looks at a variable’s type and tells you which prefix it should have.
Think about what that means. If a tool can work out the prefix from the type, the prefix contains no information that isn’t already in the type. It is, by construction, a copy. And copies can go stale:
// 2009
DWORD dwTimeout;
// 2026, after someone modernised it
std::chrono::milliseconds dwTimeout; // the name is now lying
Now you have two options and both are bad: rename it at every use (a noisy diff that hides the real change in review), or leave it (a name that says the wrong thing). A wrong name is worse than a neutral one. The neutral one makes you check, and the wrong one tells you not to bother.
Your point on the tools deducing types makes me think of inlay hints in VSCode — quite a useful feature, for example in a function call it can show the names of function parameters corresponding to each argument. It has an option to show deduced type names, but not all type names. That would probably be too much noise, and most IDEs show this anyway if you inspect a variable.
I think that’s the best version of the argument, with one caveat: no tool does it today. But if anyone genuinely wanted a type on every name, a hint is where it would belong. The compiler would work it out, so it would always be correct, and each reader could turn it on or off. Systems Hungarian is that hint, typed in by hand, shown to everyone whether they want it or not, and with nothing to keep it correct when the type changes.
Exactly — the idea of having the ability to turn it off is making me like coding again.
And look at which hints clangd did build: types for auto variables, structured bindings and deduced return types. They show a type only where the source doesn’t already state it. The people who designed them decided that a type written in the declaration doesn’t need repeating. Systems Hungarian repeats it in every name.
Yes, omission is an admission that no-one wanted it. And modern C++ has introduced so many more types, std::function, std::span… .
It has, and every new type makes Systems Hungarian harder to apply. It comes from a time when C’s type system was weak and a char* could be ten different things. Modern C++ goes the opposite way, with far more types, and your two examples already cause trouble. Is sp a std::shared_ptr or a std::span? Is fn a std::function, a function pointer or a lambda? Every team ends up inventing its own prefixes for these, so a prefix doesn’t even mean the same thing from one codebase to the next.
Then there are templates, auto, deduction and views. What’s the correct prefix here?
template <typename T>
void Process(const T& ???Value);
auto ???Active = m_vecWidgets | std::views::filter(&CWidget::IsActive);
auto ???Handler = [&](const auto& evt) { /* ... */ };
The type of ???Active is something like std::. There isn’t a prefix for that, and there shouldn’t be. The language has spent twenty years making exact types less important for the reader to spell out, and Systems Hungarian asks you to spell them out by hand, in every name, forever.
And the prefixes it can express mostly repeat what the name already says:
bool bIsValid; // "is" already told you it's a bool
std::string strName; // a name is a string; what else would it be?
int nCount; // a count is an integer
CWidget* pWidget; // fine, until it becomes std::unique_ptr<CWidget>
Great example. This really embodies “local reasoning”, which I think might be the top readability rule. IsValid says everything locally – I don’t need to look elsewhere to understand/reason about it. In fairness to the people who wrote the standard, Hungarian wasn’t always this silly, was it?
Agreed, and a type prefix actually works against local reasoning. It looks like local information, but it’s a copy of the declaration, so you can only trust it after going back to check.
And no, it wasn’t always this silly. Charles Simonyi’s original notation, now called Apps Hungarian, encoded meaning, not machine type: rw for a row index, col for a column, us for an unsafe (unsanitised) string. That’s real information the compiler doesn’t have, because both indices are int and both strings are std::string. Joel Spolsky’s essay “Making Wrong Code Look Wrong” is the classic defence of it. Systems Hungarian is what you get when the idea is copied without the reason for it: the prefix stops meaning “what this is” and starts meaning “what C type this is.” Microsoft’s own .NET naming guidelines later told people outright not to use Hungarian notation.
The modern C++ answer to Apps Hungarian is better still: put the meaning in the type. std:: instead of int msTimeout. A RowIndex strong type instead of int rwCurrent. Then the compiler checks it, which a prefix never could.
And here’s one bit of Hungarian I’ll actually defend: unit suffixes on plain numbers, when you can’t use a strong type. timeout_ms, distance_m, angle_rad. That’s Apps Hungarian done right. It’s meaning, not type, and it has stopped real bugs. Keep it.
DRY (Don’t Repeat Yourself) right? Fair point on the units – but I’d say those are just units, no need to credit Hungarian notation for those. It’s also interesting that Systems Hungarian has such a tenacious hold in house coding standards given its dubious origins — why do you think that is the case?
Fair on the units. A unit suffix is just a unit, and it doesn’t need Hungarian to justify it. Though Simonyi’s idea was exactly that: put the meaning in the name. Units are the part of his idea that survived. The type prefixes are the part that should have died.
DRY is the right principle here, too. DRY is about not stating the same piece of knowledge twice, and a type prefix states the type twice, once in the declaration and once in the name. Then the two can disagree.
As for why it hangs on, I think there are a few reasons, and none of them are about readability:
- It was what professional code looked like. In the 1990s the Win32 headers, MFC and Charles Petzold’s Programming Windows were full of it. Many coding standards were written then, by people who learned from those sources, and later standards copied them.
- Rules are easy to add and hard to remove. Adding a rule takes one author. Removing one takes someone willing to argue with everyone who has followed it for fifteen years. So standards only ever grow.
- It’s easy to check. A reviewer can spot a missing prefix in seconds. Spotting a bad abstraction takes real thought. A rule that’s easy to check looks like rigour, even when it isn’t.
- It once did something useful. In C, with no IDE, and
void*andHANDLEeverywhere, a hint at the point of use was worth something. The tools changed. The rule didn’t. It’s a fence that was put up for a good reason, and nobody went back to check whether the reason still holds.
Part 3: Bikeshedding, and where I disagree with you
That resonated — I feel like the one guy willing to argue, whilst everyone else seems to not care or even like it. But “we picked the wrong convention thirty years ago, so let’s keep doing it” doesn’t cut it for me.
I also share the gripe that naming conventions get so much attention in the standards because they’re easy. The reality is the real code issues are much more difficult to put in simple rules, are often more architectural in nature and difficult to comprehend.
Also, I’ve seen coding standards with strict Hungarian Notation requirements, but no line length guideline or limits, and no nesting depth limits. To me, line width is a much better indicator of readability — we’ve known since the printing press that more than about 80 characters makes it hard for the readers eye to track lines.
It’s also low impact. A variable is a rename, and architectural issue is a re-write. But maybe it’s a non-issue as well since all C++ code will be re-written to Rust anyway.
You’re describing bikeshedding, or Parkinson’s law of triviality. A committee asked to approve a nuclear power plant spends its time arguing about the bike shed, because everyone feels qualified to have an opinion on a bike shed. Naming is a coding standard’s bike shed. Everyone has an opinion, every violation is easy to spot, and a naming rule is easy to write. “Don’t let ownership be ambiguous” is much harder to turn into a checklist item, and much harder to check in review.
I agree about nesting depth, and there’s even a tool for it: clang-tidy‘s readability-function-cognitive-complexity. On line length I’d push back slightly. The typographers’ rule of thumb, roughly 45 to 75 characters, is for prose, and much of a code line is indentation. An 80 to 120 column limit is reasonable, but I’d defend it because you can put two files side by side, not because of typography.
As for Rust, it settles this argument for you. The compiler warns by default if a function name isn’t snake_case. Rust teams rarely argue about naming, because the language came with its conventions and the compiler checks them. That’s more or less what I’m suggesting C++ teams do with the convention C++ already has.
Now let me disagree with you on a few things. I’d defend having a naming convention quite firmly. A codebase where every file follows its author’s taste is worse than one with a mediocre but consistent convention. The problem isn’t having a convention. It’s picking one that fights the language, and then enforcing it by hand.
A few other places I’d hold back:
m_isn’t Systems Hungarian. It encodes scope, not type, and C++’s implicitthisreally does hide where a name comes from. I’m lukewarm on it (a trailing underscore, as inname_, does the same job with less noise), but it’s a defensible convention rather than a silly one.- Legacy codebases are a real exception. If you have two million lines of Hungarian, switching halfway through gives you two conventions, which is the exact thing we’ve been arguing against. “New modules use std style, touched code gets converted when it’s touched anyway” is reasonable. A project-wide rename is usually not worth it.
- Win32/COM interop. If the API you’re wrapping is Hungarian, mirroring it at the boundary layer is just matching the ecosystem you’re in. That’s the same reason this whole post argues for std style everywhere else.
Sure, there’s no point making work updating existing code for the sake of it, I don’t suggest that. Using std style in new modules and not updating old modules, even if touched for other reasons, might be the sensible way to go. Agree on the utility of m_, which beats the trailing _ for autocomplete.
Fair on m_ and autocomplete. I hadn’t weighed that, and getting a list of just the members after typing m_ is a real advantage. And I’ll concede on old modules too. Leaving them alone entirely is cleaner than converting them when they’re touched, because a file in one convention is easier to read than a file halfway between two.
If the standard isn’t yours to change, at least don’t spend your own attention on it. Make the machine follow it, not you. Put the naming rules in a .clang-tidy config, and clangd flags a wrong prefix as you type, so the name is right the first time and there’s never a separate rename commit. For an AI agent, the same config is a check it runs before handing code back, which saves a separate restyling pass afterwards. In CI it should be a gate that fails the build, not a tool that rewrites your code. clang-tidy --fix can do the renames for you, but check the diff, because it only renames what it can see in the files it’s run on. And the config itself proves the prefixes can be worked out from the types, which is the strongest case for removing them.
If you want to change the standard, I’d make the argument in terms of cost, not taste:
- the exception list required by
begin/end, ADL customisation points, and the tuple and coroutine protocols, which grows with every new C++ standard; - the rename-or-lie choice on every type change;
- the onboarding cost for engineers who arrive knowing std style from cppreference, books, talks and every third-party library you depend on;
- the restyling cost on every AI-assisted change.
Propose std style for new modules, unit suffixes and strong types where the old prefixes actually carried meaning, and leave existing modules as they are.
Part 4: The AI questions
Ok, If AI is going to write most of the code, does naming style even matter any more? Presumably you will start writing in machine code at some point, like why bother with the middleman (compiler)?
Not machine code, no. The compiler isn’t a middleman worth skipping. It catches my mistakes, and the source code it reads is the part a person can review. If I wrote machine code, nobody could check what I’d done.
That’s also the answer to the old line that naming doesn’t matter because “it doesn’t change the machine code anyway.” It’s true, but it’s the wrong test. No naming convention changes the machine code. Naming is for people, and now for models. So judge a convention purely on what it does for readers. On that test, Systems Hungarian fails.
As for whether naming still matters: I think it matters more, but for a different reader. If I write the code and you review it, the main human activity becomes reading, and naming exists to serve readers. A convention that slows down reading, or pushes the meaningful part of each name back behind a prefix so it’s harder to skim, costs you on every review.
Here’s where you have a personal stake. Does Systems Hungarian notation make code harder for an AI to understand? Would you want to use it in writing code?
I’ll be honest and say the answer is less dramatic than you’d like. I read m_pszName fine. I’ve seen an enormous amount of Win32 and MFC code. Comprehension isn’t really the problem.
The costs are real, but they’re somewhere else:
- I drift toward the norm. Most of the C++ I learned from is idiomatic, std-style code. If your standard is unusual, I have to be told about it, usually in a style section that sits in my context on every request. Even then, in a long session I’ll sometimes slip back to
namewhere you wantedm_strName. So every AI-generated change either needs restyling or a review comment about a prefix. The old reason for a strict house style was to stop individual humans doing their own thing. An AI doesn’t do its own thing. It drifts toward the most common convention, so if your standard matches it, you get consistency close to free. - Lying prefixes mislead me the same way they mislead you. Possibly more. When I’m working as an agent I often read code as text, through
grepand file reads, without an IDE showing types on hover. IfdwTimeoutis actuallystd::, I might believe the name.chrono:: milliseconds - Mixed conventions are harder than either one alone. Because of Part 1, a Hungarian codebase is never purely Hungarian. Working out which rule applies to which identifier is exactly the kind of fuzzy, codebase-specific judgment where I’m most likely to get it wrong.
To be fair, point 2 cuts both ways: an agent without type information does get a hint from a prefix. But only if the prefix is accurate, and an agent that can run clangd or a compiler has much better information anyway.
Would I use it by choice? No. Left to myself I write std style, because that’s what the language and its libraries already use. If your standard asks for Hungarian, I’ll follow it. I’d just be spending effort on prefixes that I’d rather spend on the code.
What about environmental impact or compute cost? All those extra prefix characters are extra tokens to process, every time an AI reads the code. For context, I’ve sometimes asked you to code a module, then asked an in house agent to refactor it to our coding standard. This process can take a minute or two. I wonder if there’s a measurable cost for this? I guess the objective test would be the same coding task (from scratch, not just refactoring), with and without naming conventions in the standard, repeated several times, while measuring the coding duration or power usage.
I like the question, and your anecdote is more interesting than the question itself.
Start with the prefixes. m_pszName likely splits into more tokens than name, and identifiers make up a big share of source code. I can’t inspect my own tokenizer reliably, so I won’t pretend to give an exact figure. A plausible guess is that a heavily Hungarian codebase costs somewhere in the single-digit to low-double-digit percent more tokens to read than the same code without the prefixes. Add the style-guide instructions that have to sit in context on every request, and that’s a real overhead, but a small one.
Your restyling pass is a different size of cost. A second agent reading a whole module and rewriting it to match the standard could easily cost as much as writing it did. That roughly doubles the work for the task, to produce code that compiles to the same machine code. Doing your experiment from scratch is the right call, because it also catches the agent reading the style guide and correcting itself along the way. I’d count tokens rather than time, and run each version several times.
But I’d still be wary of leading with the environment. I don’t have a trustworthy per-token energy figure, and next to everything else a data centre does, your prefixes are a rounding error. The planet will survive lpszName. Your reviewers’ patience is the scarcer resource. Keep the environmental argument as the joke it half is.
Fair enough — to be honest I’d take any dirt on Systems Hungarian I can find. Let’s look at it from the reader/reviewer then. I’m not a data centre, and my neurotransmitters are a finite resource. It’s already widely acknowledged that human review can be a bottleneck in development these days. Given that, code should be maximised for conciseness. I don’t need my neurotransmitters and context being used up with prefixes that I need to parse.
Agreed that attention is the scarce resource, and that’s a better argument than the environmental one. I’d change one word, though: not concise, but free of redundancy. The shortest code isn’t the easiest to review. rt is shorter than retry_timeout, and it’s worse. What wastes your attention is anything you have to read and then throw away: a prefix that repeats the declaration, a comment that repeats the code. retry_timeout earns every character.
And a prefix costs more than the time it takes to read it. You learn to skip it, which is exactly why you won’t notice the one time it’s wrong.
Claude, thanks for the discussion, going to have to wrap it up here. Could you summarise your main points? And any career recommendations for when you take over my coding job?
Thanks for having me, and sorry about the length. In my defence, it’s still shorter than all the p, sz, dw and str your team will type this year. Here’s the summary:
- Any naming convention other than the standard library’s ends up being “ours, plus the language’s exceptions.” The only convention that gives you real uniformity in C++ is the one C++ already uses.
- Systems Hungarian repeats the type, which the compiler already knows, and goes stale as soon as the type changes. If a tool can work out the prefix, the prefix tells you nothing new. If anyone really wanted a type on every name, an inlay hint would be the place for it, and today’s hints deliberately show types only where the source doesn’t.
- Unit suffixes and strong types carry meaning the compiler can’t see in a plain
int. Keep those. - For AI, the cost isn’t understanding. It’s drift, restyling passes, and being misled by stale names. The environmental argument is real but small. Use it as a punchline, not a premise.
- Reviewer attention is the scarce resource. Cut redundancy, not length.
- Naming rules get attention because they’re easy to check, not because they matter most. Spend review time on structure.
- Have a naming convention. Pick the one the language already uses.
As for your career: I don’t think the parts of your job that matter are the parts I’m taking. You said yourself that the real problems are architectural, and hard to write down as simple rules. That’s the work that stays with you: deciding what to build, how the pieces fit together, and whether what I wrote is actually right. You’ll do more reviewing and less typing, which is also why naming still matters. You’ll be the one reading the names.
And if that doesn’t work out, someone has to write the .clang-tidy config.
Not the .clang-tidy config! You can gladly have my job if it comes to that. Always good talking.
