Hacker News new | ask | show | jobs
by ncmncm 1640 days ago
C is the lowest-level language in common use, short of assembly language.

C lacks any high level abstractions. All the abstractions it does offer are hiding register and stack slot assignments (as local variables), code entry point addresses (as function names), ALU instructions (as operators), branching (as control-flow statements), and address arithmetic (as pointer operations). All of these are low, machine-level abstractions.

C was never a high-level language, even from its first day. It was specifically intended as a portable assembly language, by someone used to coding assembly language, to use porting an OS coded in assembly language to a new target host.

3 comments

> C lacks any high level abstractions. All the abstractions it does offer are [...]

By that standard, practically all languages lack high level abstractions. Garbage collection? Hides pointer chasing and marking of memory locations. Dynamic dispatch? Hides a pointer to a function table. Functional programming? Hides pointers to closures. Closures? Hide pointers to data and function pointers.

And structures, unions, pseudo-meta programming via the macro processors, no exposure to IO unless on a CPU with MMIO.

JOVIAL and Algol dialects were also designed for creating OSes and no one calls them low level.

> And structures, unions, pseudo-meta programming via the macro processors,

Those exists in macro assemblers, for they are extremely thin abstractions, no thicker than jumping to a label instead of jumping to an absolute or relative address.

> no exposure to IO unless on a CPU with MMIO.

Well, since not all processors have I/O instructions (or dedicated I/O pins), the easiest way to implement portability is simply to not provide a direct access to them in the language, and let library functions handle it.

> Those exists in macro assemblers, for they are extremely thin abstractions, no thicker than jumping to a label instead of jumping to an absolute or relative address.

They’re much more than that because of type aliasing, which is what lets you write -> . = operations all day without each one literally being a memory access in asm.

Which kind of proves the point C doesn't provide all the necessary capabilities for a systems programming language.

As for macro Assemblers, IBM i one supports OOP constructs, so are OOP languages now low level?

Also functions, loops, conditional statements, and arrays are considered abstractions.
>C lacks any high level abstractions

macros