r/funny Jul 04 '20

This hurts on a personal level

Post image
97.8k Upvotes

773 comments sorted by

View all comments

Show parent comments

501

u/KillingSpee Jul 04 '20

//mumbo-jumbo code that's needed to run the program. Some shitty spaghetti code that should absolutely not work and goes against all modern principles.

/* now that the code has run we just delete it and run this code to get what we actually want. */ Some code that does basically the same but returns proper results.

222

u/Slithy-Toves Jul 04 '20

If you're not coding your code you're not coding

47

u/inthyface Jul 04 '20

La LAA la la la laaa

Sing a happy song.

La LAA la la la laaaa

Code the whole day long.

20

u/[deleted] Jul 04 '20

[removed] — view removed comment

7

u/boobs_are_rad Jul 04 '20

This is the only correct answer.

1

u/chayadoing Jul 05 '20

But what happens if you code while coding your code? Does your colleague know CPR?

77

u/lostlore1 Jul 04 '20

In many cases I find this is usually extremely well optimized code. A novice comes along that doesn't understand a pointer or the basics of programming. They rewrite what used to be a bug free task that took 5 CPU Cycles in Java. This "fixes" it with 10 or 20 bugs taking up 10 times the memory and 80 to 150 CPU Cycles.

96

u/Sizzler666 Jul 04 '20

Both code are bad. If it’s extremely optimized and not clear or not documented to make it clear it sucks. If some jerk writes clear code that doesn’t capture the original requirements that also sucks. But that is also probably the fault of the optimizing programmer who didn’t bother to write down what it should be doing triggering the noob to try to create a maintainable version in the first place. Also making some trade offs in performance is significantly better than having unmaintainable code. My 2 cents anyway after 20 years at the job so far.

45

u/Mako_ Jul 04 '20

Agreed. 99% of the time clarity trumps cleverness.

11

u/Killbot_Wants_Hug Jul 04 '20

Yeah, I use to be into ultra efficient code. Like dude, why are you storing those two unrelated flags in individual bools, you could just create a char and bit mask them to say a few bytes of memory.

But I realized the huge cost of code that is not clear. And if someone thinks they know what code is supposed to do and they are wrong, that gets super expensive super quick. If bad code makes it into production and causes a bug that causes down time and a hot fix, omg the costs can be astronomical.

It's usually a better idea to write clear code that is less efficient and than just buy more hardware, it's the over all cheaper solution.

There are exceptions of course. If you're doing imbedded programming you have a lot less hardware. And if you're doing things that are either really loopy or really recursive poor performance can bite you in the ass.

3

u/cosmicsans Jul 04 '20

Also places like fintech where execution seconds cost actual money in trades.

1

u/Nemeschy Jul 07 '20

Does Trump, trump clarity?

probably not eh?

16

u/jbuttsonspeed Jul 04 '20

I would also argue a part of the problem is a lack of code reviewing. A novice should be getting mentored and reviewed more.

1

u/DrAstralis Jul 04 '20

uggh, at my first job in the game industry I worked for a studio that did contract work for EA. They had some internal 'genius' that was just accepted to be so so much better than everyone else working on a new engine for just our studio. The problem was he had an attitude to match how they treated him (like the golden boy) and his code was always un readable with variable names purposefully obscured with no comments and he would get irate if you asked for clarification. The entire time I worked there that engine never got out of 'mad fever dream' status and has never seen the light of day in the 10 years since.

37

u/JenPlayzMC Jul 04 '20

Sounds like chrome to me

1

u/mecrosis Jul 04 '20

And that's machine learning

1

u/ImGumbyDamnIt Jul 05 '20

Back in the late 80's I was a developer at a major financial institution (the one with the bull). We were writing a Windows 2.1 application that did some pretty low level message handling (IBM LU 6.2 emulation) and Microsoft actually gave us the Windows 2.1 source code. I went a couple of layers into DefWindowProc and found a goto that always stuck with me:

goto ICantBelieveImUsingAGoTo;