Jump to page: 1 26  
Page
Thread overview
[OT] Auto code reformating / one coding style enforcment.
Aug 12, 2006
kris
Aug 13, 2006
renox
Aug 13, 2006
kris
Aug 13, 2006
Frank Benoit
Aug 13, 2006
Ben Gardner
Aug 14, 2006
Walter Bright
Aug 14, 2006
Walter Bright
Aug 14, 2006
Derek Parnell
Aug 14, 2006
Walter Bright
Aug 14, 2006
Derek Parnell
Aug 15, 2006
Walter Bright
Aug 15, 2006
Brad Roberts
Aug 15, 2006
kris
Aug 14, 2006
Ivan Senji
Aug 14, 2006
Frits van Bommel
Aug 14, 2006
Walter Bright
Aug 14, 2006
Frits van Bommel
Aug 14, 2006
Regan Heath
Aug 15, 2006
Walter Bright
Aug 15, 2006
Sean Kelly
Aug 15, 2006
Sean Kelly
Aug 15, 2006
Regan Heath
Aug 15, 2006
Sean Kelly
Aug 14, 2006
Oskar Linde
Aug 14, 2006
Walter Bright
Aug 14, 2006
Derek Parnell
Aug 14, 2006
Derek Parnell
Aug 14, 2006
Sean Kelly
Aug 15, 2006
James Dunne
Aug 15, 2006
Sean Kelly
Aug 14, 2006
Pragma
Aug 14, 2006
kris
Aug 14, 2006
pragma
Aug 15, 2006
James Dunne
Aug 15, 2006
kris
RFC 451 (was [OT] Auto code reformating / one coding style enforcment)
Aug 15, 2006
kris
Aug 15, 2006
Derek Parnell
Aug 15, 2006
Pragma
Aug 14, 2006
Sean Kelly
Aug 14, 2006
Bruno Medeiros
Aug 14, 2006
Regan Heath
Aug 15, 2006
Sean Kelly
August 12, 2006
This is *not* proposition of D change. Only free concept that I wish to share with D users.

Most of the time of my coding work I'm dealing with code that I didn't wrote. What is most irritating is when I just can't reformat code using indent or astyle because I need to work on little change and produce diff that will fit into original repository. And sometimes code is completely mess - I don't care if someone likes breaking brackets here and there, but ... I thing you all know what I'm talking about.

My thoughts are always like this: why creators of C language allowed people to format code freely? Wouldn't world be a better place if languages would enforce their one-true-coding-style? If there would be no choice there would be no reason to argue.

"If I'd write my own language ..." (don't get it too serious - it's only hypothetical ;-) ) there would be no way to code same code in two different ways (except of identifier names, comments and such ...). There would be one standard and compiler would enforce it - throwing errors about code formating or even reformat code in the fly if asked to (optional switch or something like that).

The users would have to adopt to code in such language - get used to one coding style, which probably wouldn't be what they were doing before in every aspect, but ...

... after some time they would discover that when they look at someone else code in that language - there is no difference. Working with patch/diff tools is nicer, reading code pleasure is bigger. Everything is better ...

Python code tries to enforce coding style rules - I like that aspect of it. What I don't like is not enforcing to use tabs for indentation and which is even worse - not enforcing on _any_ standard about indentation, only to be consistent in whole source file. Except that I'm not aware of any language (except Whitespace ;-) ) that do something similar. Have anybody even tried? Did such language succeed?

What do you think?
August 12, 2006
"Dawid Ciezarkiewicz" <dawid.ciezarkiewicz@gmail.com> wrote in message news:eblf6h$1vo6$1@digitaldaemon.com...

> Most of the time of my coding work I'm dealing with code that I didn't wrote. What is most irritating is when I just can't reformat code using indent or astyle because I need to work on little change and produce diff that will fit into original repository. And sometimes code is completely mess - I don't care if someone likes breaking brackets here and there, but ... I thing you all know what I'm talking about.
>
> My thoughts are always like this: why creators of C language allowed
> people
> to format code freely? Wouldn't world be a better place if languages would
> enforce their one-true-coding-style? If there would be no choice there
> would be no reason to argue.

I always thought it'd be cool if there were an IDE which could read in code, parse it into tokens, then display the tokens in any format you wished, and you could change things like indentation, spacing, bracket styles etc.  Then when you saved, it'd write it back out as a text file.  Of course, like you said, when dealing with things like diffs for repositories, you can't really do that..

