Coding Style

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Coding Style

C-Style
21
51%
Java-Style
19
46%
VB-Style
1
2%
 
Total votes: 41

maniac9
Forum Commoner
Posts: 55
Joined: Fri Aug 01, 2003 12:27 am
Location: Arkansas, USA
Contact:

Post by maniac9 »

First of all, I don't understand what you people mean by C-style and Java-style, since they follow the same syntax, and work in both languages...I do mine the same in all languages...
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

maniac9 wrote:First of all, I don't understand what you people mean by C-style and Java-style, since they follow the same syntax, and work in both languages...I do mine the same in all languages...
I hear what you're saying. I chose a way and do it that way most of the time to until I get to work.

And there is the reason right there. When bodies of code start to grow in size, importance, or both, then conventions become important. And as a result, the need for being able to name and identify these conventions.

Personally, I think something is suspect with what we are calling C or Java style. Java get's it's style from C. So does C++ and Perl. When you get right down to it, what Kriek labeled as the Java style is what K & R themselves used years before Java was ever an Oak (If you know what I mean). To me the idea that Java would even have a style named after it is kinda obscene.

Cheers,
BDKR
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

To me the idea that Java would even have a style named after it is kinda obscene.
Hehe... True.

The question about how we code are a neverending subject. I prefer the (obscene hehe) 'Java-Style' way, and I think that thats the way I see it mostly. But as I said in another thread, I personally change the way I code to whom I code with.
At home, 'Java-Style'. At work, C-style.

Doesn't matter that much, as long as the idents and overall readability/comments is there.
User avatar
Toneboy
Forum Contributor
Posts: 102
Joined: Wed Jul 31, 2002 5:59 am
Location: Law, Scotland.
Contact:

Post by Toneboy »

C style - I find it clearer. Still have lots of scripts with Java style though, it seems to be most popular on online tutorials (of which I've read plenty). I'm not surprised that it is a narrow leader in this poll.
onefocus99
Forum Newbie
Posts: 16
Joined: Tue Oct 07, 2003 11:09 pm
Location: Hamilton Ont., Montreal, Chibougamau,... PQ, Victoria BC, now Alberta Canada

Post by onefocus99 »

I'm a Java Programmer and learned this first,
however I code C-Style.
I use only 3 spaces to indent
Then if there are alot of nested 'if statements' the logic doesn't go off the screen. I am Ho Ho for that.
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

I find going by the PEAR standard easiest to read. Whoever decided VB style coding should be part of PHP should be Google-bombed with the term "constipated yak."
User avatar
devork
Forum Contributor
Posts: 213
Joined: Fri Aug 08, 2003 6:44 am
Location: p(h) developer's network

Post by devork »

c-style gives you easy to understand code flow
it depends from which background you have more experience
c-style will be easy for c lang ppl and same for other.
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

devork wrote: c-style gives you easy to understand code flow
Don't they all aim (in some way) to give you easy to understand code flow?
:twisted:

Really, when you get right down to it, it's just an organizational issue. Norhing more and nothing less. How are things arranged, or even name (uderscores, studly caps, hungarian notation), will all help somebody to some degree. Beyond that, with the exception of python, ...

Code: Select all

fucntion shoot_gun(&$player)
    {
     fire_weapon(&$player->weapon);
     register_hit(&$player);  /* If the player actually hits something */
    }
and

Code: Select all

fucntion shootGun(&$player) {
     fireWeapon(&$player->weapon);
     registerHit(&$player);  /* If the player actually hits something */
}
...will work exactly the same. And when you get right down to it, this is a readability issue. Not one of code flow, which implies a concern with logic.
devork wrote: it depends from which background you have more experience
c-style will be easy for c lang ppl and same for other.
And that's ultimately the 'it'. Python, Ruby, VB all look incredibly bland and just mushed together becuase there are no brackets, braces, semicolons, or parenthesis. For those of us with a foundation in a C like syntax, this is maddening at first. The only visual clues you have as to what's going on are things like indentation, white space, and new lines.

What if it's a n00b3 and he/she doesn't indent consistently. At least with a C based language there are still the braces. But in this case, Guido (the developer of Python) was smart and at least requries (at the engine level) indentation for code blocks. Having the indentation helps immensely.

Cheers,
BDKR
User avatar
Fredix
Forum Contributor
Posts: 101
Joined: Fri Jul 18, 2003 2:16 pm
Location: Wehr (Eifel) Germany
Contact:

Post by Fredix »

I voted for C-Style because I !!!HATE!!! what you call Java style, really!

I use that C-style in any language that has such block delimiters and even in pascal I handle those key words "BEGIN" and "END" as if they would be brackets.

Writing brackets in one column gives you the fastest overview over your code, while using "JAVA-Style" you need to _search_ the start of the code block.

For me there is no space for any other argumentation as I could not imagine that someone can read JAVA Style better.

I'm not concerned about VB so much because I hardly find anyone really using this a lot.
Post Reply