4 ms·
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 co
by jxramos 8y ago
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
- danmaz74 8y ago> 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.
- aasasd 8y ago> source code being a 2D grid Indeed!: http://people.idsia.ch/~juergen/oopscode.c http://people.idsia.ch/~juergen/oopscode.c
- pjc50 8y agoSee "multi dimensional analog literals": http://www.eelis.net/C++/analogliterals.xhtml http://www.eelis.net/C++/analogliterals.xhtml
- Sharlin 8y agoIn 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.