3 ms·
Ask HN: Learning go – why is “gofmt” such a big deal?
Quite curious about this one, and thought I'd pose the question here. I've recently started to learn Go - quite a wonderful language for some server-side processing libraries I'm working on - and I recall seeing many people say, "gofmt is the bomb," or, "gofmt is one of the greatest things any programming language could have." It seems that the big deal is simply that nobody argues over code formatting.
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't really awesome, but rather that it was there first.
Is that the case? Is that all there is to gofmt - it was there first, so nobody bothered arguing?
- nostrademons 12y agoYes. 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 12y agoFormatting 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))))
- lispm 12y agoFormatting and indenting are slightly different things. Formatting in Lisp is either called pretty printing or grinding (in the editor). 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 12y agoMost 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.