> "If I'd write my own language ..." (don't get it too serious - it's only
> hypothetical ;-) ) there would be no way to code same code in two
> different
> ways (except of identifier names, comments and such ...). There would be
> one standard and compiler would enforce it - throwing errors about code
> formating or even reformat code in the fly if asked to (optional switch or
> something like that).
>
> The users would have to adopt to code in such language - get used to one coding style, which probably wouldn't be what they were doing before in every aspect, but ...
>
> ... after some time they would discover that when they look at someone
> else
> code in that language - there is no difference. Working with patch/diff
> tools is nicer, reading code pleasure is bigger. Everything is better ...

Most Basic languages are pretty much this way.  Whitespace and newlines are a lot more significant, and as such, you can pretty much only write constructs one way.

> Python code tries to enforce coding style rules - I like that aspect of
> it.
> What I don't like is not enforcing to use tabs for indentation and which
> is
> even worse - not enforcing on _any_ standard about indentation, only to be
> consistent in whole source file. Except that I'm not aware of any language
> (except Whitespace ;-) ) that do something similar. Have anybody even
> tried? Did such language succeed?
>
> What do you think?

I think you're on target with the idea that it's stupid to have such a freeform language style.  All that happens is everyone develops their own styles and everyone gets into religious debates about which is better.  In other words, it's a lot of argument over nothing.

What seems to be the most common solution to this problem is that programming teams / companies will often adopt a single coding style.  To this end, it would be very useful if there were a "dtidy" tool that everyone would have to run on their code before submitting it to everyone else.  This tool would optimally be powerful on its own, but with scriptability so that really obscure coding styles (like lining up braces with the left paren of the owning construct.. wtf) could still be generated.  Or, this tool would just look at the input and complain if it doesn't match the given coding style spec.  Kind of like a style lint tool.

Oh, and spaces should die.  Hard tabs for LIFE.


August 12, 2006
Dawid Ciężarkiewicz wrote:
> This is *not* proposition of D change. Only free concept that I wish to
> share with D users.
> 
> Most of the time of my coding work I'm dealing with code that I didn't
> wrote. What is most irritating is when I just can't reformat code using
> indent or astyle because I need to work on little change and produce diff
> that will fit into original repository. And sometimes code is completely
> mess - I don't care if someone likes breaking brackets here and there,
> but ... I thing you all know what I'm talking about.
> 
> My thoughts are always like this: why creators of C language allowed people
> to format code freely? Wouldn't world be a better place if languages would
> enforce their one-true-coding-style? If there would be no choice there
> would be no reason to argue.


lol ... because there would never be a unanimous concensus on what that format should be ;D

You may recall the beating Fortran took because of the need to place variable-decls on the sixth column only (or something like that).

Python uses syntactically significant indentation (for blocks), instead of braces. Because of that, the language attracts a lot of flack from various quarters.



> "If I'd write my own language ..." (don't get it too serious - it's only
> hypothetical ;-) ) there would be no way to code same code in two different
> ways (except of identifier names, comments and such ...). There would be
> one standard and compiler would enforce it - throwing errors about code
> formating or even reformat code in the fly if asked to (optional switch or
> something like that).
> 
> The users would have to adopt to code in such language - get used to one
> coding style, which probably wouldn't be what they were doing before in
> every aspect, but ...
> 
> ... after some time they would discover that when they look at someone else
> code in that language - there is no difference. Working with patch/diff
> tools is nicer, reading code pleasure is bigger. Everything is better ...
> 
> Python code tries to enforce coding style rules - I like that aspect of it.
> What I don't like is not enforcing to use tabs for indentation and which is
> even worse - not enforcing on _any_ standard about indentation, only to be
> consistent in whole source file. Except that I'm not aware of any language
> (except Whitespace ;-) ) that do something similar. Have anybody even
> tried? Did such language succeed?
> 
> What do you think? 


As long as anyone considers writing code to be an "expression" or "art form", to any degree, the notion of a single writing format (upon which everyone will agree) is doomed to failure :)

There have been strict rules regarding the use of grammar, prose, and sentence structure for centuries ... yet, it seems those are abandoned on an accelerating basis :p

August 13, 2006
> What do you think?

I think so too.
Sure, I have my own style and don't like any other ;)

