Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: A thought of C Date: Tue, 14 Apr 2026 21:46:02 -0700 Organization: None to speak of Lines: 91 Message-ID: <874ilcx245.fsf@example.invalid> References: <3a3462bdd72c4ed9d392a78b7d369a7b5ccc3b04.camel@gmail.com> <87jyu9tbq9.fsf@example.invalid> <722ff6ff518fe213dd47b392d325dd4cde27c71e.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 15 Apr 2026 04:46:04 +0000 (UTC) Injection-Info: dont-email.me; posting-host="1e0bef0e1ec57bd67eb672eeef0be697"; logging-data="691306"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EErdG6+NFtps1X5Q7XPKy" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:Ky0dIEAxQ/jHpH0YPec1WBllXX4= sha1:+dWyRdCFPpGv/8g/FNcoJqusCvQ= Xref: csiph.com comp.lang.c:397536 wij writes: > On Tue, 2026-04-14 at 15:31 -0700, Keith Thompson wrote: >> wij writes: >> > In attempting writting a simple language, I had a thought of what language is >> > to share. Because I saw many people are stuck in thinking C/C++ (or other >> > high level language) can be so abstract, unlimited 'high level' to mysteriously >> > solve various human description of idea. >> > >> > C and assembly are essentially the same, maybe better call it 'portable assembly'. >> >> No, C is not any kind of assembly.  Assembly language and C are >> fundamentally different. >> >> An assembly language program specifies a sequence of CPU instructions. > > [Repeat] 'Assembly' can also be like C: > // This is 'assembly' > def int=32bit; // Choose right bits for your platform, or leave it for > def char= 8bit; // compiler to decide. Compiler? You said this was assembly. > int a; > char b; > a=b; // allow auto promotion > > while(a a+=1; > } You've claimed that that's assembly language. What assembler? For what CPU? Is it even for a real assembler? > Yes, the C-like example above specifies exactly a sequence of CPU instructions > (well, small deviation is allowed, and assembly can also have function, macro) > >> A C program specifies run-time behavior.  (A compiler generates CPU >> instructions behind the scenes to implement that behavior.) > > Being 'portable', it should specify 'run-time behavior', no exact instructions. Yes, that's what I said. And that's the fundamental difference between assembly and C. >> > In C, we don't explicitly specify how wide the register/memory unit is, we use >> > char/int (short/long, signed/unsigned) to denote the basic unit. I.e. >> > >> >   a=b;   // equ. to "mov a,b" >> >> (Or "mov b,a" depending on the assembly syntax.) >> >> Nope.  `a=b` could translate to a lot of different instruction >> sequences.  Either or both of the operands could be registers.  There >> might or might not be different "mov" instructions for integers, pointers, >> floating-point values.  a and b could be large structs, and the >> assignment might be translated to a call to memcpy(), or to equivalent >> inline code. >> >> Or the assignment might not result in any code at all, if the compiler >> can prove that it has no side effects and the value of a is not used. >> >> [...] > > All mentioned could also be implemented in assembly. Sure, many C compilers can generate assembly code. But I question your claim that an assembler can plausibly generate a call to memcpy() for something that looks like a simple assignment. Many assemblers support macros, but the assembly language still specifies the sequence of CPU instructions. If you can cite a real-world "assembler" that behaves that way, there might be something to discuss. > Note that I am not saying C is assembly. You said that "C and assembly are essentially the same, maybe better call it 'portable assembly'." I disagree. I had a similar discussion here some time ago. As I recall, the other participant repeatedly claimed that sophisticated assemblers that don't generate specified sequences of CPU instructions are common, but never provided an example. (I haven't been able to track down the discussion.) -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */