Coding style guides across languages
Introduction
Before you can start programming production code in any programming language you should know a few things like syntax, purpose, coding standards, good practices. There is another thing that is really important too and can help developers that work with multiple projects and languages: coding style guides. This is just a set of rules that developers should take care about when writing code. They are not so different across various programming languages. In this article, I will sum up and list coding style guides for the most popular languages.
It’s not a crime to use different styling, but standardizing this helps in the process of creating software. When your team is using the same standard it’s much easier to read each other’s code.
There is one universal resource when it comes to programming style guides. Many of you will already have read it: the “Clean Code” book by Robert C. Martin.
Something else that should be mentioned here:
- When you don’t know how to write a structure, read guides.
- When you know how to write a structure but it’s different than standardized, ask other developers about it.
- When your structure is different than all the other structures made by your co-workers, consider changing it.
- When someone will force you to change your styling code, ask her/him/them why, even if she/he/they are your manager or boss.
- When there is no good coding style guide for your language, create one.
- Try to have the same habits of coding in your team and company—it’s a time saver.
- Even if you’ve adapted to some structures be open for change.
- Respect experience. If senior developers tell you that your code is weird, there is probably something wrong with it.
Order of the guides is not random, most important and trusted first. Not all the guides cover all the topics so it would be wise to real all of them when you plan to write code in such a language.
Let’s begin.
Java
- http://www.oracle.com/technetwork/java/codeconventions-150003.pdf
- https://google.github.io/styleguide/javaguide.html
- https://www.scribd.com/doc/15884743/Java-Coding-Style-by-Achut-Reddy
C
- http://www.maultech.com/chrislott/resources/cstyle/indhill-annot.pdf
- http://www.maultech.com/chrislott/resources/cstyle/Peter_CStyleGuide.pdf
- http://www.maultech.com/chrislott/resources/cstyle/LinuxKernelCodingStyle.txt
C++
- http://www.maultech.com/chrislott/resources/cstyle/Ellemtel-rules-mm.pdf
- http://www.maultech.com/chrislott/resources/cstyle/Wildfire-C++Style.html
- http://www.maultech.com/chrislott/resources/cstyle/CppCodingStandard.html
C#
- https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/index
- http://www.idesign.net/Downloads/GetDownload/1985
- http://www.dotnetspider.com/tutorials/BestPractices.aspx
Python
- https://www.python.org/dev/peps/pep-0008/
- https://www.python.org/dev/peps/pep-0257/
- http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
- https://www.memonic.com/user/pneff/folder/python/id/1bufp
Objective-C
- https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html
- http://google.github.io/styleguide/objcguide.html
- http://cocoadevcentral.com/articles/000082.php
PHP
- http://www.php-fig.org/psr/psr-1/
- http://pear.php.net/manual/en/standards.php
- https://framework.zend.com/manual/1.12/en/coding-standard.coding-style.html
Visual Basic .NET
JavaScript
- https://github.com/airbnb/javascript
- http://google.github.io/styleguide/javascriptguide.xml
- https://www.w3schools.com/js/js_conventions.asp
Visual Basic
Perl
- http://shop.oreilly.com/product/9780596001735.do
- http://wiki.dictybase.org/dictywiki/index.php/Perl_Coding_Standards#Documentation
- http://perldoc.perl.org/perlstyle.html
Assembly
Ruby
- https://github.com/bbatsov/ruby-style-guide
- https://github.com/airbnb/ruby
- http://www.caliban.org/ruby/rubyguide.shtml
Conclusion
Maybe it’s not the most important programming part but it’s something you need to think about.
If we will try to compare those rules to human language, English for example, see “Romeo and Juliet”, Act III:
MERCUTIO
Come, come, thou art as hot a Jack in thy mood as any in Italy, and as soon moved to be moody, and as soon moody to be moved.
Now try to remove writing standards:
MERCUTIO Come, come, thou art as hot a Jack in thy mood as any in Italy, and as soon moved to be moody, and as soon moody to be moved.
It’s not easy to read this one liner. Our code is the same: Be smart, listen to more experienced people, read style guides and you will make live easier for you and other people too.
Comments