Perhaps it would be good to have a formatting tool with 2-3 fixed style sets, that it can use.

What I really miss, is a D indent tool that really works. I spent some time on the dparser and even had some success with indenting code, but I didn't continue.

I feel there should be much more man power in the dparser project. The compiler itself should be build in D. It should provide a really good interface for applications working with D code. And it should be build in a way, that after parsing every bit of information is available, and the source file can be regenerated with it.

That would enable many development tools for D. Indention/autocompletion/refactoring/d-lint/...

well dreams ...


August 13, 2006
Frank Benoit wrote:
> What I really miss, is a D indent tool that really works. I spent some
> time on the dparser and even had some success with indenting code, but I
> didn't continue.

Uncrustify supports the D language.

You may want to check it out.
http://uncrustify.sourceforge.net/

Ben
August 13, 2006
kris wrote:
> Python uses syntactically significant indentation (for blocks), instead of braces. Because of that, the language attracts a lot of flack from various quarters.

Note that one reason that Python get some flacks as dawid ciezarkiewicz rightly put it is that it doesn't enforce *enough* the syntax: blanks and tabs are 'equivalent', which makes a mess when you have various contributors..

If a language enforce 'syntactically significant indentation', it should  also enforce the use of tab instead of space for example.

Of course if one programmer is dumb enough to align with space, you could look for the error in the code for hours without finding the error, but this is easy to avoid: the compiler/interpreter should complain each time he see '4 space' or a tabulation depending of the choice of the delimiter.

Regards,
RenoX
August 13, 2006
Ben Gardner wrote:

> Frank Benoit wrote:
>> What I really miss, is a D indent tool that really works. I spent some time on the dparser and even had some success with indenting code, but I didn't continue.
> 
> Uncrustify supports the D language.
> 
> You may want to check it out. http://uncrustify.sourceforge.net/

Oh. Thanks for the link. :)


P.S.
/me is dreaming about kind of public agreement:

"We - the D users - when coding in D will always reformat it using style described: <a href="somelink">here</a> even when we personally think it's not perfect/best/favorite style and will be strongly advicing anybody who codes in D to do so as well."

However I have a doubts that such group effort could succeed in language with C-like syntax. Too many people coming from different places with different habits.

Even phobos sources have mixed space/tabs indentation (mixed in single
file!) ... sad.
August 13, 2006
renox wrote:
> kris wrote:
> 
>> Python uses syntactically significant indentation (for blocks), instead of braces. Because of that, the language attracts a lot of flack from various quarters.
> 
> 
> Note that one reason that Python get some flacks as dawid ciezarkiewicz rightly put it is that it doesn't enforce *enough* the syntax: blanks and tabs are 'equivalent', which makes a mess when you have various contributors..

yes; you're right


> 
> If a language enforce 'syntactically significant indentation', it should  also enforce the use of tab instead of space for example.
> 
> Of course if one programmer is dumb enough to align with space, you could look for the error in the code for hours without finding the error, but this is easy to avoid: the compiler/interpreter should complain each time he see '4 space' or a tabulation depending of the choice of the delimiter.
> 
> Regards,
> RenoX
August 13, 2006
"Dawid Ciezarkiewicz" <dawid.ciezarkiewicz@gmail.com> wrote in message news:ebmvsa$2up9$1@digitaldaemon.com...

> Even phobos sources have mixed space/tabs indentation (mixed in single
> file!) ... sad.

That's just Walter's coding "style."  It's not just phobos; it's everything he writes.  Including the DMD source.  Oh man.

I love hard tabs, and I don't mind spaces; but everything only falls apart when you mix them.  Like Walter.  :)


August 14, 2006
Jarrett Billingsley wrote:
> "Dawid Ciezarkiewicz" <dawid.ciezarkiewicz@gmail.com> wrote in message news:ebmvsa$2up9$1@digitaldaemon.com...
> 
>> Even phobos sources have mixed space/tabs indentation (mixed in single
>> file!) ... sad.
> 
> That's just Walter's coding "style."  It's not just phobos; it's everything he writes.  Including the DMD source.  Oh man.
> 
> I love hard tabs, and I don't mind spaces; but everything only falls apart when you mix them.  Like Walter.  :) 

It works just fine when you set tabs to be 8 characters, as god intended them to be.
« First   ‹ Prev
1 2 3 4 5 6