Beautiful But Deadly

9 months ago by other_cat to c/programmer_humor

RedFrank24 122 points 9 months ago

Anyone who complains about code not compiling on the first try likely hasn't been coding for very long. Getting your code to do what you tell it is easy, getting it to do what you want is hard.

path: 0 21749004, hotness: undefined, score: 122, children: 19
AngryCommieKender 52 points 9 months ago

Code will ALWAYS do EXACTLY what you tell it to do, and that is specifically the problem.

path: 0 21749004 21750996, hotness: undefined, score: 52, children: 3
Amir 17 points 9 months ago

Tell that to undefined behaviour

path: 0 21749004 21750996 21754903, hotness: undefined, score: 17, children: 2
entropicdrift 3 points 9 months ago

Just threw up in my mouth a little

path: 0 21749004 21750996 21754903 21780232, hotness: undefined, score: 3, children: 1
sp3ctr4l 3 points 9 months ago

Make sure to try - catch the vomit in the event it potentially escapes your mouth.

path: 0 21749004 21750996 21754903 21780232 21784965, hotness: undefined, score: 3, children: 0
ClownStatue 36 points 9 months ago

Getting your code to do what you tell it is easy. Getting it to do what you want is hard.

New email signature unlocked.

path: 0 21749004 21750779, hotness: undefined, score: 36, children: 0
OpenStars 22 points 9 months ago

img

path: 0 21749004 21749049, hotness: undefined, score: 22, children: 0
schnurrito 13 points 9 months ago

I usually code in an IDE that tells me whether my code will compile while I am typing it.

But when I write things like PL/SQL, yeah it is definitely an achievement to get it to compile.

path: 0 21749004 21752510, hotness: undefined, score: 13, children: 4
OpenStars 4 points 9 months ago

Have you ever tried compiling your BASH scripting code? Man, that's like, almost literally impossible! :-P

path: 0 21749004 21752510 21754363, hotness: undefined, score: 4, children: 0
Magnum 1 point 8 months ago

You compile your SQL?

path: 0 21749004 21752510 22117755, hotness: undefined, score: 1, children: 2
schnurrito 1 point 8 months ago

PL/SQL needs to be compiled, there can be compilation errors when you create a function or procedure on an Oracle DB. Doing that is part of my current job, so I definitely know what I'm talking about.

path: 0 21749004 21752510 22117755 22118021, hotness: undefined, score: 1, children: 1
Magnum 1 point 8 months ago

Polish people acting fancy again

path: 0 21749004 21752510 22117755 22118021 22118560, hotness: undefined, score: 1, children: 0
ulterno 10 points 9 months ago

When I started programming with C, it was pretty easy to get code to compile on my first try.

Now, when I use C...
_POSIX_C_SOURCE >= 199309L ... was in the man page, but didn't work... _GNU_SOURCE works.
Read somewhere to just use -std=gnu17 and remove _GNU_SOURCE and nice, it works.
Create another project with -std=gnu17, but using another function and now it doesn't work. Need to add _GNU_SOURCE. Why?

path: 0 21749004 21751953, hotness: undefined, score: 10, children: 0
merc 2 points 9 months ago

Anyone who doesn't complain about code not compiling on the first try likely writes dead simple programs and could be replaced by an LLM. Writing simple programs is easy, writing complex programs is hard.

path: 0 21749004 21758782, hotness: undefined, score: 2, children: 6
Beanie 2 points 9 months ago

i mean, yeah? but also the language doesn't become more complicated with larger programs and you typically don't spit out thousands of lines of code without compiling at least some of it at least once

path: 0 21749004 21758782 21774739, hotness: undefined, score: 2, children: 5
merc 2 points 9 months ago

Most programmers I know compile a program when they have fully expressed an idea they have in their heads. It might just be the first outline of the idea. But, it's a solid first sketch that contains all the key details. Unfortunately, often that's a complex idea so it can be somewhere on the order of an hour before they stop coding and try compiling. One reason for that is that compiling the program is a context switch, and when they context switch they can't keep all of their thoughts about the program in their head, instead they have to think about compiling. And, if compiling takes more than a few seconds their attention also starts to drift to other things.

Coding for something like an hour without making a single typo or braino is difficult. This is especially true if the programmer is attempting to express a creative idea. Their focus won't be on getting every single detail correct, it will be in sketching the shape of the idea as completely as possible. 99% of the time, those mistakes are entirely obvious and take no time to fix. But the compiler is (luckily) unforgiving of errors, even if the fix is obvious. But, that's why it's suspicious if the code compiles perfectly the first time.

