2011-01-05

The code

"I am mad!" -- someone

EDIT: Some one does not know what the One True Brace Style is... Let me help you google it.


My problems with the coding standard that are in use today.
I have so many problems with the coding standard for c-like languages in most project: first of the idea that starting brackets should be on a new like, this makes the code IMHO look like fuck:


class foo()
{
x=2+3;
print(x);

}


Am I the only one that sees the problem with this? The fukking bracket is not on the same line as the class! it is an eye sole!

The brackets on a new like makes the code look messy, and hard to read. It looks like a coding error to me.

this is the way it is suppose to be done:

class foo(){

x = 2 + 3;
print(x);

}

it is no longer an eye sore.

So how did the coding standard that is in use today come to be so popular?
The KnR style was invented by Kernighan and Ritchie's book The C Programming Language* and I can draw the conclusion that this book was read by many future programmers, and then these programmers started projects, and wrote books about programming which then inspired others.... A downward spiral of programming style.
And this downward spiral was accelerated by the the coding standard enforced by GNU** that encapsulated lodes of project that are a part used in our day to day lives.

I am a promoter of the One True Brace Style*** or its derivitive that is intended at making the more reader friendly. Even the Whitesmiths Style**** is better then the KnR Style, even though the end brace is at the wrong level.

help out and stop this downward spiral in to coding hell and convert your code from KnR to 1TBS or one of its derivative.

On White Spaces VS Tabs:
I do not give a fukk, I like tabs, but white spaces can be better if you are doing code with many indentation levels. b/c as you know a line of code has to be less then the 80 characters/columns ( this is just a standardised convention for interoperability and niceness of code)***** and with a tab taking up eight characters we have a when you hit the tenth level in your code.
And btw, gedit converts my tabs to what I want if I want.

* http://en.wikipedia.org/wiki/Indent_style#K.26R_style
** http://www.gnu.org/prep/standards/standards.txt
***http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS
**** http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style
***** I have lines that are longer then 80 chars, but I try to minimise it as much as possible.

4 kommentarer:

  1. I don't really think there is One True Coding Style(tm). If there is, I have yet to find any viable arguments for it.

    With enough experience you can easily switch mindset between different styles and adjust your code to the guidelines of the project you're working with.

    Tabs vs spaces though... One level of indention and two, or even four, characters to mark that up? Retarded, I think. Even the most basic editor today have settings for controlling the width of tabs, which means everyone could display their preferred indentation width.

    SvaraRadera
  2. @Tobias Sjösten

    Like I said, when working I can easily adjust the indentation levels with the press of a button.

    My editor adjusts the indentation automatically... just hit TAB and it does the right indentation for me. be it 2, 4, 8, or a Tab.

    and yes, indentations are important, w/c it code would be non-readable, and a butt fukk to debug.

    What I meant was that It is easer to adjust the indentation level in my mind then it is to read code that does not use the One True Brace Style...

    SvaraRadera
  3. I totally disagree with this. About both your view on braces, and your blatant lack of tolerance. Add or remove a single line break, and it goes from totally fucked up to the way it should be?
    It doesn't hurt to keep an open mind about things, like you would respect other people's tastes. You know, what you don't like doesn't automatically suck, and so on.

    When I started programming, I was taught the 1TBS style, and naturally thought this looked wrong and that braces should be lined up, although I had not seen it done. To me, 1TBS screams "I'm out of room, let's save a little bit there"... but I don't try to evangelize people about what I think they should be doing.

    Honestly, this "article" looked like a random troll to kill time. Wasn't it one?

    SvaraRadera
  4. @Stifu:
    I did not troll actually...
    This was just me babeling about nonsens...
    I do think that code should go first and stupid religious coding conventions should come second, I can and have used Allman, but it just looks ugly IMHO.

    I think that the GNU coding standard is weird but it looks better to the eye then allman.

    I this is the first of a tow parter, the next I am going to post how I code in c-like languages.

    And no I will not criticise anyone for using Allman, It is there choice. and I will respect that.

    ------
    I actually wrote this when I was looking at the coding convections of diffiernt projects. and my aesthetic eye, how has been looking at python code a lot lately, made me do it.

    love GegoXaren

    SvaraRadera