Top
Best
New

Posted by MaxLeiter 9/7/2025

Formatting code should be unnecessary(maxleiter.com)
354 points | 476 commentspage 5
iLemming 9/9/2025|
Lua is especially annoying - even after years of using it I just can't really decide how to format it for better readability. lua-fmt sometimes works, often it makes it even worse. I welcomed Fennel in my Lua setups mainly because of this.
jaimebuelta 9/8/2025||
I think that formatting code is necessary to maintain a codebase that's used by multiple people and keep some consistency. It's very confusing to have different standards in different parts of the same code.

Code should be generally written so it's easy to read.

dark-star 9/8/2025||
In most languages (other than e.g. Python), formatting code is actually unnecessary...
Tractor8626 9/8/2025||
Author advocates for a thing they never used.

"It must have been good because Grady Booch says so".

amdivia 9/8/2025||
I assume that's something similar to the Unison [1] programming language

https://www.unison-lang.org/

fridental 9/8/2025||
Typing keywords letter by letter is unnecessary too. Think about ZX Spectrum keyboard allowing you to type BASIC keywords with just one key press.
whartung 9/8/2025||
This was actually a potential problem, at least on Commodore machines.

On those machines you were able to abbreviate keywords.

At the same time, they support full screen editing. That meant you could just cursor up over some code, make changes, hit enter, and the changes would take place.

However, when using the abbreviations, it was possible to create lines that were too long. I don't recall the specifics, but there was a line limit for BASIC input. Lets say it was 80 chars (for discussion).

Using abbreviations (like ? for print) and you could end up with a line that would LIST for more than 80, but if you tried to change it with the screen editor, the lines would be too long, and truncate silently.

So you had to be cautious with your use of the abbreviations.

Cockbrand 9/8/2025|||
Similar, and maybe more related to the article's topic: Commodore BASIC also saved the commands as tokens, so you could enter abbreviated commands like

  10 ? "Hello"
  20 gO 10
and a LIST command would yield

  10 print "Hello"
  20 goto 10
So saving commands as tokens in memory and formatting them on output was somewhat common back then.

The speccy was more advanced in terms of this (as mentioned in the parent comment), and it had the better BASIC for sure.

cluckindan 9/8/2025||
Or think about the M (aka MUMPS) language, which allows you to type just the first letter(s) of a keyword and considers it valid syntax.

Imagine Java if you could…

    na com.mycompany.myapp;
    
    pu cl MyClass {
      pro sta i = 42;
    
      pri fi ch[] MAGIC = ['a', 'b'];

      pu sta v main(String[] args) {
        OtherClass otherClass = n OtherClass();
        f (i i = 0; i < MyClass.i; i++) {
          otherClass.hex(i, this.MAGIC);
        }
      }
    }
gethly 9/8/2025||
I am quite thankful for Go. It ticks so many boxes. Having native gofmt and simple syntax means I can easily read anyone else's code instantly.
komali2 9/8/2025||
Formatting code is unnecessary. You write it however you want, then run the lint fix command and prettier command, commit, and move on.
BlueUmarell 9/8/2025||
Ohhh, a topic about code formatting

<picks pop-corns>

grim_io 9/8/2025|
I came prepared to fight the author, but I left in agreement.

Yes, we should expect better from our tools and languages.

More comments...