←back to thread

218 points signa11 | 1 comments | | HN request time: 0s | source
Show context
pjmlp ◴[] No.43681194[source]
> The reason I believe C is and always will be important is that it stands in a class of its own as a mostly portable assembler language, offering similar levels of freedom.

When your computer is a PDP-11, otherwise it is a high level systems language like any other.

replies(7): >>43682173 #>>43682246 #>>43682554 #>>43682928 #>>43683332 #>>43683914 #>>43701871 #
pornel ◴[] No.43682173[source]
Less controversially, when you write C, you write for a virtual machine described by the C spec, not your actual hardware.

Your C optimizer is emulating that VM when performing symbolic execution, and the compiler backend is cross-compiling from it. It's an abstract hardware that doesn't have signed overflow, has a hidden extra bit for every byte of memory that says whether it's initialized or not, etc.

Assembly-level languages let you write your own calling conventions, arrange the stack how you want, and don't make padding bytes in structs cursed.

replies(2): >>43682625 #>>43682918 #
bmandale ◴[] No.43682918[source]
These are all such nonsensical misinterpretations of what people mean when they say C is "low level". You absolutely don't write C for the C abstract machine, because the C spec says nothing about performance, whereas performance is one of the primary reasons people write C.

The existence of undefined behaviour isn't proof that there is a C "virtual machine" that code is being run on. Undefined behaviour is a relaxation of requirements on the compiler. The C abstract machine doesn't not have signed overflow, rather it allows the compiler to do what it likes when signed overflow is encountered. This is originally a concession to portability, since the common saying is not that C is close to assembly, but rather that it is "portable" assembler. It is kept around because it benefits performance, which is again one of the primary reasons people write C.

replies(2): >>43682955 #>>43689019 #
pjmlp ◴[] No.43682955[source]
C performance exists thanks to UB, and the value optimising compilers extract out of it, during the 8 and 16 bit home computers days any average Assembly developer could write better code than C compiler were able to spit out.
replies(1): >>43683954 #
codr7 ◴[] No.43683954[source]
And also because it doesn't get in your way of doing exactly what you want to do.
replies(1): >>43684796 #
OCASMv2 ◴[] No.43684796[source]
If that was true then the optimizers wouldn't need to exist in the first place.
replies(1): >>43685475 #
codr7 ◴[] No.43685475[source]
Compared to the alternatives.

It gets very frustrating to communicate at this level.

replies(2): >>43686719 #>>43689366 #
OCASMv2 ◴[] No.43686719{3}[source]
I don't think compilers allowing trash through is a good thing.
replies(2): >>43699806 #>>43701396 #
greenavocado ◴[] No.43701396{4}[source]
Have you ever seen the error steamroller? https://github.com/mattdiamond/fuckitjs
replies(1): >>43702730 #
1. dwattttt ◴[] No.43702730{5}[source]
ON ERROR RESUME NEXT rears its ugly head again