296
you are viewing a single comment's thread
view the rest of the comments
[-] ByGourou@sh.itjust.works 8 points 7 months ago

Sorry, I want to make an app that works, not a perfect art piece.

[-] 9point6@lemmy.world 4 points 7 months ago

The app working isn't good enough, it needs to be maintainable. From a professional perspective, unmaintainable code is useless code.

Code that mutates everywhere is generally harder to reason about and therefore harder to maintain, so just don't do it (unless there's literally no other practical way, but genuinely these are very rare cases)

[-] ByGourou@sh.itjust.works 1 points 7 months ago

I personally disagree, forcing yourself to use non mutable variables only leads to longer and more convoluted code.

[-] 9point6@lemmy.world 2 points 7 months ago

Fair play, I guess we're probably just gonna disagree.

In my experience I'd say mutable code (larger than anything other than toy examples) always results in more time spent fixing bugs down the line, predominantly because it's objectively harder for humans to reason about multiple one to many relationships rather than multiple one to one relationships. I'd say because you need to think about all possible states of the set of mutable variables in your code in order to completely understand it (and I don't just mean understanding the intended purpose of the code, I mean understanding everything that code is capable of doing), that usually results in a more convoluted implementation than the pretty linear way you typically read functional code.

Longer code is practically always better if it's easier to understand than the shorter alternative. Software engineers aren't employed to play code golf, they're employed to write maintainable software. Though I'll say ultra high performance applications might be the exception here—but 99% of engineers aren't doing anything like that.

I'm always happy to be convinced otherwise, but I've never seen a convincing argument

this post was submitted on 21 Mar 2024
296 points (94.8% liked)

Programmer Humor

19450 readers
359 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS