logoalt Hacker News

cjfdlast Saturday at 8:20 PM12 repliesview on HN

One can talk about about the technical side of writing a code formatter, but what about the ethical side? Automatically formatted code looks kind of okay but never great. Uniformity for the sake of uniformity. It is not a very humanistic.


Replies

chapslast Saturday at 8:27 PM

This might just be the most HN comment I've ever read.

show 3 replies
o11clast Saturday at 9:14 PM

There are 3 major problems with automated code formatters:

* Handling of multiple newlines to break sections, or none to group related functions (e.g. a getter with a setter). Sometimes it's even best to move functions around for better grouping.

* They don't factor out an expression into a separate variable.

* They destroy `git blame`. This one is avoided if the tooling has always enforced formatting.

show 4 replies
tom_yesterday at 12:41 AM

Interesting comment. I always saw the formatting aspect as the sort of drudgery the computer could do for me. (As a bonus, it will always do it completely consistently.)

mjsir911last Saturday at 9:16 PM

yeah, I've come to terms that I mostly do programming-as-an-art and that includes how my code is structured, and I'm on exactly the same page.

In pragmatic business environments it's not worth the fuss but I never feel great about anything I make in those kinds of environments anyways, and I always appreciate being able to shine when there's no enforced code formatting.

nkrisclast Saturday at 10:21 PM

What is the ethical dilemma presented?

andrewflnrlast Saturday at 9:27 PM

"Ethics" is overdramatizing it. The goal of a code formatter is not greatness, but adequacy, in a context where the code is a means to an end. They're particularly used in contexts where you may be sharing the project with people who don't care about formatting at all. Forcing me to work in or clean up the messes of my lazy co-workers is also, I would suggest, not very humanistic.

Feel free to not use one in your art projects.

jbreckmckyelast Saturday at 11:21 PM

I agree, actually. Humans are visual creatures and they take cues from the visual design of program code: alignment, grouping, density. All these things are used to signify meaning in product design, including digital design. But we are not allowed to "design" source code.

mackeyelast Saturday at 11:01 PM

semantic code style varies plenty between people; i can often tell who wrote which code, among the members of my research group, even though we format our code. i'd prefer to be recognized by my preference for short lambdas (vs. defs) and partial functions, than my preference to put if statements on one line.

bartekpacialast Saturday at 9:16 PM

weirdest take on code formatting I've ever read

imho uniformity of what the code looks like > some single person's opinion

it's so satisfying to me when I just run "gofmt" and know the thing is formatted well.

show 1 reply
wiseowiselast Saturday at 10:15 PM

Humanistic is bikeshedding for weeks over new lines and “I feel like this is more readable”.

dredmorbiuslast Saturday at 11:46 PM

Ethical, or aesthetic?

Both are branches of philosophy, but rather distinct from one another.

jiballast Saturday at 10:42 PM

You surely forgot the "/s".

The uniformity is not merely for the sake of uniformity.