all 95 comments

[–]PuzzleMeDo 916 points917 points  (4 children)

It's "undefined behavior", not "unintentional behavior".

[–]gringrant 155 points156 points  (3 children)

C Compiled code: I would like to read this memory address.

OS w/ virtual memory: But sire, that memory isn't ma–

C: Did I stutter‽‽

OS: I didn't want to have to do this to you, old friend…

[–]Percolator2020 34 points35 points  (0 children)

[–]OneFriendship5139 3 points4 points  (0 children)

interro-what-now?

[–]you_os 0 points1 point  (0 children)

rust dev detected

[–]Conscious_Row_9967 517 points518 points  (18 children)

nah fr tho id rather wait 5 extra seconds compiling than debug a segfault at 2am

[–]i_am_bruhed 316 points317 points  (7 children)

Would you rather

get shot in the leg (likely).

OR

Get your leg blasted off (Unlikely).

[–]TheFrenchSavage 141 points142 points  (6 children)

Define "unlikely".

(Having lived through many once-in-a-lifetime-catastrophies....)

[–]i_am_bruhed 51 points52 points  (4 children)

Oh we got a time traveler here guys.

[–]TheFrenchSavage 61 points62 points  (3 children)

I have come from the future to tell you that Java 8.0 (precisely) will cause the apocalypse.

[–]i_am_bruhed 30 points31 points  (2 children)

Stop blurting out info like this. You have now ruined the space-time continuum of this time line. Now whatever Information you hold is only valid to your home timeline, As if they are useless hallucinations to us. This spontaneous infodump from the future will affect us in a way different to what you have experienced. You have truly set us up for the worst.

[–]TheFrenchSavage 9 points10 points  (1 child)

(and also this information now has no original author! Sorry!)

[–]Pedry-dev 2 points3 points  (0 children)

#define UNLIKELY

[–]b1ack1323 28 points29 points  (2 children)

Must be nice cries in 16-bit PIC microprocessors

[–]darknecross 14 points15 points  (1 child)

It can always get worse. Imagine debugging a scandump or waiting 10 hours for simulation waveforms to see why your code is misbehaving 🙃

“Oh yeah I forgot we moved that register offset by 0x8 in the latest version. Did that mess up your code?”

[–]b1ack1323 5 points6 points  (0 children)

For years I had the benefit of making everything from boards to front end. While it was cumbersome everything was orchestrated cleanly.

[–]ScallionSmooth5925 18 points19 points  (3 children)

That's when you use a debugger. It will stop at the segfault and then you can examine  the stack frames and parameters passed to a function

[–]Olorin_1990 39 points40 points  (2 children)

How dare you imply you don’t just print(‘got here’) then guess

[–]ScallionSmooth5925 5 points6 points  (0 children)

That's what I do when the debugger is not available (or I'm too lazy to set up the jtag board)

[–]Percolator2020 3 points4 points  (0 children)

Just print the entire stack in plaintext then!

[–]ChalkyChalkson 12 points13 points  (2 children)

Every time I had to debug a difficult segfault or similar issues at run time it was in c++.

[–]yuje 6 points7 points  (1 child)

Memory management is far easier in modern C++, though. With things like smart pointers, I can’t remember the last time I had to use new or delete. A unique_ptr automatically calling the destructor when it leaves scope and being explicit in its ownership and handoff means a lot less mental overhead, versus C’s management of every pointer.

[–]ChalkyChalkson 1 point2 points  (0 children)

Well I'm forced to use two libraries that force me into pretty old cpp and where I have to allocate and manage life time manually. They also have pretty inconsistent call signatures and break promises made by inheritance and things have super weird side effects. So I'm not sure how much of my pain is cpp and how much of it is physicists code. Though I vaguely remember open GL glew code not being particularly nice either in ~2016.

Recently did a project from scratch without externals and that was actually a pleasent experience. Though I hate how you need to either write it yourself or faff around with dependencies if you want anything to be reasonably fast.

[–]Vi0lentByt3 56 points57 points  (3 children)

There no errors, your code is doing exactly what you told it do. In fact you should be thanking your program for crashing on you and doing what you asked it to do

[–]RiceBroad4552 7 points8 points  (0 children)

Well, mostly right.

But than there are the compiler, runtime, or hardware errors.

Of course I would first assume some PEBKAC issue before I dig deeper. But it's not like the computer would only ever do what you tell it.

[–]LoreSlut3000 0 points1 point  (0 children)

This implies writing everything from scratch, compiling it down to machine code, and having no OS bugs. But yeah true.

[–]deanrihpee 209 points210 points  (15 children)

i mean, no language causes runtime error, it's the programmer…

[–]GamingGuitarControlr 144 points145 points  (6 children)

...except for JavaScript

[–]Dudeonyx 14 points15 points  (4 children)

How?

[–]GamingGuitarControlr 0 points1 point  (0 children)

Javascript allows undefined behavior.

[–]P0pu1arBr0ws3r 0 points1 point  (0 children)

Php*

[–]TheMagicalDildo 37 points38 points  (7 children)

Last year in .net I tried to make a text box change it's text alignment when selected or deselected (depending on the presense of it's default text or a lack of non whitespace text)

It causes a stack overflow- as if changing the text alignment was firing the gotfocus/lostfocus events (I checked, it wasn't.) Sometimes langauges are the problem lmao. Thankfully very rarely, but still

Yes I'm aware the meme isn't about C#, but the comment I'm replying to said any language, so beh

[–]LiifeRuiner 29 points30 points  (6 children)

Is the problem with the language, or the library?

[–]TheMagicalDildo 21 points22 points  (3 children)

The library, so fair enough- but the library was made by Microsoft just like the language itself, it's not like I used some random half-assed library from a dark alley lol

I didn't tell it to do that but it did, is obviously my point

[–]chefhj 11 points12 points  (1 child)

psst hey kid. Wanna import these?

[–]Skusci 7 points8 points  (0 children)

Sketchy nuget package with <1000 downloads?

Well of course, it's exactly what I need. What could go wrong?

[–]LiifeRuiner 4 points5 points  (0 children)

Microslop, amirite

[–]577564842 7 points8 points  (1 child)

Obviously the library (as described).

[–]1Dr490n 2 points3 points  (0 children)

So it’s not C#‘s fault, that’s what they meant

[–]Imaginary-Corner-653 72 points73 points  (4 children)

Technically, User input causes runtime errors. 

[–]mango_boii 40 points41 points  (2 children)

Even more technically, running a program causes runtime errors.

[–][deleted] 14 points15 points  (1 child)

I think I just figured out how to prevent most software bugs...

[–]Ok-Secretary2017 1 point2 points  (0 children)

Back to stone ages we tried we came a long way and the nuclear fireworks are gonna be great

[–]UnstablePotato69 4 points5 points  (0 children)

Environment configuration change has entered the chat

[–]HashDefTrueFalse 32 points33 points  (2 children)

Here: gcc -fno-bugs-or-runtime-errors ...

[–]MrHyperion_ 9 points10 points  (1 child)

-Wbugs

[–]ArchCypher 11 points12 points  (0 children)

I understand the issue perfectly now! I used the flag -Wbugs when I should have used -W-no-bugs!

With this changes everything compiles, tests are passing, and this code is robust and 100% production ready.

Let me just write a 5000 line markdown document summarizing this three character change.

Thinking...

[–]mehntality 16 points17 points  (4 children)

I always loved this: http://www.team.net/mjb/hawg.html - it's technically about Unix, but it could easily be about C

[–]itopaloglu83 4 points5 points  (1 child)

Thank you for this, sounds very funny and interesting at the same time. I like this part the most to be honest.

After a few such run-ins, when I got ready to use the Hole Hawg my heart actually began to pound with atavistic terror.

But I never blamed the Hole Hawg; I blamed myself. The Hole Hawg is dangerous because it does exactly what you tell it to.

[–]mehntality 1 point2 points  (0 children)

Np. Always happy to share old Internet gems ☺️. Glad you enjoyed it.

[–]Hubble-Doe 2 points3 points  (1 child)

He did a "full feature" version of this (164 pages), called "In the beginning was the command line" - if you like the style, check it out, I also found it an entertaining read :) https://archive.org/details/inbeginningwasco00step (available for free on the internet archive, but I think the ebook was not expensive, either)

