News for hackers. Stuff that matters.
Re:C Isn't a Language by Nevermark on Friday February 06, 2026 @02:24AM (#46910063)
> the concepts of pointers, variable sizes and memory layout of structs all represent the machine at some level.

Exactly.

Everything in assembly is still one-to-one in terms of functional/stateful behavior to actual execution. Runtime hardware optimization (pinhole instruction decomposition and reordering, speculative branching, automated caching, etc.) give a performance boost but do not change the model. Doing so would mean it didn't work!

And C is still very close to the assembly, in terms of basic operations. Even if a compiler is able to map the same C operations to different instructions (i.e. regular, SIMD, etc.)

Re:C Isn't a Language by pjmlp on Friday February 06, 2026 @03:50AM (#46910538)
Lets play a game of what ISO C can do, and no other systems programming language has similar feature available?

If language extensions to ISO C are allowed, then same goes for my selection on competing systems languages.

Re:C Isn't a Language by Nevermark on Friday February 06, 2026 @06:26AM (#46911587)
Yes, most languages allow C type code, if that’s what you are trying to do.

Java with only primitive values, arrays, and classes only with fields and static methods.

But that wouldn’t be idiomatic Java, so typically non-explicit abstractions such as polymorphism have code generated for them that you don’t have explicit control over.

C is consistently low level because that’s all you get. Down to direct access to addressing and RAM, the stack frame, etc. as with assembly.

Re:C Isn't a Language by pjmlp on Friday February 06, 2026 @08:06AM (#46912370)
How do you do direct accessing to CPU registers in C as with Assembly?

Being idiomatic or not doesn't matter, what counts are what language features are available.

Re:C Isn't a Language by Nevermark on Friday February 06, 2026 @11:56AM (#46915228)
I am puzzled by the claim that C and assembly are not close for the vast majority of C code.

For systems programming and complete performance control, C makes it easy to drop into assembly, but that is a small fraction of C code.

The vast majority of C code is very close to assembly, in part as its data types emphasize types handled natively, compound types reflect RAM layout, and pointers are essentially naked (type sizes being helpful for allocation and indexing, but not a hindrance to alternate access or stores).

And in part because C doesn’t offer abstractions that other languages have. So it is more “strictly” low level than languages with more abstractions built-in.

Taking advantage of many language-level abstractions in other languages results in a lot of assembly that isn’t reflected closely in the source.

C also lacks source overhead that isn’t a requirement of assembly. For instance, Java’s strong class-centric bent, isn’t an assembly inspired choice, but a programming abstraction, organization choice. Likewise, Lisps S-exp model is a strong choice not arrived at from assembly code (for non-Lisp machines).

The one non-assembly adjacent feature is type as a restriction on code composition, which is very far from assembly. But it doesn’t impact generated code, can be bypassed any time, do is a zero implantation abstraction.

It is often easy to add abstractions, via regular C, or macros, but you have to provide an explicit implementation for them in the source or complied library.

(However, if macros are viewed as C source instead of as a C source construction language, then C becomes a very wacky language with behavior and rules that look nothing like simple assembly instructions.)

Re:C Isn't a Language by jenadine on Friday February 06, 2026 @06:01PM (#46919371)
> I am puzzled by the claim that C and assembly are not relatively close.

Did anyone say that? I think the point is not that it is not "close", but that C is not equivalent to ASM: C has its own abstractions, and there are things you can do on assembly that you can't express in C.

The other low level languages such as C++, Rust, Zig, ... are equally close since you can express the same things. In some respect they are even closer since they got more features builtins that modern assembly can now do that was not part of the design in C. (SIMD, threading, ...)

Modern languages also have extra abstractions that makes programming easier without compromising on the cost. There are more abstractions than in C, but they also are optional. (Just like you could use goto instead of while or for loop, but you're happy this abstractions exist. We could also use functions pointer in C++ instead of virtual functions, but why would we if the language provide tools that make programming easier, for the same result)

Re:C Isn't a Language by Nevermark on Saturday February 07, 2026 @01:36AM (#46921819)
As I noted, closeness has several meanings.

> The other low level languages such as C++, Rust, Zig, ... are equally close since you can express the same things.

C is not just low level friendly, but low level out of the box. That is the level that all C must be written in, even when creating higher abstractions.

Some higher level languages are also low level friendly, not low level strict. Which is a kind dual.

I would argue that what makes C lower level, is that it comes in at, or under, the low levels of other languages, and its high bar comes in much lower than the abstractions built into other languages.

Forth is a good candidate for being even lower level.

But if someone else doesn't see things that way, that is fine. It is just one lens for comparing languages.

Re:C Isn't a Language by jenadine on Saturday February 07, 2026 @02:38AM (#46922058)
> C is not just low level friendly, but low level out of the box. That is the level that all C must be written in

No, it is not:

- People use for/while loop, for example, instead of the "low level" 'goto'

- C compiler compute pointer aliasing, assume operations don't overflow, etc., in order to optimise your code: What you write doesn't translate directly to assembly.

- Some low level operations cannot even be represented in pure C (without using __asm__ extension escape hatch)

Re:C Isn't a Language by kazinator on Friday February 06, 2026 @11:16PM (#46921252)
There is no "C's convenient inline assembly": that is a vendor extension, if available, and its convenience could vary considerably.

The manipulation of memory by C programs is close semantically to the manipulation of memory by assembly programs. Memory accessed through pointers is similarly "external" to both assembly language and C programs.

The evaluation of C program code is not close to assembly language. C programs cannot reflect on themselves portably; features like parameter passing, returning, and allocating local storage during procedure activation, are not in the programming model.

C loses access to detailed machine state. Errors that machine language can catch, like overflows, division by zero and whatnot, are "undefined behavior". An assembly language program can easily add two integers together and then two more integers which include the carry out from the previous addition. Not so in C.

Assembly language instruction set designs (with some exceptions) tend to bend over backwards to preserve the functioning of existing binary programs, by maintaining the illusion that instructions are executed in sequence as if there were no pipelining or speculative execution, or register renaming, etc.

Meanwhile, C compiler vendors bend over backwards to prove that code you wrote 17 years ago was wrong and make it fail. C is full of unspecified evaluation orders and various kinds of undefined behavior in just the basic evaluation model of its syntactic, built-in constructs; and then some more in the use of libraries.

In assembly language, you would never have doubt about the order of evaluation of arguments for a procedure.

Even when it comes to memory, where C and asasembly language agree in many points, there are some subtle ways C can screw you. In assembly language, you would never wonder whether copying a structure from one memory location to another included the alignment padding bits. In C you also don't have to wonder, if you use memcpy. Oh, but if you use memset to clear some memory which you don't touch afterward and which goes out of scope, the compiler can optimize that away, oops!

Re:C Isn't a Language by rramadass on Saturday February 07, 2026 @08:20PM (#46930355)
You keep making these sorts of comments on various threads which tells me that perhaps you are not clear on the idea of an "Abstract machine" which underpins all high-level languages.

See my comment here for some references - https://news.ycombinator.com/item?id=46930253

The gap between the "C Abstract Machine" and the actual Hardware underneath is smaller than most other high-level languages. This comment by user haberman puts it very nicely - https://news.ycombinator.com/item?id=46910015