mstdn.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A general-purpose Mastodon server with a 500 character limit. All languages are welcome.

Administered by:

Server stats:

16K
active users

tony 🏳️‍⚧️ 🏴 🤖 🚴🧗🏻

I'm going to have to write a whole fucking essay explaining that automatic code formatting is bad and you're wrong if you like it, aren't I

@jessewilson as a matter of research shall we say, how would you summarize your issues with code formatters?

@autonomousapps

The workflow sucks when robots enforce formatting rules.

I edit the code, commit, push, wait for a build, oh darn a whitespace error, fix, and push again.

There’s hooks and gadgets to fix this stuff but it’s all so slow. spotlessApply takes 30 seconds and I don’t want to wait for that.

@autonomousapps

The formatting rules are dumb.

Maybe I have some code that’s got a tabular structure and I want a few lines to match up vertically.

I get it just the way I want, then the code formatter comes and throws that careful alignment away.

@autonomousapps

The IDE integration is clumsy.

I’ve got .editorconfig but the tools still disagree on unimportant stuff like how aliased imports are sorted.

I don’t want an IDE plugin for whitespace! That’s just another thing that can be slow or break.

@autonomousapps

The robot does dumb things and I’m accountable for them.

Maybe I’ve got a file with a special copyright header because it’s originally authored by somebody else.

Now I’ve got to register that file in a special build file somewhere, otherwise the robots will claim copyright on a file somebody else created.

github.com/cashapp/redwood/blo

Multiplatform reactive UI for Android, iOS, and web using Kotlin and Jetpack Compose - cashapp/redwood
GitHubredwood/build.gradle at 3fe178c14ec112982e1f33f2a931936dae962d9d · cashapp/redwoodMultiplatform reactive UI for Android, iOS, and web using Kotlin and Jetpack Compose - cashapp/redwood

@autonomousapps

Suppressions don’t refactor well.

Suppose I’m breaking naming rules throughout a file for a good reason. I’ve got a @file:Suppress at the top.

When I move declarations out to another file, the suppressions don’t travel with them.

Unlike automatically reforming stuff, the tool always makes me add the suppress annotations myself.

@autonomousapps

Sometimes they change the formatting rules.

It will reject code that it formatted itself yesterday!

Renovate helpfully tries to update the formatter library, and the new formatter library insists on changing a bunch of innocent files as a side-effect.

Shall I accept that the formatter now owns me and makes me do tricks for its amusement?

@autonomousapps

It messes up git blame.

The ‘introduce ktfmt’ commit message is an unwanted layer of plastic film beneath which the true authorship lies.

According to line counts, the person who introduced the formatter is now the project’s largest contributor.

@autonomousapps

It creates faux consistency in the codebase.

When I pick a table at Arby’s, I pick one that’s not covered in crumbs. It’s probably got fewer germs.

If you brush the crumbs off the table without sanitizing it, you can trick me into contracting a minor illness.

If you reformat some horrible engineering manager code into something that looks good cosmetically, I might overlook that it’s using ObjectOutputStream. Which is the JVM equivalent of contacting a minor illness.

@jessewilson lots of gold in this here thread! ty for indulging me and also the implicit peer pressure to follow through on my repeated threats to attempt to explain my deep seated hatred of code formatters in a consistent way

@rjrjr @ralf @jessewilson @autonomousapps My part is easy and boring: formatting is tool whose utility grows with the codebase and contributor size. I don't need a formatter. I know Jesse doesn't need one. Probably neither Tony nor Ralf do either. And if we're working in small codebases by ourselves or with just each other we can leave it out. Like a type system or linter or whatever else, it simply removes a class of problems that I have to think about for others code who I may not fully trust.

@jw @rjrjr @ralf @autonomousapps

Having to wait ten seconds, 5-10 times a day, just because my imports might not be sorted is what actually makes me grumpy.

I’ll report the above referenced bugs. IntelliJ’s formatter is fast, and if that’s all I need I’m happy.

@jessewilson @rjrjr @ralf @autonomousapps I started to make a Gradle plugin that used IntelliJ as a library to do code formatting. It was also very slow, and it really doesn't format enough to even be useful. Maybe that's changed in the last two years (although probably not the slowness). Kotlin and Gradle are just so slow. Especially when you start looking around at what others are doing...

(image from youtu.be/IroPQ150F6c)

@jw @jessewilson @rjrjr @ralf conceptually, using a single automated formatter eliminates a whole class of _conversations_ (and maybe problems), but at the implementation level I find it's not nearly so straightforward. I'm also not fully convinced at the conceptual level

I also distinguish automatic code formatting from linting. I hate* the former and value the latter

