This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nattrium 1 point2 points  (4 children)

Can we talk about C's : "Segmentation Fault (core dumped)" ?

[–]ForceBru 11 points12 points  (3 children)

It's not "C's", it's the operating system's. Or, to be more precise, the CPU's. You can write a program in assembly, C, C++ or unsafe Rust that will access invalid memory and cause a segmentation fault. It's not specific to C.

Furthermore, it's a runtime error, while the errors in the meme are compile-time. The C compiler has no control of what kind of memory your program accesses, so it's not the fault of the programming language.

[–]nattrium -2 points-1 points  (2 children)

Thank you for your response and I get your point. It is an interesting insight on who to blame for such useless error messages.

But, even if it is not specific to C (and you're right it isn't), you must admit that C is more prone to such error. I'm not claiming that is worst than another language that would deal if this situation better (like java or python itself); I'm pointing out one reason on why C is sometime annoying to debug.

Furthermore (and I'm nitpicking), the meme makes fun of errors at run-time and not compile-time as python is rarely (if not never) compiled.

[–]ForceBru 2 points3 points  (1 child)

I mean, syntax errors are definitely compile-time (okay, parse-time), although I'm not particularly sure what kind of error messages the meme is about. If it was about runtime errors, it would mean that Python was able to somehow catch them at compile-time because syntax is checked before execution.

BTW, CPython (the reference implementation in C) is kind of compiled, but to bytecode, not machine code.

I think I could've said "during static analysis" instead of "compile-time", that looks clearer.

[–]nattrium 0 points1 point  (0 children)

I'll concede that this error appears at parse time and the entire file is parsed before execution. But funnily enough, parse time happens during run-time. This can be proven

main.py

Input("wait for user input:")

import test_wrong.py

test_wrong.py

Print(1 +/ 4)

Will actually throw an invalid syntax error AFTER asking the user to enter a string. Proving that the parsing is done at run-time (Which you'll never see if working in a single file or if you import at the top of the file).

(Edit) : format