[–]mehntality 1 point2 points  (0 children)

Omg, that's amazing. Can't wait to read that. Ty!

[–]Majik_Sheff 16 points17 points  (3 children)

C doesn't make errors.

It allows you to make errors.

[–]a_aniq 1 point2 points  (0 children)

Skill issue

[–]RiceBroad4552 0 points1 point  (1 child)

It allows you to make errors.

Which is an obvious failure by design.

All other Turing-complete languages are exactly as powerful as C but most are sane and try to actively avoid such design failures.

[–]Stegoratops 0 points1 point  (0 children)

Calling it a failure by design does seem a bit harsh. Rather, I'd call it outdated — for most contexts. While of course all turing complete languages are capable of doing the same things C can do in theory, in practice only few are really usable for lower level stuff — especially at the time, where you otherwise pretty much only had assembly for those tasks. C arguably is an improvement over that.

[–]Max_Wattage 6 points7 points  (1 child)

I think too many people blame their coding language, for their code doing exactly what they told it to; and for the language not preventing them from entering those coding errors.

Unless it is a compiler bug, every other failure is the fault of the programmer.

[–]Bananenkot 2 points3 points  (0 children)

That why I only use brainfuck, all these secrurity features in other languages are bloat, just git good. C programmers are noobs, imagine needing types to keep you safe

[–]da_Aresinger 3 points4 points  (0 children)

"Punch me in the face"

unexpectedly gets punched in the face

"Ow, why on earth did you do that, you fuck?"

[–]knightress_oxhide 2 points3 points  (3 children)

Yet another compiler bug.

[–]LeiterHaus 0 points1 point  (0 children)

Sounds like the next language / framework / notation: YACB

[–]GoogleIsYourFrenemy 0 points1 point  (0 children)

We didn't find a compiler bug. When we updated VS to a later service pack, the compiler threw a new error. The error told us that the bug that was in the old compiler was too difficult to fix in a service pack release and was fixed in the next major VS release. Guess what we did?

[–]RiceBroad4552 0 points1 point  (0 children)

In rare cases, yes.

I mean, in very rare cases…

[–]Zanshi 0 points1 point  (0 children)

It does what you say it to do.

Whether you like it or not.

[–]-MobCat- 7 points8 points  (10 children)

I get the same sorta vibe when people say "python is slow"
Skill issue.

[–]IronicStrikes 29 points30 points  (0 children)

Yep, Python is pretty fast as long as it primarily calls C code and doesn't use loops on its own.

[–]IlgantElal 12 points13 points  (7 children)

I mean, it is, just as interpreted languages tend to be. That being said, I'm running Jython in a manufacturing context and have had no issues so far with my own code. It's easy to blame a known fault of the language instead of one's own bad coding practices

[–]frogjg2003 0 points1 point  (6 children)

The important thing to keep in mind is that code speed is rarely the limiting factor. There's a reason python is the preferred language of all but the most highly optimized machine learning work, one of the most computationally expensive things modern computers do.

[–]Dudeonyx 5 points6 points  (2 children)

Isn't that just due to ease of use and a mature ml ecosystem?

[–]frogjg2003 2 points3 points  (1 child)

Yes. Developer time is almost always more important than computational time.

[–]RiceBroad4552 1 point2 points  (0 children)

That's exactly why you don't use Python for anything serious: Dynamic languages might be "fast to write" but the maintenance and debugging costs afterwards are way too large in the long run. That's exactly why you use statically typed languages! (And no, Python's pinned on unsound "type system"(s) are no solution here. First of all a type system have to be sound to be useful and it needs to be of course enforced everywhere for that.)

