15 ms·
Show HN: Spaghettify – A VSCode Extension to make your code worse with AI
Recently, I saw Github Next Code Brushes (https://githubnext.com/projects/code-brushes https://githubnext.com/projects/code-brushes) which is a VSCode extension that can use AI to do things like make your code more readable, add types, etc.
This inspired me: what if there was an extension that could use AI to make your code worse as well?
Meet Spaghettify. An extension I developed that can do things like:
- Obscure your code
- Introduce a bug
- Make the variable names way too descriptive
- Use nonsymmetrical whitespace
- Add irrelevant/rambling comments
- Document the code with emoji
- Document the code in any style (Dirty Limerick, Fast Talkin' 1930s Gangster)
I built this extension over the last couple of days and released it in collaboration with BCAD.one. It's available on the VSCode Marketplace, you will need an OpenAI API Key to use it. You can grab it here:
(https://marketplace.visualstudio.com/items?itemName=BCAD.spaghettify https://marketplace.visualstudio.com/items?itemName=BCAD.spa...)
Code here:
https://github.com/BeforeCutieAfterDoggo/spaghettify https://github.com/BeforeCutieAfterDoggo/spaghettify
- smoldesu 4y agoThis is pretty amazing. I'm inspired to go write something similar now, that uses AI to pad out source code to exactly 80 characters per-line...
- JeanSebTr 4y agoVertical screen users thank you in advance!
- progx 4y agoLol!
- dgan 4y ago> Overly Descriptive Names Looks like regular Lisp function names to me ¯\_(ツ)_/¯
- serpix 4y agoAdd irrelevant comments has real world use for some students who are required to comment all of their code when submitting their work.
- bee_rider 4y agoI’ve been trying to push students in the direction of fewer, better comments but it is a lonely hill to die on.
- Mizza 4y agoThe obfuscation is a little too obvious. The people need something which defends their job security but still passes code review.
- onemoresoop 4y agoInvolve a few layers of unneeded steps of indirection via a few hyped technologies. Now obfuscation is not easily removed. Beware, it may bite the creators themselves
- foobiekr 4y agoThat’s like 90% of Java that uses spring.
- JonathanFly 4y ago>A VSCode Extension to make your code worse with AI >Document the code with emoji >Document the code in any style (Dirty Limerick, Fast Talkin' 1930s Gangster) >worse TIL I've been coding wrong my whole life. But it's the only way I know...
- lelandfe 4y agoWow, fast talkin' 1930s gangster documentation is pretty remarkable. >> Listen up, ya mugs! I'm gonna give ya the lowdown on dis here function, getSourceImage(). >> Dis baby is the real deal. It's gonna give ya the goods on the source image. Ya got it? The source image! No more guessin' or snoopin' around, dis function'll give ya the straight dope.
- fragmede 4y agoHow creative! Did you consider adding wrong comments? Because those are the worst! like flip the logic from arithmetic to subtraction and then have the bot summarize that.
- jmilldotdev 4y agoThat's a really good one. Like the 'introduce bug' one, but just the comments are factually incorrect.
- jackcviers3 4y agoAm I the only one that found the more explicitly named definition way easier to read? Sure the definition name was too large, but the inner variables were great.
- jmilldotdev 4y agoThere have been many moments in building this thing where I expected something terrible and got something that actually looked better than what I had.
- thefifthsetpin 4y agoNah. I worked at a company that had a code style guide encouraging very verbose variable naming. It was awesome.
- yamtaddle 4y agoI read that feature on the list and immediately thought "I bet that improves more code than it harms"
- throwawayben 4y agoAre there any examples to enjoy for my amusement without installing & setting up the extension? Edit: nevermind, just found the home page: https://www.spaghettify.dev/ https://www.spaghettify.dev/
- jmilldotdev 4y agoAlso, it's open source and all the prompts we use are in this file: https://github.com/BeforeCutieAfterDoggo/spaghettify/blob/main/src/prompts.ts https://github.com/BeforeCutieAfterDoggo/spaghettify/blob/ma... You can take these and play around with them in the OpenAI playground as well.
- dcow 4y agoThe little animation at the top wraps when it gets to “Well Documented” on mobile. The whole page keeps shifting up and down. It’s really hard to read. Maybe it’s on purpose but just pointing it out. It detracted from the comedy for me. Otherwise love the gag.
- jmilldotdev 4y agoAh, good catch. Will fix.
- what-no-tests 4y agoOh can you have it add code blocks that are commented out? And have it do the opposite of "Extract a method" - oh and have a class call a method on another class that calls a method on another class that calls a method on the original class (but for every single thing that needs to happen in the critical path)? If you can't, I have some developers I'm cleaning up after who can...
- neoneye2 4y agoAwesome. Evil ideas for improvements. Random typos in class name, function names, comments, such as: inheritance -> enheritance class -> clas cannot -> cannont Pick related words: person -> user, account, customer Random swapping plural/singular users -> user Append "Class" to classnames. example: User -> UsersClass Insert rant comments about, politics, religion, profanity.
- Gordonjcp 4y ago"privite" and "private" and "privet" but there are #defines to make them work anyway. I actually saw code that looked like that from a very dyslexic mate of mine who I worked with a long time ago.
- peterkos 4y agoalso, common capitalization mixups: "ID vs. Id", "snapshot vs. snapShot", "username vs. userName"
- RobotToaster 4y agoEmojis as class and variable names
- reaperducer 4y agoDon't forget homonyms: InActive (not active) inActive (in the Active list)
- kunalgupta 4y agokill it with fire
- kvandy 4y agoI'm so triggered
- poulpy123 4y agoYou should have called it Job Assurance Generator
- jmilldotdev 4y agoour best defense against the robots is a good offense
- thatxliner 4y agoThis is a work of art
- alvis 4y agoI used to spend lots of time to prepare some coding tests that mimic real-world situations for candidates, like introducing a small bug to an example code or pretending I've bad coding practice etc. Now I found the best tool ever! Thank you.
- dmkirwan 4y agoWhat (presumably!) was built as a joke will actually help me a lot. For my side-project (devscreen.io) we have to make lots of realistic coding tests and pull requests with bugs in them for candidates to work on as part of a technical interview. It's actually more time consuming than you'd think to intentionally insert bugs into code in a way that isn't super obvious, so thank you!
- sublinear 4y agoI think use cases like this are the right ones for generated code from language models. I'm pretty sure the vast majority of training data is more buggy than not and literally writing the code is only half of what it takes. The other half is comprehension of the problem it solves which is usually missing from documentation at the level of mere snippets.
- groestl 4y agoTake something perfect and internetlify it. It was basically trained on exactly that data.
- 908B64B197 4y agoSomething I wonder is what the computing landscape (and tech recruiting) will looks like once we reach a critical mass of "GitHub Co-Pilot native" devs. Especially with the bootcamp craze. Are we going to see hires basically trying code generation until it builds?
- jmilldotdev 4y agoBugs-as-a-Service (BAAS)
- quectophoton 4y ago"Because, you see, bugs are a way of connecting people to the real world. Reminding them that, at the end of the day, it is just a game." — Matt Jablonsky, Head of Bug Creation Department Quote from an Aprils Fools video for The Witcher 3.
- jimt1234 4y agoI don't need this extension. My code already looks like this. LOL
- debuggest 4y agoHere comes AI threatening to take my job away again.
- whatever1 4y agoIt is not worse than my code. Better luck next time AI.
- deleted 4y ago[deleted]
- racl101 4y agoI ran it and it made my code better.
- rochak 4y agoWhat do you know? Two wrongs do make a right!
- codeulike 4y agoBig fan of "document using emoji"
- moremetadata 4y agoWhen you introduce a bug, is it a dumb random bug, or an intelligent AI bug? In other words, would the bug work for me or the user? When I say work for me, what I mean is, considering decompiler tools like https://ghidra-sre.org/ https://ghidra-sre.org/ can shine light where once there wasn't, would the bug generates lots of unnecessary work for me, or could I use the bug as a stealth form of copy protection, where those with illegal copies get bitten by the bug and eventually forced into purchasing said code? I've seen that technique used with a software company supplying addons to other programming companies. Cant say its a technique taught at places like University.
- ahmednazir 4y agoWhat is the real life uses of this project?
- jmilldotdev 4y agogetting to the top of hackernews
- BMorearty 4y agoNice. A few more ideas: consolidate small functions into one huge function; change await to callback hell in JS; goto!
- cratermoon 4y agoThe reverse of refactoring. Defactoring? Factoring?
- das_keyboard 4y ago...and everyone said my job won't be replaced by AI :/
- caust1c 4y agoGreat way to introduce bug-doors! Looks hilarious, love it!
- btrettel 4y agoI'm now realizing that AI could be quite useful for introducing bugs for mutation testing. I'm going to have to try that.
- danuker 4y agoIndeed, it would make mistakes similar to common mistakes in the web at large.
- deleted 4y ago[deleted]
- mystickphoenix 4y agoI'd love to see a feature that creates tests that don't actually test anything
- camel-cdr 4y agoAh, I was waiting for somebody to implement something like this. Now you just need to write a bot that floods github with shitty code, and we've got job security again.
- batch12 4y agoSomething like this could be good for malware authors as a new obfuscation tool. Would be awesome if it still delivered working code and could recurse so the level of nasty was tunable.
- klyrs 4y agoExcellent! I, for one, recommend using this tool to make parallel versions of important files in every github repo. If the AI can't learn to keep their hands out of the honey jar, they don't deserve to survive.
- ChickenNugger 4y agoTwo thoughts: * This is ridiculous. Why would you do this? Which made think of this quote: "Which is ridiculous and unnecessary but when has that ever stopped programmers?" from one of my favorite Tom Scott videos: https://www.youtube.com/watch?v=gocwRvLhDf8 https://www.youtube.com/watch?v=gocwRvLhDf8 * How to Write Unmaintainable Code: https://github.com/Droogans/unmaintainable-code https://github.com/Droogans/unmaintainable-code
- cratermoon 4y agoNever ask a nerd "why?", just nod your head and back away slowly.
- cheapliquor 4y agoOn one hand, funny. On the other, potentially useful for either teaching yourself or learning to read other people's code. Intentionally botching or skewing code and teaching yourself to deal with it/fix it. Would use if I was even halfway decent at coding
- xaedes 4y agoRewrite this function into latin-py, a python dialect based on latin, with all identifiers (even append) and keywords translated to proper latin. Add comments in proper latin. Add typeannotations (translated into latin) and docstring in proper latin. ```latin-py """Haec definitio vicini elementos in arr in spatio n a puncto (x, y) repperit.""" definio vicini(arra: lista, x: numerus, y: numerus, n: numerus) -> lista: """Resultatus in quem vicini elementi addentur.""" resultato: lista = [] # Maximum quod x possit esse. riga_maximus: numerus = max(0, x-n) # Minimum quod x possit esse. riga_minimum: numerus = min(longitudo(arra)-1, x+n) # Maximum quod y possit esse. colonna_maximus: numerus = max(0, y-n) # Minimum quod y possit esse. colonna_minimum: numerus = min(longitudo(arra[0])-1, y+n-1) # Itero per intervallum rigarum pro i in intervallum(riga_maximus, riga_minimum+1): # Itero per intervallum columnarum pro j in intervallum(colonna_maximus, colonna_minimum): # Addo elementum ad resultatum. resultato.adde((i, j)) # Redire ad resultatum. redire resultato ```
- iwasanewt 4y agoI'm a bit disappointed that the integers are not latin numerals, though I'm sure someone considered it for a moment before realizing what a horrible idea it would be.
- dfrey1 4y agoThis is amazing!!
- 29athrowaway 4y agoSome people code like this and see no problem about it. They love to say "overengineering", "perfect is the enemy of the good" and "the business".