logoalt Hacker News

usrnmtoday at 8:27 AM4 repliesview on HN

The famous C dilemma: we want to be as close to the machine as possible, but don't want to change anything when the machine changes


Replies

pjmlptoday at 9:37 AM

Because contrary to urban myths, C is a normal high level language like everything else.

The Assembly like abilities have been growing as language extensions in specific compilers, not as part of ISO C.

Going back to K&R C, inline Assembly or intrisics were not even available, all of that required using the Assembler directly.

show 3 replies
flohofwoetoday at 11:31 AM

It really hasn't much to do with C (e.g. there is no such thing as a "C ABI", and especially no such thing as a "standardized C ABI" - not sure if that's even a hot-take anymore).

ABIs are defined by CPU and operating system vendors. Those ABIs usually happen to be quite 'C friendly', but that's not a requirement (for instance the AmigaOS ABI was primarily meant to be used from handwritten assembly code, and Amiga C compilers had to adapt to those ABI rules or they wouldn't be able to call into the operating system DLLs).

show 1 reply
wren6991today at 9:50 AM

Except for the basic integer types. Change those as much as possible. Hell, CHAR_BIT=12 just to keep them on their toes.

Personal pet theory: C is portable as in "you can retarget the compiler to any machine" moreso than "your code will run on any machine".

show 1 reply
tonyhart7today at 9:11 AM

so what they gonna do ??