Sunday 4 December 2016

Coding standards in Linux

Coding standards are our way of telling the world that discipline, order and total obedience towards a set of rules too can be a form of beauty.
Indentation to me is the most visible, obvious and unanimously agreed upon coding style/ standard that is out there. But I think the last sentence made it obvious that indentation is quite obvious. There are things though that are not so obvious at least in the beginning like breaking lines in between to not cross 80 columns, naming variables a certain way and breaking things down to various files rather than being composed. 
One learns with time but is often kept waiting for a standard and a style to oblige to. In most cases a coder turns to personal choice for this style which is absolutely fine. But nothing beats being aligned with a huge organisation's style of writing code. And if you google the keywords: "huge", "organisation" and "code", you'll probably learn something about Linux. It's big, very big.
People (mostly companies) contribute code, in bulks to the Linux kernel. As such it is very important that everyone be made to follow the same style. Now, obviously they can't employ people to check if each submission meats their requirements or not. They have scripts doing this for them. Basically you can use scripts provided freely to you in order to test whether your code is alright (stylistically) for the Linux kernel. If it is than kudos, but if it's not, you can always look up the coding guidelines given in the official Linux source. It is a good read, I promise.
Here is the link:  

http://lxr.free-electrons.com/source/Documentation/CodingStyle

No comments:

Post a Comment