Coding standards provide guidelines on how to write code with the intention of following best practices and ultimately improving software quality.
Most programming languages have coding standards assembled to provide rules and guidelines on using best practices for that particular language. For languages with similar syntax and rules, some standards can also be used interchangeably between such languages.
Advantages of following coding standards includes code with improved readability, security, maintainability, safety and robustness.
The source of coding standards can vary and exist in many forms. They can be documented rules set by a development team, industry level rules and regulations on code written for critical level applications or coding guidelines written by individuals to ensure consistency in their programming style.
All these together form coding standards developers use to increase the efficiency and performance of the program and to even reduce technical debt.
To put it simply, coding standards any set of documented rules and guidelines that recommend coding practice and styles that when followed should lead to improved code quality.
This article will list some popular coding standards that are useful for software practitioners to follow when writing code for a particular programming language. It’s not a complete reference list and of course, there are tons more coding standards for each language!
We’ll list coding standards for 11 programming languages, 10 of these featured in the top 10 ranked programming languages according to the PYPL index.
Python
PEP8 Style Guide for Python Code
PEP8 (Python Enhancement Proposal) is a coding convention for Python that aims to offer readability and consistency in a Python code base.
Java
Google Java Style Guide
Google’s own ‘Google Style’ coding standards for Java. Focuses on providing guidelines that can be clearly enforceable.
SEI CERT for Java
This is a coding standard from the CERT (Computer Emergency Response Team) for the SEI (Software Engineering Institute).
It focuses on providing rules to improve the protection of software applications against security vulnerabilities.
Javascript
Google JavaScript Style Guide
Google’s own ‘Google Style’ coding standards for JavaScript. Focuses on providing guidelines that can be clearly enforceable.
Airbnb Javascript Style Guide
A widely adopted set of coding guidelines for Javascript using Babel.
C#
Microsoft C# Coding Conventions
This presents the guidelines Microsoft follows when writing C# code for samples and documentation.
Philips Healthcare C# Coding Standard
A coding standard with objectives of avoiding errors/bugs and improving maintainability through proven design principles.
C/C++
MISRA C/C++
MISRA stands for Motor Industry Software Reliability Association. MISRA comes as a standard for C and C++ and is a widely adopted standard for Embedded systems applications. While it has ‘Motor’ in the title it is also used for several security and safety critical systems such as railway, aerospace, telecommunications and medical.
SEI CERT for C/C++
This is a coding standard from the CERT (Computer Emergency Response Team) for the SEI (Software Engineering Institute).
It focuses on providing rules to improve the protection of software applications against security vulnerabilities.
The Power of 10: Rules for Developing Safety Critical Code
Created by an engineer at the NASA Jet Propulsion Laboratory in 2006, these 10 rules were created for C programs running mission-critical applications. They were formulated to provide a concise but strict set of rules that aims to improve software reliability and testability.
These 10 rules can be a good reference for C developers who are looking for a minimal set of rules to follow but will positively impact the robustness of their code base.
PHP
WordPress PHP Coding Standards
WordPress is a content management system that runs on PHP. They present these guidelines for developers writing any application code in PHP for WordPress.
PHP-FIG Basic Coding Standards
A concise set of basic rules that must/should be followed to ensure compatibility between shared PHP code.
R
Tidyverse R Style Guide
R style guide to improve readability.
Objective-C
Apple’s Cocoa Objective-C Coding Guideline
A widely adopted guideline from Apple covering naming conventions and recommended best practices.
TypeScript
Google TypeScript Style Guide
Google’s own ‘Google Style’ coding standards for TypeScript. Provides both rules and best practices that can be picked according to the needs of a development team.
Swift
Apple Swift Language Guidelines
Swift is used primarily for Apple platform development and Apple covers good practices for writing in Swift in this guide.
Google Swift Style Guide
Google’s version of a Swift guide largely inspired from Apple’s own guide.
HTML/CSS
W3School HTML Style Guide and Coding Conventions
A set of general guidelines from W3 on writing HTML code that is clean and tidy.
Google HTML/CSS Style Guide
Google’s own ‘Google Style’ coding standards for HTML/CSS. Focuses on improving collaboration and code quality for files using HTML and CSS.
Conclusion
Coding standards are largely subjective and several can exist for each programming language.
Selecting a widely adopted convention and styling guidelines that are proven to support quality code is the safest way to ensure you are complying with best practices for that language.
It’s mostly up to you and your team to decide how strictly you want to follow these coding standards. However, some industries may require a particular standard to be adopted to pass regulatory for safe critical applications.
Bonus Tip: Code linters and other static analysis tools can be used to aid you in writing code complying to a particular coding standard.
Which coding standards are you familiar with and do you follow any consistently? Leave a comment below.
See other articles you may be interested in below: