Subject: Re: Code beautifiers, anyone?
To: =?ISO-8859-1?Q?Kyrre_Nyg=E5rd?= <kyrreny@broadpark.no>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: current-users
Date: 08/24/2006 08:21:12
Kyrre Nygård wrote:
> Hello people,
>
> I'm looking for the best ways to create a line of code beautification
> (reformatting) scripts -- one for C, one for Ruby, one for Bash and
> one for web development languages like XHTML, XML, CSS, PHP and Ajax.
> Whether as frontline warriors or household maids, they would ensure
> proper indentation, linebreaks, spaces, tabs and so forth.
>
> Can anybody help me?
>
> My studies of architectural science has taught me to pay extreme care
> to the correction of details, and I now wish to apply these teachings
> to all my code. I find myself always reformatting whatever my
> associates give me. Not that they're bad programmers, they just care
> more about the code itself rather than its structure, and I dare not
> argue with that. When their code is messy, however, my heart feels
> messy and I can't get any sleep.
>
> I wish to be in full control of my code beautifiers. That is, I wish
> to have them as simple and meaningful as possible. Give me an easy
> Bash over a complex Ruby any day.
>
> There's a lot of messed up tools out there. Companies with flashy
> websites just doing this for the money. So apart from the bullshit,
> I've managed to spot out the Ruby Beautifier and GNU Indent as two
> worthy code beautifiers. However I get the feeling they are more
> complex than they ought to be, and if less is more, my search will
> have to continue.
>
> All the best,
> Kyrre
Do do it properly, you really can't use something simple like bash
scripts. The problem is that you need to do lexigraphical analysis to
know e.g. what kind of symbol you're looking at, etc. This is typically
beyond simple line oriented tools.
You can get _close_ with some line oriented tools, but there will always
be edge cases that they don't do right, IMO.
So, in other words, I don't think you're going to find a "simple" way to
do this, unless you're willing to sacrifice accuracy.
--
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134 Fax: 951 325-2191