You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by David Tanzer <st...@guglhupf.net> on 2005/10/21 16:58:29 UTC

[dev-process] Coding Style Guide

I've just had a look at some C code from jchevm and BootJVM to compare 
the coding style of both contributions. Both use coding styles which are
quite common for C source code but they are slightly different, and I
don't think that's good. We should really define a coding style guide
before even more code is contributed.

I'm not worried about Java code we write, because I assume everyone
agrees to use the Java Coding Conventions from Sun [1] here. Much of the
development in Harmony is done in C at the moment, and we need a coding
style guide here too.

I once suggested to use the Java Coding Conventions in C and C++ code
too [2] (at least where possible, and we'd have to extend them to cover
pre-processor directives and other C/C++ specific things). We could also
use a style like Archie Cobbs or Dan Lydick used in their contributions,
but IMHO we should write it down and then stick to it.

Mark Wielaard provided a link to the project policy of GNU Classpath 
[3], I guess we could get some Ideas from this too.

Regards, David

[1] http://java.sun.com/docs/codeconv/
[2]
http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200508.mbox/%3c1125132934.2487.6.camel@Elrond.Rivendell%3e
[3]
http://mail-archives.apache.org/mod_mbox/incubator-harmony-dev/200510.mbox/%3c1128247495.6126.16.camel@localhost.localdomain%3e

-- 
David Tanzer, Haghofstr. 29, A-3352 St. Peter/Au, Austria/Europe
http://deltalabs.at -- http://dev.guglhupf.net -- http://guglhupf.net
My PGP Public Key: http://guglhupf.net/david/david.asc
--
Pinky, Are You Pondering What I'm Pondering?
Umm, I think so Big Brainy Fish Face Stove Pipe Wiggle Room Eileen. 
But if you get a long little doggie, wouldn't you just call it 
a dachshund?

Re: [dev-process] Coding Style Guide

Posted by Mark Wielaard <ma...@klomp.org>.
Hi David,

On Fri, 2005-10-21 at 16:58 +0200, David Tanzer wrote:
> I'm not worried about Java code we write, because I assume everyone
> agrees to use the Java Coding Conventions from Sun [1] here. Much of the
> development in Harmony is done in C at the moment, and we need a coding
> style guide here too.

I have never seen that coding convention. But for GNU Classpath we use a
coding convention that mimics the standard (GNU) C and C++ coding
convention as closely as possible. This has as advantage that code
written in different programming languages looks similar across the
projects. I would recommend that other projects adopt that since we have
written so much code that conforms to this standard already. See
http://www.gnu.org/software/classpath/docs/hacking.html#SEC8

I do note that coding conventions are something that lots of people have
an opinion on. And in general they quickly turn into bike shed (*)
discussions. So I would just state one convention and stick with it.

Cheers,

Mark

(*)
http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/misc.html#BIKESHED-PAINTING


-- 
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html

Join the community at http://planet.classpath.org/

Re: [dev-process] Coding Style Guide

Posted by David Tanzer <st...@guglhupf.net>.
On Sat, 2005-10-22 at 10:42 +0200, Leo Simons wrote:
> On Fri, Oct 21, 2005 at 04:58:29PM +0200, David Tanzer wrote:
> > I've just had a look at some C code from jchevm and BootJVM to compare 
> > the coding style of both contributions. Both use coding styles which are
> > quite common for C source code but they are slightly different, and I
> > don't think that's good. We should really define a coding style guide
> > before even more code is contributed.
> 
> *shrug*.
> 
> "A Foolish Consistency is the Hobgoblin of Little Minds"
> (http://www.python.org/doc/essays/styleguide.html)
> 
> The most important thing with coding style guides is that they don't get
> in the way of actual work or that discussing them turns into big flamewars
> or anything like that. IMNSHO.

Ok, I didn't want to start a flame war (and AFAICS I didn't do so yet), 
and you're right, such a style guide should not get in the way of 
development. OTOH it has some advantages to have one and I've read on
this list that others like the idea of a coding style guide too. Also
it's good to know when *not* to apply such a style guide, but IMHO it's
better to have a law you can break ;-).

> The rest IMHO.
> 
> The second most important thing is consistency on a file-by-file basis.
> 
> The third most important thing to note is that doing lots of reformatting
> halfway through a project makes the diffs harder to read, so it *is*
> something to do as early as possible.

Exactly what I wanted to say. If we want such a style guide we should
write it soon before too much code is contributed.

> [Snip]
> I like the kaffe one too:
> 
>   http://www.kaffe.org/doc/kaffe/FAQ.coding-style
> 
> :-)

:-D

> In any case, perhaps someone should just start a wiki page with some kind of
> policy on it and everyone that doesn't like the policy can change it so that
> what they're doing complies with that policy. See how it goes :-)

Maybe I'll start one next week, this weekend I won't have too much time 
for that.

> cheers!
> 
> Leo

Cheers,
David.

-- 
David Tanzer, Haghofstr. 29, A-3352 St. Peter/Au, Austria/Europe
http://deltalabs.at -- http://dev.guglhupf.net -- http://guglhupf.net
My PGP Public Key: http://guglhupf.net/david/david.asc
--
Are You Pondering What I'm Pondering?
I think so Brain, but there's still a bug in there from last time.

Re: [dev-process] Coding Style Guide

Posted by Leo Simons <ma...@leosimons.com>.
On Fri, Oct 21, 2005 at 04:58:29PM +0200, David Tanzer wrote:
> I've just had a look at some C code from jchevm and BootJVM to compare 
> the coding style of both contributions. Both use coding styles which are
> quite common for C source code but they are slightly different, and I
> don't think that's good. We should really define a coding style guide
> before even more code is contributed.

*shrug*.

"A Foolish Consistency is the Hobgoblin of Little Minds"
(http://www.python.org/doc/essays/styleguide.html)

The most important thing with coding style guides is that they don't get
in the way of actual work or that discussing them turns into big flamewars
or anything like that. IMNSHO.

The rest IMHO.

The second most important thing is consistency on a file-by-file basis.

The third most important thing to note is that doing lots of reformatting
halfway through a project makes the diffs harder to read, so it *is*
something to do as early as possible.

> I'm not worried about Java code we write, because I assume everyone
> agrees to use the Java Coding Conventions from Sun [1] here.

Huh, what, no, not me :-). Well sometimes, depends on the project.

> Much of the
> development in Harmony is done in C at the moment, and we need a coding
> style guide here too.
> 
> I once suggested to use the Java Coding Conventions in C and C++ code
> too [2] (at least where possible, and we'd have to extend them to cover
> pre-processor directives and other C/C++ specific things). We could also
> use a style like Archie Cobbs or Dan Lydick used in their contributions,
> but IMHO we should write it down and then stick to it.
> 
> Mark Wielaard provided a link to the project policy of GNU Classpath 
> [3], I guess we could get some Ideas from this too.

I like the kaffe one too:

  http://www.kaffe.org/doc/kaffe/FAQ.coding-style

:-)

In any case, perhaps someone should just start a wiki page with some kind of
policy on it and everyone that doesn't like the policy can change it so that
what they're doing complies with that policy. See how it goes :-)

cheers!

Leo