Linux Kernel Coding Style

I’m not a Linux Kernel developer, but I’ve found the Coding Style those hackers use really insightful. Code written in compliance with their guidelines not only looks nice, but is also easier to understand and maintain. Take a look:

  • If you have the linux source installed, read the file /usr /src /linux /Documentation /CodingStyle.
  • If not, read it on-line here.

2 Responses to Linux Kernel Coding Style

  1. Alex says:

    That’s an interesting discussion point. I am not an adept of the K&R coding style; I find it difficult to read code where the brace is on the same line as the keyword – this saves space but hinders readability.

    This is why I like Python – strict indentation rules make it impossible to write ugly code. There is no need for braces or begin/end keywords.

    When it comes to C-like language, I am an adept of what turns out to be called “BSD/Allman style”, http://en.wikipedia.org/wiki/Allman_style

    Nowadays there is plenty of space on my screen to make the advantages of K&R brace placing less attractive. The page you provided a link to seems to offer a demi-god status to Kernighan and Ritchie… the prophets that stole C from Olympus and shared it with the mortals (-;

    The author of the story provides reasonable backup arguments for his statements, but his use of “divine intervention” arguments makes the whole article less credible.

  2. Constantin says:

    The author is Linus Torvalds himself ;)
    He is probably used to editing code on a 25-line terminal, so I don’t blame him for not putting the brace on a line by itself. But in today’s world I agree that “wasting” one line is better than “wasting” some readability.

    Thanks for the comment – always a pleasure to read.

%d bloggers like this: