User:Avarma/Coding Style: Difference between revisions
Jump to navigation
Jump to search
(Origination) |
(added section on comments) |
||
Line 1: | Line 1: | ||
= Introduction = | |||
My coding style is generally a compromise between the [https://developer.mozilla.org/en/JavaScript_style_guide Mozilla JavaScript Style Guide], the vagaries of what [http://www.toolness.com/wp/?p=40 js2-mode] happens to be compatible with, and my own personal tastes. | My coding style is generally a compromise between the [https://developer.mozilla.org/en/JavaScript_style_guide Mozilla JavaScript Style Guide], the vagaries of what [http://www.toolness.com/wp/?p=40 js2-mode] happens to be compatible with, and my own personal tastes. | ||
Because I started the [[Labs/Jetpack|Jetpack]] and [[Labs/Ubiquity|Ubiquity]] projects, much of their code happens to conform to this style. | |||
= Comments = | |||
Comments are always C++-style, starting with a <tt>//</tt>. This is partly because: | |||
* It's hard to remember how to format C-style (<tt>/* */</tt>) lines consistently, | |||
* Emacs constantly gets confused with C-style comments because there's so many different styles of using them, | |||
* Virtually all other programming languages use a minor variation on C-style comments, e.g. using <tt>#</tt> as the comment prefix instead of <tt>//</tt>, making it easy to convert common comment code (e.g. license blocks) from one language to another, | |||
* C++-style comments can easily be nested, while C-style comments cannot. | |||
Furthermore, the comments before functions or sections of code are usually commented using [http://www.wikicreole.org/ WikiCreole] syntax, so as to be compatible with [http://www.toolness.com/wp/?p=441 Code Illuminated]. |
Revision as of 17:10, 15 June 2009
Introduction
My coding style is generally a compromise between the Mozilla JavaScript Style Guide, the vagaries of what js2-mode happens to be compatible with, and my own personal tastes.
Because I started the Jetpack and Ubiquity projects, much of their code happens to conform to this style.
Comments
Comments are always C++-style, starting with a //. This is partly because:
- It's hard to remember how to format C-style (/* */) lines consistently,
- Emacs constantly gets confused with C-style comments because there's so many different styles of using them,
- Virtually all other programming languages use a minor variation on C-style comments, e.g. using # as the comment prefix instead of //, making it easy to convert common comment code (e.g. license blocks) from one language to another,
- C++-style comments can easily be nested, while C-style comments cannot.
Furthermore, the comments before functions or sections of code are usually commented using WikiCreole syntax, so as to be compatible with Code Illuminated.