Are there other major variants of code formatting style still being developed out there?
[1] https://news.ycombinator.com/item?id=30130315
[2] https://github.com/boot-clj/boot/blob/master/boot/base/src/main/java/boot/App.java
1–10 of 22 posts
Are there other major variants of code formatting style still being developed out there?
[1] https://news.ycombinator.com/item?id=30130315
[2] https://github.com/boot-clj/boot/blob/master/boot/base/src/main/java/boot/App.java
Given near all code (let's say for large projects) is authored with IDEs, elaborate formats can be applied consistently and automatically, at little or no cognitive or typing cost.
To me the question is then if such formatting can increase the legibility of the code. The grid of static variable declarations in [2] is nice, but I wonder if sorting the variable lexicographically would make it easier to read/find a var by name?
Not sure how splitting method signature names onto a second line helps, though.
If you need some ideas for brainstorming, here is the endless source for inspiration. https://shitcode.net/
I mean this seriously, because the people are trying to solve their real problems with the tools available to them. So this has a good educational exercise.
With the availabily of syntax highlighting including color, has anyone seen merit in skipping indentation altogether?
For that matter, what if block color or font size took the place of indentation (under control of syntax highlighting). I'll have to try it by hand.
I myself am a huge fan of Pascal, and limiting code to one function per line. I find that clever/terse code is unmaintainable code.
Here's some code I wrote back in 1991 for a TECO clone that reflects that style. Looking back, I think some things could have a few more comments, but it seems fairly easy to read the intent of the code.
[1] https://en.wikipedia.org/wiki/Indentation_style#Horstmann_st... [2] https://bugs.llvm.org/show_bug.cgi?id=27263
GNU C formatting is odd: https://en.wikipedia.org/wiki/GNU_coding_standards
Zlib still uses K&R-1st-edition-era function definitions: https://github.com/madler/zlib/blob/cacf7f1d4e3d44d871b605da...
I find the Horstmann indentation style [1], in which code is placed on the same line as the opening bracket, simultaneously disturbing and compelling. If it ever ends up added to clang-format as has been requested [2], it might become more popular. [1] https://en.wikipedia.org/wiki/Indentation_style#Horstmann_st... [2] https://bugs.llvm.org/show_bug.cgi?id=27263
Sound confusing - very. I could see his "logic" but as to teaching programming students ... yes confusion all round, and wait till the poor students move on to any other language #@%%!$#!!!