It's possible that some people have different workflows. Maybe they write out the entire program in comments and pseudocode before using an actual programming language. If you do that, then you can probably afford to take a break from the actual coding more often and compile what you have so far. Maybe you're compiling every 5 minutes instead of every 30, in which case it's pretty normal not to have any compiler errors. Maybe some people use a super advanced IDE that effectively compiles the code in the background all the time and flags errors that will become compiler errors. I think a lot of people who became programmers before that kind of thing was popular find that sort of thing to be distracting. If they're trying to write something on line 50 and the IDE flags something from line 45, they might have already shifted their context a bit, and having to go back and fix that will distract them from the thing they're currently trying to express.

Personally, I've often had no compiler errors when writing tests. Tests are often very small, self-contained bits of code that don't take long to write, and aren't very complex, so it's pretty normal to have a test compile and run perfectly the first time.

The point is, programmers who have been programming for a long time are the ones who are more likely to be surprised if their code compiles perfectly the first time.

path: 0 21749004 21758782 21774739 21777431, hotness: undefined, score: 2, children: 4
wpb 1 point 9 months ago

Unfortunately, often that’s a complex idea so it can be somewhere on the order of an hour before they stop coding and try compiling.

Maybe I've been lucky with the people I got to work with so far (and I definitely am), but I know of no professional software engineer that would voluntarily subject themselves to such a long feedback loop. I guess some of the juniors try to work this way sometimes, but they learn fairly quickly not to. The best ones I know work incrementally. Small change, run, small change run, and so on.

path: 0 21749004 21758782 21774739 21777431 21778257, hotness: undefined, score: 1, children: 3
pipe01 49 points 9 months ago

Compiling is only half the battle

path: 0 21747184, hotness: undefined, score: 49, children: 6
marcos 54 points 9 months ago

That's why you know that if your code hasn't put up a fight yet, it's because it's saving its energy.

path: 0 21747184 21747647, hotness: undefined, score: 54, children: 1
boeman 8 points 9 months ago

I feel that in my soul.

path: 0 21747184 21747647 21748821, hotness: undefined, score: 8, children: 0
palmtrees2309 40 points 9 months ago

In Rust, it is 80% of the battle.

path: 0 21747184 21749253, hotness: undefined, score: 40, children: 1
Siethron 21 points 9 months ago

In assembly it's none of the battle. Or all of the battle depending on the perspective.

path: 0 21747184 21749253 21749887, hotness: undefined, score: 21, children: 0
kautau 7 points 9 months ago

Can’t wait to see how much lint is in her dryer

path: 0 21747184 21748164, hotness: undefined, score: 7, children: 0
Magnum 1 point 8 months ago

If compiling is half your battle, you have already lost

path: 0 21747184 22105278, hotness: undefined, score: 1, children: 0
MadMadBunny 23 points 9 months ago

That’s deep poetry

/s

path: 0 21747085, hotness: undefined, score: 23, children: 3
craftrabbit 4 points 9 months ago

What do you mean "/s"?

path: 0 21747085 21752171, hotness: undefined, score: 4, children: 2
deadbeef79000 7 points 9 months ago

He's dividing by s.

in case you are serious

"/S" means "sarcasm"

path: 0 21747085 21752171 21753608, hotness: undefined, score: 7, children: 1
Klnsfw 1 point 9 months ago

Without checking if s!=0

path: 0 21747085 21752171 21753608 21778252, hotness: undefined, score: 1, children: 0
some_guy 13 points 9 months ago

I'm so happy that, after I decided that I was gonna close Lemmy after reading the posts on the current page, this was the last one. What a great way to wrap up and go about my day after horrible current events and such.

path: 0 21775494, hotness: undefined, score: 13, children: 1
WorldsDumbestMan 5 points 9 months ago

It will get better, if we make it better.

path: 0 21775494 21777703, hotness: undefined, score: 5, children: 0
tiramichu 10 points 9 months ago

Unit tests that pass first time

path: 0 21777611, hotness: undefined, score: 10, children: 0
ragas 6 points 9 months ago

God, I have days like this where I build a feature for a whole day nevrr compile in between as it is not done yet. Then run it and it just works.

The next day is spent in paranoia mode trying to write more and failing tests.

2-3 times in my career it happend that the tests never failed and I had just written complex code that worked on the first try.

path: 0 21779556, hotness: undefined, score: 6, children: 0
sp3ctr4l 2 points 9 months ago

Wait wait wait.

So, analogously...

What would JIT compiler style code be?

... oh no.

I think it would basically be a co-dependent sycophant with no personality beyond pleasing you.

path: 0 21784995, hotness: undefined, score: 2, children: 0
tatterdemalion 1 point 9 months ago

These days with language services, code should be compiling after nearly every edit.

path: 0 21778051, hotness: undefined, score: 1, children: 0
programmer_humor
programmer_humor

@programming.dev

login for more options
33571
2550
7101

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

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
    • If the mod doesn't find it funny, you're banned. Ha-ha!... For real: do not use the community for "statements". There are other places for such content. Keep it chill and funny.

go to feed...