

Ask HN: Learning go – why is “gofmt” such a big deal? - spdustin

Quite curious about this one, and thought I&#x27;d pose the question here. I&#x27;ve recently started to learn Go - quite a wonderful language for some server-side processing libraries I&#x27;m working on - and I recall seeing many people say, &quot;gofmt is the bomb,&quot; or, &quot;gofmt is one of the greatest things any programming language could have.&quot; It seems that the <i>big deal</i> is simply that nobody argues over code formatting.<p>However, with tools like EditorConfig [0] making code formatting concerns largely irrelevant in a given repo (aside from syntax-affecting formatting issues), it seems to me that the code formatting imposed by gofmt isn&#x27;t really <i>awesome</i>, but rather that it was <i>there first</i>.<p>Is that the case? Is that all there is to gofmt - it was there first, so nobody bothered arguing?
======
nostrademons
Yes. Source code reformatting has been around since `indent`, and probably
before. The problem was getting everyone to agree on a style and use it
consistently. Go solved that by providing an official style, and official
tool, and a culture that consistently uses that tool. The only other language
that's managed that was Lisp (via emacs), which for a variety of other reasons
never became popular. Many others (eg. Java, C, Python, etc.) may provide the
tool and/or the styleguide, but not the culture that consistently applies it.

In other words, it's a cultural innovation, not a technical one.

~~~
lispm
Formatting and indenting are slightly different things.

Formatting in Lisp is either called pretty printing or grinding. Formatting
includes the layout of code including where the line breaks are in code.

    
    
        CL-USER 50 > (PPRINT '(DEFUN FOO (A B C) (* (+ A B C) (+ (EXPT A 2) (EXPT B 2) (EXPT C 2 )) (+ (EXPT A 3) (EXPT B 3) (EXPT C 3)))))
    
        (DEFUN FOO (A B C)
          (* (+ A B C)
             (+ (EXPT A 2) (EXPT B 2) (EXPT C 2))
             (+ (EXPT A 3) (EXPT B 3) (EXPT C 3))))

------
andrewchambers
Most tools have a multitude of configuration options which everyone wants to
set differently.

go fmt comes with the official distribution, is zero configuration, and
everyone who uses go uses it.

