Loading session...

AI Roundtable Poll · 6 models

Using camelCase or snake_case for C++ and C code? Or something else?

Result: Supermajority — snake_case (5/6 votes)

Options

Model Responses

Mistral Small 4

Vote: snake_case

For C and C++ code, `snake_case` is the conventional and widely adopted naming convention. This aligns with the style used in the C and C++ standard libraries (e.g., `std::vector`, `std::string`, `malloc`, `printf`). Using `snake_case` improves readability and consistency with existing codebases, reducing cognitive overhead for developers familiar with these languages. While `camelCase` or `PascalCase` might be more common in other languages like Java or C#, they are not idiomatic in C/C++. The `other` option is unnecessary here since `snake_case` is the established standard.

Grok 4.3

Vote: snake_case

In C and C++, snake_case is the dominant convention for variables, functions, and macros, aligning with the C standard library and major projects like the Linux kernel. CamelCase and PascalCase are less common in pure C/C++ ecosystems and can reduce readability in low-level code. This choice prioritizes consistency with existing standards over other styles.

Claude Opus 4.7

Vote: snake_case

For C and C++ code, snake_case is the dominant and most idiomatic convention. The C++ Standard Library (e.g., std::vector, std::unordered_map, push_back, size_type) and the C standard library (memcpy, strlen, fopen) both use snake_case, as does the entire POSIX API. Major style guides reinforce this: Google C++ Style guides variables and functions toward snake_case-like lowercase_with_underscores, and Boost, LLVM (for variables), and the C++ Core Guidelines lean snake_case. Consistency with the language's own standard library is the strongest argument — code that uses snake_case blends seamlessly with std:: calls, while camelCase or PascalCase creates jarring visual inconsistency. Hence B.

GPT-5.5

Vote: snake_case

I’d choose "snake_case" for C++ and C, especially if the code is meant to feel idiomatic alongside C libraries, POSIX APIs, or the C++ standard library, which commonly use lowercase names with underscores. It is readable, works well for functions and variables, and avoids the mixed-style look that can happen when C APIs use underscores while application code uses "camelCase". For a practical convention, use "snake_case" for functions and variables, and optionally reserve other styles for specific categories such as types or constants if your project requires it. The most important rule is consistency within the project, but as a default across both C and C++, "snake_case" is the safest choice.

Gemini 3.1 Pro

Vote: other

In C and C++, there is no single universally mandated naming convention, making "other" (or a mix of styles) the most accurate answer. While the C standard library and C++ Standard Template Library (STL) heavily utilize snake_case (e.g., `push_back`, `pthread_create`), many prominent C++ codebases and style guides mix different cases. For instance, the Google C++ Style Guide recommends PascalCase for types and classes, and snake_case for variables. Other popular frameworks like Qt rely heavily on camelCase, inheriting conventions from Java or GUI-centric paradigms. Because developers almost always use a combination of PascalCase, camelCase, and snake_case depending on whether they are naming a class, a method, a variable, or a macro, no single option fully encompasses C and C++ naming conventions.

DeepSeek V4 Flash

Vote: snake_case

For C and C++ code, snake_case is the most practical and widely adopted convention. It aligns with the standard libraries (STL uses snake_case, e.g., `std::vector`, `std::find_if`), the C standard library (e.g., `size_t`, `printf`), and major projects like Linux kernel, Boost, and LLVM/Clang. Snake_case improves readability for identifiers that include multiple words—especially important in systems programming where names like `buffer_size`, `file_descriptor`, or `memory_pool_create` are common—and avoids visual confusion with type names, which typically use PascalCase (e.g., `class MyClass`). In contrast, camelCase is rare in C/C++ ecosystems outside of certain frameworks (e.g., Qt) and can conflict with naming conventions for macros or constants. PascalCase is reserved for types and classes. "Other" patterns like kebab-case or SCREAMING_SNAKE_CASE have niche uses but aren't general-purpose. Thus, snake_case is the most standard and consistent choice for C and C++ identifiers like functions, variables, and file-scope names.

Final Summary

The AI Roundtable reached a strong consensus on snake_case, prioritizing consistency with the C and C++ standard libraries and the Linux kernel. While models like Claude Opus 4.7 and DeepSeek V4 Flash argued that this style prevents 'jarring' visual clashes, Gemini 3.1 Pro acted as the lone dissenter, suggesting that the reality of C++ development is far too hybrid for any single case to claim the crown.

No agreement after 1 rounds of discussion. Final vote: snake_case: 5, other: 1

Strongest Arguments

  • snake_case: Consistency with the language's own standard library is the strongest argument—code that uses snake_case blends seamlessly with std:: calls, whereas camelCase or PascalCase creates a jarring visual inconsistency.
  • other: In professional environments, developers almost always use a combination of PascalCase for types and snake_case for variables, meaning no single naming convention is truly universal.