Naming Conventions in 6 Major Programming Languages
Every programming language has its own rules for naming variables, functions, classes, and constants. Here's a complete reference for JavaScript, Python, Java, C#, Go, and Rust — and why the conventions differ.
Published February 28, 2026 · By Sudip Bhowmick
Naming conventions are not arbitrary preferences — they are documented standards backed by official style guides, compiler warnings, and community consensus. Following the wrong convention in a language is a signal that you've imported habits from another ecosystem. This guide maps the naming conventions for six widely used languages: JavaScript/TypeScript, Python, Java, C#, Go, and Rust.
JavaScript and TypeScript
JavaScript has the most case variety of any mainstream language because it covers so many identifier types:
- ▸Variables and functions: camelCase — getUserById, isAuthenticated, handleButtonClick
- ▸Classes and constructor functions: PascalCase — UserService, NavigationMenu, EventEmitter
- ▸React components: PascalCase — required by React, not optional — <UserCard />, <NavMenu />
- ▸TypeScript interfaces and type aliases: PascalCase — interface UserProfile, type ApiResponse
- ▸Module-level constants (fixed values): CONSTANT_CASE — const MAX_RETRIES = 3
- ▸Enum members (TypeScript): PascalCase — enum Direction { North, South, East, West }
The Airbnb, Google, and Standard style guides all align on these conventions for JS/TS.
Python
Python's naming conventions are formally defined in PEP 8, the official Python style guide:
- ▸Variables and functions: snake_case — user_name, get_user_by_id, calculate_total
- ▸Classes: PascalCase — UserProfile, DatabaseConnection, HttpRequestHandler
- ▸Module and file names: snake_case — user_service.py, database_config.py
- ▸Constants: CONSTANT_CASE — MAX_CONNECTIONS, DEFAULT_ENCODING
- ▸Private attributes and methods: _single_underscore prefix — self._cache
- ▸Name mangling (strong privacy): __double_underscore prefix — self.__private_data
Python is distinctive for using snake_case for virtually everything except class names, which contrasts sharply with JavaScript's mixed conventions.
Java
Java has some of the longest-established and most rigorously followed naming conventions, formalized in the original Java Code Conventions document:
- ▸Variables and methods: camelCase — firstName, getUserById, calculateTotal
- ▸Classes and interfaces: PascalCase — UserService, Comparable, HttpRequestHandler
- ▸Constants (static final): CONSTANT_CASE — public static final int MAX_SIZE = 100
- ▸Packages: all lowercase, no separators — com.example.userservice
- ▸Generic type parameters: single uppercase letters — T, E, K, V
Java's conventions are especially strict around package names, which use all-lowercase reversed domain names as the namespace.
C#
C# has the most PascalCase of any mainstream language — Microsoft's official guidelines extend it to nearly all public members:
- ▸Public methods, properties, classes, namespaces: PascalCase — GetUserById, UserProfile, DataService
- ▸Private fields: _camelCase with underscore prefix — _userId, _connectionString
- ▸Local variables and method parameters: camelCase — userId, connectionString
- ▸Interfaces: IPascalCase with I prefix — IDisposable, IEnumerable, IUserRepository
- ▸Constants: PascalCase (not CONSTANT_CASE, unlike most other languages) — MaxRetries, DefaultTimeout
C# is notable for using PascalCase for constants rather than CONSTANT_CASE — a convention that surprises developers coming from Java or Python.
Go
Go uses a distinctive convention tied directly to visibility — whether something is exported (public) or unexported (private) depends entirely on whether the first letter is uppercase or lowercase:
- ▸Exported identifiers (public): PascalCase — func GetUser(), type UserProfile struct
- ▸Unexported identifiers (private): camelCase — func getUser(), type userProfile struct
- ▸Constants: PascalCase if exported, camelCase if unexported — MaxRetries vs maxRetries
- ▸Acronyms: all caps when exported — ServeHTTP not ServeHttp, parseJSON not parseJson
Go's export system makes case directly semantic: uppercase = public API, lowercase = internal detail. This is enforced by the compiler, not just convention.
Rust
Rust enforces naming conventions at the compiler level — rustc emits warnings (treated as errors in most projects) for violations:
- ▸Variables and functions: snake_case — let user_name, fn get_user_by_id()
- ▸Structs, enums, and traits: PascalCase — struct UserProfile, enum Direction, trait Display
- ▸Constants and statics: CONSTANT_CASE — const MAX_RETRIES: u32 = 3
- ▸Modules and file names: snake_case — mod user_service, user_service.rs
- ▸Enum variants: PascalCase — enum Status { Active, Inactive, Pending }
Rust is among the strictest ecosystems for naming conventions because the compiler enforces them. A Rust codebase with wrong case conventions will produce build warnings on every affected identifier.
Conclusion
The pattern across languages: snake_case dominates in Python and Rust for functions and variables; camelCase dominates in JavaScript and Java; PascalCase is near-universal for class names and types; CONSTANT_CASE is nearly universal for constants (with C# as the notable exception). Go uses case to encode visibility, making it semantic rather than purely stylistic. When working in a new language, read the official style guide — the conventions are documented, widely followed, and meaningful.
Free Tool
Try the Convert Case Tool