News for hackers. Stuff that matters.
Re:Applying the Gestalt Principles to Code by jxramos on Sunday May 05, 2019 @02:44AM (#19831528)
I forget what book it was that I read but it made this very obvious statement about source code being a 2D grid. And this is very apparent with the whole row column cursor tracer shown in editors and in compiler errors. For some reason I always perceived these things as having significance on a per line basis and once I read that code is a fundamentally 2D entity it empowered me to create relationships along the vertical with judicious usage of vertical alignment and creating vertical harmony in my code. It’s pretty cool to perceive monospace fonts as allowing a lattice of 2D characters. There’s a trade off of course with unnecessary vertical white space in that readability is boosted but the lexer has more characters to ignore.

There was one numerical project I worked on where I had these _x and _y suffixes showing up very frequently in identifiers. Having the code vertically aligned actually made spotting copy paste bugs very easy because you can trace the vertical and find all _x’s lumped together or whatever the case may be. Inconsistencies stood out more readily I want to say.

One thing I try to do with the visual aspect of my code is to organize things semantically when possible with a good clear comment that tersely covers the operation: initialize abc, validate xyz, calculate, compute, guard clause: ignore case 1, load config, override X, etc

Re:Applying the Gestalt Principles to Code by Sharlin on Sunday May 05, 2019 @08:18AM (#19832418)
In The Beginning (tm) source code was very explicitly a 2D grid, with column numbers being lexically significant in both FORTRAN and COBOL because columns matter in punch card representation.

Of course, as every Lisp programmer knows, programs represented in almost any high-level language are actually trees, and to force them into a 2D grid of symbols is rather unnatural and awkward. Specifically, almost all 2D grids of symbols are lexically or syntactically invalid programs, and many natural source code transformations require either manual labor or special support from the editor.

Re:Applying the Gestalt Principles to Code by danmaz74 on Sunday May 05, 2019 @03:22AM (#19831609)
> There’s a trade off of course with unnecessary vertical white space in that readability is boosted but the lexer has more characters to ignore

I suspect that the impact on the lexer is negligible.

Re:Applying the Gestalt Principles to Code by aasasd on Sunday May 05, 2019 @04:59AM (#19831852)
> source code being a 2D grid

Indeed!: http://people.idsia.ch/~juergen/oopscode.c

Re:Applying the Gestalt Principles to Code by pjc50 on Sunday May 05, 2019 @07:35AM (#19832292)
See "multi dimensional analog literals": http://www.eelis.net/C++/analogliterals.xhtml