@jw @jessewilson @rjrjr @ralf @autonomousapps JVM, Kotlin, and Gradle all deserve some frowns, but Gradle is the worst offender by far if we're talking about code formatting.

I was going to say you'd get so much improvement if you just got rid of Gradle (which is true), but even then... 30s. ugh.

@billjings @jw @jessewilson @rjrjr @ralf you mean the Gradle overhead when running a formatter via a task? yeah that's painful. ideally the task would invoke a cli with identical behavior so users could use whatever they were most comfortable with

@rjrjr @ralf @jessewilson @autonomousapps @jw Have you put Jake's posts up next to Jesse's? That's like asking to mix some steak in with your ice cream

@billjings @rjrjr @ralf @jessewilson @jw who's the steak and who the ice cream in this metaphor, and which am I meant to prefer 🤔

@autonomousapps @rjrjr @ralf @jessewilson @jw Steak and ice cream are both great! Very different writing styles and topic preferences

@billjings @rjrjr @ralf @jessewilson @jw i think the most upsetting thing about this whole conversation is that jake has made some good points, and so what i was originally envisioning as a half-joke shitpost now has to be more serious 😭

@billjings @rjrjr @ralf @jessewilson @jw I've now got something drafted. I will link this thread in the post, but I haven't explicitly named anyone for various reasons. if you actually do want to be named, let me know. if you want to review the draft so that you have an opportunity to correct me if you think i am mis representing any of your arguments, let me know! i will be posting on my personal blog. other than correcting outright errors, i am not interested in editorial opinions. thanks ❤️

@autonomousapps @rjrjr @ralf @jessewilson @jw 1. I don't think I said anything interesting, but anyone can name me for any reason whatsoever

2. I only go to your personal blog for the spiciest, top of the dome anti capitalist shit. Which I'm hoping code formatters are related to somehow

@billjings @rjrjr @ralf @jessewilson @jw oh then you might like the thing I'm working on about how much i hate ai!

@jessewilson @autonomousapps Consistent formatting means the usage of ObjectOutputStream would actually be easier to spot because you simply can't be distracted by formatting.

To follow your analogy, it means that when you take a microscope to each table at Arby's in search of germs, your view isn't entirely blocked by a giant crumb which allows germs to pass underneath.

@jessewilson @autonomousapps Every formatter of any value will have a mode which only enforces formatting on changed files which completely does not break git blame. Git also allows you to ignore entire SHAs for blame purposes if you choose to do batch reformatting.

Relying solely on a blame anyway is misguided at best. You might get a quick signal from it, but it's not authoritative. Otherwise it completely discourages refactoring, type refining, nullability annotations, etc.

@jessewilson @autonomousapps This is true for *all* software though. If a library can deprecate an API and force me to change my code does that mean no one should use libraries? I can't tell if you're trying to argue that tools shouldn't improve or you're accusing a specific tool of arbitrarily changing formatting *with no reason*. If it's the former... what? If it's the latter... don't use that tool!

@jessewilson @autonomousapps File-based suppression is again a language feature the point of which is to apply only to the file and be unrelated to individual members within. This holds true for opt-in, warnings, lints, and even imports. File-level *anything* doesn't magically follow when you copy a tiny piece of the file. Nothing to do with formatting tool here.

@jessewilson @autonomousapps This is the standard mechanism of suppressing *anything* in the language. Deviating from normal behavior and having to suppress+justify is completely normal behavior that we do with compiler warnings, lints, ignores, etc.

@jessewilson @autonomousapps You spent a decade asking contributors to add copyright headers manually in PRs and we're required by legal to include these. But a tool which handles it automatically is somehow troublesome because in the 0.1% case you have to tell it the files come from somewhere else? Also: this behavior does not come from the syntax formatting tool but from Spotless so probably shouldn't be included.

@jessewilson @autonomousapps Please include the link to a bug filed about this. Because the point of both tools reading editorconfig is to be consistent with each other, after all. Surely we're not complaining that software has bugs without filing issues, right?

@jw @jessewilson @autonomousapps we had a fundamental disagreement on imports lol

(I think YT doesn't differentiate between deactivated and banned)

@jessewilson @autonomousapps This. So much. For the most part auto formatting is fine but there is code that is made objectively much harder to read when enforcing those rules (math heavy code, bit manipulation, etc.)

@jessewilson @autonomousapps I'm not sure that anyone would disagree that sometimes particular pieces of code can be better suited to manual formatting. But holy shit "The formatting rules are dumb"? Is 99% of your code manually formatted? Or less than 1%? This seems like bog-standard trade-offs associated with just about all tools and libraries.

I'm not sure either picture is great. If you put a leading `0 or` (like how we used to do a leading `"" +` in multi-line Java strings) both improve.