user656925
user656925

Reputation:

Unified coding style for Javascript, PHP, C, and C++

I'd like to have one coding style across multiple languages. Can anyone provide a link to code that is styled nicely, that I can use for each language?

It is easiest to just look at an example rather than read for the multitude of cases that arise.

Upvotes: 2

Views: 1403

Answers (5)

Puppy
Puppy

Reputation: 146910

There's not a chance in hell. There's no such thing as code that's styled nicely for C and C++, let alone across the other languages too. You haven't exactly picked C# and Java here in terms of language similarities.

Edit: Do not, ever, use the Google Style Guide. It is horrendous and terrible. It was only ever devised to make C++ compatible with C, which basically means not using virtually all of the useful language features and writing some terrible code. And even then, you'd never make it compatible with JavaScript and PHP.

Upvotes: 7

Ed Heal
Ed Heal

Reputation: 59997

Javascript - Probably not compares with the others.

Worth reading the coding styles from ESA wrt Java, C++.

Also getting documentation out of Doxygen is another good starting point.

Upvotes: 1

rob
rob

Reputation: 10119

I would suggest something like this, it seems the way most people are heading, at least on the non-microsoft side of things:

http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml

Although that is for C++, it also applies to the c-like languages you mention. You can look at example code Google provides for other languages, it all tends to stick this this general style. For instance the code within these pages: http://code.google.com/apis/maps/documentation/javascript/basics.html and http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html

Upvotes: 0

Madara's Ghost
Madara's Ghost

Reputation: 174957

It's really a matter of taste. There are no definite standards to follow in this case.

See the many questions on this subject:

And more. All you need to do is search :)

Upvotes: 0

ssamuel
ssamuel

Reputation: 427

Wikipedia has an article that lists several C coding styles. Anything that works for C should work similarly for all the languages you ask for with little additional thinking.

Upvotes: 1

Related Questions