What is "spaghetti code"? - /g/ (#105712732) [Archived: 712 hours ago]

Anonymous
6/26/2025, 7:26:52 PM No.105712732
mom's spaghetti
mom's spaghetti
md5: 55a132f218b0a6b74622081c883c42d1🔍
Most people don't seem to have a clear definition.
Replies: >>105712767 >>105712769 >>105712777 >>105712793 >>105712794 >>105712803 >>105712805 >>105712919 >>105713144 >>105714871 >>105714983 >>105715036 >>105715396 >>105717149 >>105720217
Anonymous
6/26/2025, 7:30:29 PM No.105712767
>>105712732 (OP)
If i ask you "please remove this feature" and you spend more than 30 seconds looking for its implementation then its spaghetti code
Anonymous
6/26/2025, 7:30:34 PM No.105712769
>>105712732 (OP)
For me, it's code that is strung out (hence the spaghetti metaphor) across a bunch random files with poor structure. For instance, File A calls a method in File B and File B calls a method in File C that updates a state in File A.
Anonymous
6/26/2025, 7:32:21 PM No.105712777
>>105712732 (OP)
unorganized code, messy code that's hard to track.
It's a simple definition.
Anonymous
6/26/2025, 7:32:37 PM No.105712781
nigger = "spaghetti"
print(nigger)
Anonymous
6/26/2025, 7:33:32 PM No.105712793
>>105712732 (OP)
It means it's tangled and complicated like spaghetti, it usually means separation of concerns doesn't exist and you have fuckhuge functions changing state in other smaller functions without any good reason, you can't make small changes without breaking shit easily, a tangled, fragile mess.
Anonymous
6/26/2025, 7:33:31 PM No.105712794
1730857758450029_thumb.jpg
1730857758450029_thumb.jpg
md5: 949eb8b323a12a3fa1de04035fd26d18🔍
>>105712732 (OP)
Almost every Python project.
Anonymous
6/26/2025, 7:34:39 PM No.105712803
navi go boom 1750218414905640_thumb.jpg
navi go boom 1750218414905640_thumb.jpg
md5: d065fd86944a89b0fcc8d6d1e6204f34🔍
>>105712732 (OP)
I just wish "spaghetti" wasn't synonymous with bad code, because I love spaghetti.
Anonymous
6/26/2025, 7:34:59 PM No.105712805
>>105712732 (OP)
Code that's above your IQ level.
Replies: >>105712829 >>105712848
Anonymous
6/26/2025, 7:37:09 PM No.105712829
>>105712805
>Code that's below fridge IQ level.
So basically every Python project.
Anonymous
6/26/2025, 7:39:36 PM No.105712848
>>105712805
>Code that's above your IQ level.
this
Anonymous
6/26/2025, 7:44:57 PM No.105712919
>>105712732 (OP)
>Identify how structure [X] feature integrates with structure [Y]
>have to go through structures [W] [V] [T] and [R} to explain it
Anonymous
6/26/2025, 8:06:58 PM No.105713144
>>105712732 (OP)
The term spaghetti code was coined before structured programming when all you had was GOTOs. Instead of having well-defined functions or procedures you'd just have code randomly jumping around labels so if you wanted to find out what was going on you had to follow around jumps like following a string of spaghetti.
This type of code in the strictest sense is mostly outdated at this point.
Replies: >>105714882 >>105715473
Anonymous
6/26/2025, 8:08:30 PM No.105713163
code that is hard to scale
Anonymous
6/26/2025, 10:53:25 PM No.105714871
>>105712732 (OP)
no overarching structure. following the control flow will lead you in a circle around the whole project
Anonymous
6/26/2025, 10:54:15 PM No.105714882
>>105713144
the modern gotos are cross file references
Anonymous
6/26/2025, 11:04:28 PM No.105714983
>>105712732 (OP)
Italians have an undeserved reputation.
Curry code on the other hand...
Anonymous
6/26/2025, 11:10:07 PM No.105715036
>>105712732 (OP)
You can't understand what it does, you can't properly extend it or fix something without breaking some other, potentially unrelated functionality, you can't reuse any code because it's part of a 2000 line function and does tons of side effects you don't want or need...
And optionally it's just bugged as hell.
Anonymous
6/26/2025, 11:45:46 PM No.105715396
>>105712732 (OP)
Code that someone else wrote
Anonymous
6/26/2025, 11:53:27 PM No.105715473
>>105713144
the term is still somewhat relevant
goto being the "nigger" of programming has only made it very slightly more difficult for retards to make incomprehensible codebases
Anonymous
6/27/2025, 3:26:33 AM No.105717149
>>105712732 (OP)
If you print out the code and draw lines in the margin next to it tracing out the jumps, the lines end up looking all tangled up like spaghetti.
Anonymous
6/27/2025, 4:20:01 AM No.105717472
Pointers
Branch prediction
Flow control
Anonymous
6/27/2025, 7:17:08 AM No.105718735
yours
Anonymous
6/27/2025, 7:25:16 AM No.105718783
508475071_122175576434337203_1251587166501115805_n
508475071_122175576434337203_1251587166501115805_n
md5: 510fe057bd7f6b027ca253fa6758aa8a🔍
Clean code is well structured. You read it and you understand what it does, but spaghetti code is mostly made up of nested functions that abstract each other into oblivion. You read the subroutines and you wont understand them unless you read the other subroutines they are nested into, and to untangle this mess you would rewrite it. This is literally spaghetti
Anonymous
6/27/2025, 11:00:43 AM No.105720217
>>105712732 (OP)
long strings with little to no structure.