from Hacker News

Shittier: Code formatting tool that makes your code look terrible

by wolframhempel on 2/27/24, 9:21 AM with 78 comments

  • by merelysounds on 2/27/24, 10:24 AM

    Feature requests:

    1. Convert leading indentation to tabs or spaces at random.

    2. Insert trailing spaces.

    3. Use varying indentation styles - pick at random from: https://en.wikipedia.org/wiki/Indentation_style#Overview

  • by Someone on 2/27/24, 11:56 AM

    The problem with this tool is that it’s too easy to revert most of its work (everything except for the case changes in identifiers, AFAICT) using a prettifier.

    To make it robust against such adversary attacks it should incorporate the teachings of “How To Write Unmaintainable Code” (https://github.com/Droogans/unmaintainable-code)

  • by mstade on 2/27/24, 10:46 AM

    I used to work with a fella that wrote code similar to this. To him, code seemed to be a scratchpad, a place to jot down ideas and try them out. Once an idea worked out, he shipped it. Done.

    Impossible to maintain, but damn if he couldn't churn out some quality works. Bug laden, sure, but the core ideas were great – at times even brilliant. There was a certain beauty to the chaos.

    Prettier wasn't around then, and code for matters weren't much of a thing at all really. Can't help but think if that would've helped or stymied his process. Certainly would've helped the rest of us though!

  • by Jemm on 2/27/24, 2:04 PM

    Worked with a company that outsourced their code. Contract stated that source code must be provided so in an effort to be pricks, the outsourced company provided their code on fanfold dot matrix printouts using a line printer from the 80s. It arrived in three very heavy boxes not even folded neatly.

    This reminded me of that for some reason.

  • by russfink on 2/27/24, 12:27 PM

    I could see someone triggering a proper obfuscator (not this) as a time bomb, rendering the code in a permanent frozen feature state - usable but unmaintainable by future employees. (The contract says only to “write code to do this feature…”.) Do contracts provide legal barriers to this?
  • by dspillett on 2/27/24, 10:20 AM

    I'm sure this wouldn't make half as much difference to my code as I'd like to think…

    > Random indentation for a chaotic code structure.

    One to add if it isn't there already: some blocks indented by tab, some by spaces, some mixed.

  • by Skeime on 2/27/24, 10:22 AM

    Why is the source code not formatted using the tool itself?
  • by epipolar on 2/27/24, 10:17 AM

    Cool, now I can copy highly structured and perfectly formatted code from LLMs and make it look I hacked it all on my own last night
  • by sverhagen on 2/27/24, 10:35 AM

    >Shittier is a purely satirical project

    And yet, I'm sure some folks will find serious applications, like in cases of malicious compliance when having to share your code against your will.

  • by madeofpalk on 2/27/24, 11:51 AM

    If it was deterministic - everyone on your team uses it to produce the same formatting, no matter show shitty it is - it would still meet the same goals as Prettier.
  • by luke-stanley on 2/27/24, 11:20 AM

    Perhaps this could make useful synthetic data for improving large language models improving code, because you could have two pairs of code, better code, and the terrible code. This is probably already done internally at the top AI labs.
  • by KronisLV on 2/27/24, 10:59 AM

    This reminds me of seeing others' code in the first year of university. There was a pretty basic intro to some language constructs, but for some reason the first exams were done on paper.

    People wrote everything without indentation, or with inconsistent spacing. Somehow this also carried over to the code that they'd write in the computer, so it was pretty much unreadable, since you couldn't glance at a block of nested loops and realize what goes where.

  • by dusted on 2/27/24, 10:38 AM

    This looks very much like the typescript formatter we use...
  • by ajsnigrutin on 2/27/24, 10:30 AM

    Is it possible to get something like this: https://i.redd.it/as700946ez9z.jpg , but without the indents? So a flat block of code aligned to the left, and all the brackets in a column on the right?

    ...just trying to be evil... :)

  • by stabbles on 2/27/24, 11:11 AM

    In Python it should turn a list of strings

        ["foobar", "baz"]
    
    into

        [
          "foo"
          "bar",
          "baz"
        ]
    
    to infuriate people further.

    Also possible in C and C++:

        char * strings[] = {
          "foo"
          "bar",
          "baz"
        };
  • by seritools on 2/27/24, 10:16 AM

    Needs a --check that enforces a minimum number of prettier violations per 100 lines :^)
  • by bjclark13 on 2/27/24, 3:11 PM

    I know this is satirical, but I would actually use this with my web development students as an exercise if it introduced more subtle shittiness that they would have to fix.
  • by sylware on 2/27/24, 11:13 AM

    Having a code generator for each and everything mandating accutely expensive dependencies (massive and complex scripting language/templating SDK) is brilliant too...
  • by schutt on 2/27/24, 10:58 AM

    Please make sure to ship this as a prebuilt .exe file.
  • by self_awareness on 2/27/24, 11:22 AM

    Not nearly as shitty as the code I have to work with
  • by netbioserror on 2/27/24, 3:56 PM

    Sometimes the nightmare is some mix of organized and chaotic. I had the responsibility of rewriting from scratch a C codebase that was deliberately obfuscated. The spacing and bracketing and general code style was almost perfect. But every name was obfuscated into nonsensical single letters and contractions, and every ostensibly simple math operation was separated into a multiline series of single stateful operations on a variable. Plus, global variables.

    Surprised I managed to do it at all, but it was circumstantial evidence for what each operation did that helped immensely, plus a few logical and mathematical lightbulb moments. Rewriting it in Nim has also helped me make it well-organized and self-documenting. I have a document full of pseudocode but it looks basically exactly the same as the Nim code!

  • by logtempo on 2/27/24, 11:03 AM

    for when a company want the opensource label but is too selfish to share.
  • by agilob on 2/27/24, 11:25 AM

    A reminder that spaghettify exists too https://www.spaghettify.dev/
  • by callamdelaney on 2/27/24, 10:42 AM

    Can you make it so it takes my beautifully arranged imports and mushes them together using brackets and commas? Oh wait..
  • by wiradikusuma on 2/27/24, 10:47 AM

    A.K.A job security.