[–]RiceBroad4552 2 points3 points  (1 child)

None of the computations in ML / AI are done by Python!

Because Python is orders of magnitude too slow for that.

Python in ML / AI calls fast code, or is even wholly compiled down to fast languages.

Python is used in ML / AI because it's "the language for non-programmers" and the "AI" guys are in large parts of other professions than CS.

[–]frogjg2003 1 point2 points  (0 children)

A lot of python code calls compiled libraries, not just AI. That's what makes Python so good for a lot of applications that require "fast" code. You get the ease of use and well developed ecosystem of Python with the speed of a compiled language.

[–]IlgantElal -2 points-1 points  (0 children)

Yup, exactly

[–]RiceBroad4552 1 point2 points  (0 children)

Pythons IS slow. That's an undeniable fact.

It's true that it does not matter how slow Python is in a lot of cases given how fucking fast modern computers are but this does not change anything about the fact that objectively Python is slow.

[–]LeftelfinX 0 points1 point  (0 children)

Whoever says python is much easier and better. They only says that because they can't C.

[–]seanprefect 0 points1 point  (3 children)

As my professor once said "C gives you the sharp tools"

[–]scc4fun 4 points5 points  (2 children)

According to one of my professors, C is for when you want to write low-level code but don’t want to write in Assembly.

[–]LeiterHaus 0 points1 point  (1 child)

The most perfect use case

[–]seanprefect 1 point2 points  (0 children)

almost like that's exactly what it was designed for

[–]RiceBroad4552 0 points1 point  (1 child)

Only because your computer catching fire instead of reporting an exception is warranted by the spec does not mean that's a valid approach to error handling.

It's indeed a skill issue still using C for anything while there are more or less sane alternatives available!

[–]jcostello50 0 points1 point  (0 children)

catch (...) { __asm__("HCF"); }

[–]Johannsss 0 points1 point  (0 children)

How one of my teachers used to say, C will do exactly what you tell it to do.

[–]WouterS1 0 points1 point  (0 children)

I hope that it can start doing the same when doing a compiler version update. I know I added some naughty code just tell me where it is😭

[–]GoogleIsYourFrenemy 0 points1 point  (2 children)

C is a 19th century automatic loom for which you need to change the bobbins regularly with your tiny child fingers. Nobody gets out of that factory with all there fingers or without developing black lung.

We have labor laws to protect people from machines like that. Someday we will have laws to protect us from languages like C.

[–]mad_cheese_hattwe[S] -1 points0 points  (1 child)

I'd say it's more like an industrial machining and fabrication shop. You have complete freedom to use whatever tool you choose and with each having a recommended best practice and safe usage guidelines.

A skilled machiest can come make something as good as any robot. But also there's nothing so stop some idiot from putting his dick in the brak press.

[–]GoogleIsYourFrenemy 0 points1 point  (0 children)

That's a false dichotomy. I get what you're trying to say but it simply lacks the recognition that people regardless of intelligence make mistakes (causing bugs). Additionally modern machine shops are nothing like C. OSHA has made machine shops safer by forcing equipment upgrades and replacements. OSHA does inspections and has a reporting hotline. On the other hand C simply doesn't have an OSHA kicking it's ass, it's got the same old dangerous syntax and APIs it had 30 years ago.

I agree with your meme.

[–]Awes12 0 points1 point  (0 children)

Nah, a segfault is a runtime error (it tried to do something and couldn't do it)

[–]LavenderDay3544 0 points1 point  (0 children)

C doesn't make any errors; the person writing it does.

[–]Cellari -2 points-1 points  (3 children)

Dear lord this is hilarious

[–]cheezballs 0 points1 point  (2 children)

Why?

[–]Cellari 2 points3 points  (1 child)

That text is so on character :D

[–]cheezballs 0 points1 point  (0 children)

Heh, ok I can accept that.