Ask HN: How do I write quick and dirty, spaghetti code?
I want to start a project, with no concern for design patterns, clean code, separation of concerns.
I want to write the most spaghetti, working, hacky code that works. C#, Java, Php, JS or python. What tips do you have? You might need a throwaway for this hahaha.
13 comments
[ 2.7 ms ] story [ 44.9 ms ] threadAll of those are details to worry about later.
Jeez! It's funny how reading so many HN tech blogs actually limited me, I was trying too hard to be a perfect programmer.
It's fun because you have to know a few details about the language that aren't widely known (you can define as many classes as you want in a file, only one of them can be public.) It is handy when you want to write things that are really scripty or self-contained like you might want to do for tests.
I'm not one of them but there are many people who hate Java and hate object-orientation and single-file Java provides many chances to fight orthodoxy. Sometimes people are very happy to see single-file Java but sometimes it really drives people up the wall... If you want to break all the rules for your tribe it's a great foundation to start with.
Failing that, design your software with nice abstractions, then do the compiler's job and strip them all out and turn it into a bunch of if/gotos. Preferably with vague (ideally numeric!) label statements.
Otherwise I'm not sure it's actually possible to write anything larger than a couple hundred lines without paying homage to design patterns and consistency, if only in your head. It took me a long time to learn that code's greatest enemy is the task of holding up its own weight.
Do you prefer then to grow organically, or do you enforce then from the start?
Inelagant code that works. Just for personal use.
Not code that will run a space station obviously
One can make use of design patterns, clean code and separation of concerns and still get working spaghetti code without all the hacky stuff. Much less effort if use C.
Engineered C case studies as goto solutions! https://blog.feabhas.com/2017/02/abusing-c-switch-statement-... https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
Just have to impliment the program as if it was an OS. aka mix/match abstraction levels!
Mix/match assembler / language macros / foreign language calls to other language libraries
Use C20 ability to assign case statement(s) to a thread (mixed with remote procedure calling and/or function stacks across multiple threads)
Mix & match unicode/non-unicode, hex, ascii, etc. where text is code that can be run.
Mix and match C# language extensions in which same thing can be implimented different ways (e.g. strings, vectors, templating)
About as likely as NULL nil adding to a value greater than 0 in a standard programming language.
aka progressing beyond nil'ist gotos