The Harm of Manual Code Formatting (2007)

By Xah Lee. Date: .

The Harm of Manual Code Formatting

The following is a newsgroup post (edited), at comp.emacs, Xah Lee, 2007-10-11.

Someone wrote: «As for your code, I don't know why you are indenting interactive differently than the further forms;»

just sloppy… never really pay much attention about any so-called “coding style” (which often means the code formatting habit) Actually, i consider the rampant reference and concern about “coding style”, is a egregious fuck up that can be attributed significantly to unix and C. The damage is far and wide, and also influenced negatively the lisp community.

In general, a programer should never have to press any returns, tabs, etc for the purpose of formatting his code. The editor should automatically wrap the code properly for display formatting. Many language, especially those turds from Unix/C's family {tcsh, Perl, C++, Java} has a syntax that this is impossible lex level. For Lisp the lang it is possible, but the thinking isn't there.

In Mathematica, i never have to spend time to fiddle with code formatting. (and when i do actually insert a indent or return, it is intentional and means something (usually indicating a break in {semantics, algorithm, code unit})) It's quite interesting to note that Mathematica not only formats codes automatically, but the fact that its code can contain 2-dimensional type-set mathematics (i.e. fractions, roots, powers, subs, parens, nesting, integrals, … variously combined.), and auto-render AND auto-wrap such type-set expressions on the fly. This feature, started in Mathematica version 3 about 1997, is today a decade-old technology. Most coders today (For example, Perl) are still arguing and wallowing about the fine points of how many spaces a indent should be. (not just inanely in newsgroups, but there are entire literature (For example, guides) devoted to it. fucking morons and holes.)

As to lisp, it would be nice, if a programer can press a button in emacs, then the current code block would be formatted by a simple lexical scan. (similar to how fill-paragraph would work) I think it is relatively trivial to code his command, but to my surprise, it is not done. I was told by one Scheme expert Taylor R Campbell (aka Riastradh, author of paren-edit mode) that this is non-trivial, but i couldn't believe it and maybe he misunderstood what i wanted about this command.

In fact when i gained more lisp experience in ~2005, i was surprised to find that the concept of auto-wrap is basically non-existent among lispers. Lispers, to a lesser degree than C/Perl morons, still do discuss and debate now and then about formatting trivia.

For a outline of how this lisp formatter would work, see: A Simple Lisp Code Formatter.

Unix line truncation problem