admin管理员组文章数量:1025457
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.
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.
Share Improve this question edited Nov 9, 2011 at 17:21 hugomg 70.1k29 gold badges166 silver badges255 bronze badges asked Nov 7, 2011 at 20:22 user656925user656925 3- 1 You could read code plete cc2e. – CamelCamelCamel Commented Nov 7, 2011 at 20:23
- Style guides read like dictionaries...is there just a simple example to well formatted say C++ code which I can infer the rest from? – user656925 Commented Nov 7, 2011 at 21:47
- You could do some very very generic things and stick to that. For example, indent one tab for every increase in scope depth, format all if statements the same way, use braces consistently on loops and/or functions, decide how you will write multi-line concatenations and long arrays or function signatures – That Realty Programmer Guy Commented Aug 16, 2021 at 11:03
5 Answers
Reset to default 7There'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++ patible 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 patible with JavaScript and PHP.
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.
Javascript - Probably not pares with the others.
Worth reading the coding styles from ESA wrt Java, C++.
Also getting documentation out of Doxygen is another good starting point.
It's really a matter of taste. There are no definite standards to follow in this case.
See the many questions on this subject:
- Are there any coding standards for JavaScript?
- PHP coding standards
- Coding style checker for C
And more. All you need to do is search :)
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./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./apis/maps/documentation/javascript/basics.html and http://code.google./apis/calendar/data/1.0/developers_guide_php.html
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.
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.
Share Improve this question edited Nov 9, 2011 at 17:21 hugomg 70.1k29 gold badges166 silver badges255 bronze badges asked Nov 7, 2011 at 20:22 user656925user656925 3- 1 You could read code plete cc2e. – CamelCamelCamel Commented Nov 7, 2011 at 20:23
- Style guides read like dictionaries...is there just a simple example to well formatted say C++ code which I can infer the rest from? – user656925 Commented Nov 7, 2011 at 21:47
- You could do some very very generic things and stick to that. For example, indent one tab for every increase in scope depth, format all if statements the same way, use braces consistently on loops and/or functions, decide how you will write multi-line concatenations and long arrays or function signatures – That Realty Programmer Guy Commented Aug 16, 2021 at 11:03
5 Answers
Reset to default 7There'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++ patible 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 patible with JavaScript and PHP.
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.
Javascript - Probably not pares with the others.
Worth reading the coding styles from ESA wrt Java, C++.
Also getting documentation out of Doxygen is another good starting point.
It's really a matter of taste. There are no definite standards to follow in this case.
See the many questions on this subject:
- Are there any coding standards for JavaScript?
- PHP coding standards
- Coding style checker for C
And more. All you need to do is search :)
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./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./apis/maps/documentation/javascript/basics.html and http://code.google./apis/calendar/data/1.0/developers_guide_php.html
本文标签: Unified coding style for Javascriptphpcand CStack Overflow
版权声明:本文标题:Unified coding style for Javascript, PHP, C, and C++ - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1744996799a2128626.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论