Kyrre Nygerd 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?
Yeah.
Use vi or emacs. :)
The OpenBSD developers spend a lot of time making code fit what they
call "KNF" -- Kernel Normal Form, documented in style(7)
They do it carefully by hand, not using automatic tools. Why? To get
EYES ON THE CODE. Go look at the commit logs, they often end up
catching errors doing this.
Run your "ugly" code through an automatic beautifier, you end up with
ugly code that now looks pretty...every bug remains, and your knowledge
of what is in there doesn't improve. Sure, you might be able to read it
better LATER, but the point is, you didn't read it NOW. If you don't,
the bad guys may...
Even though I'm not a coder, this technique helps me on the FAQ, as
well. Take a chunk, "normalize" it, and then go "Eww. We can do
better". :)
Nick.