12/9/17

Coding Standards/ Style Guides for popular Programming languages

When you start out learning a programming language, you will probably just follow the examples from where you are learning the language, or apply principles of formatting and naming you have used in a previous language.

You should be aware there are standard conventions that may specify or guide you in many if not all of the following areas:

  •     directory and file organization
  •     use of indentation
  •     how to comments
  •     declaration preferred style
  •     statement style
  •     the use of white space
  •     naming guidelines/rules
  •     best practice in other areas

At the end of this short article I provide a list of style/convention guides for the most popular languages.
    
A language may have a common style or convention guide for anyone using the language such as Microsoft C#. When you work at a specific company, they may have a company-wide style guide. If you work on a team or on a Open Source project, they may have a style guide that you must follow.

There are automated tools to warn of not following a style that is recommended usually called a linter. Lint was the name of a program that would go through your C code and identify problems before you compiled, linked, and ran it. It was a static checker that would run after editing your code and before compiling. Some linters also check that the code follows certain style/conventions.

Good programming style creates easier to understand programs with consistent style and code patterns and names. This results in less bugs and higher productivity.

A recommendation for any programmer: 

A great reference for many software writing techniques that make a difference is the book: Code Complete 2 written by Steve McConnell . I had been programming decades and then discovered this book, it was a book I wish I had when I was starting to program. It would have saved me many hard lessons. I recommend it to anyone getting serious about programming.

I recommend that you read the style guides for the language you are using, and also check out some other languages.

The Style/Guide List:




LanguageGuides
C GNU, Linux, WikiBook, Malcolm Inglis, Collection of C/C++
C++ Google, by Bjarne Stroustrup
Python: PEP8 , Summary PEP8, Google
Java: Google, Historic Oracle(1999), Historic Oracle(1997 pdf), Combined Google/Oracle
Ruby: bbatsov community guide, rails, Airbnb, Shopify
C# Microsoft, raywenderlich.com, Dennis Doomen
JavaScript Google, JQuery.orgAirbnb, W3Schools
PHP: PHP Standard Recommendation (PSR), php-fig, pear standard, Goggle
SQL: top google search, Drupal
Swift: Swift.org, raywenderlich.com
R Google, by Hadley Wickham:
Go 1- How to write Go, 2 -Effective Go
Visual Basic Microsoft msdn, microsoft docs, WikiBook
Assembly Language Recommended by me, Collection
CSS Google, Airbnb
Objective-C Apple, NYTimes, Google