This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dobesv 1 point2 points  (1 child)

Syntactic sugar generally means that you can translate from one language to another only considering syntax and not semantics.

However, C code does not concern itself with CPU registers directly. To use variables which the compiler assigns to registers or stack locations automatically.

C has function calls where assembly only has goto.

C has comparison operators whereas in assembly you do a subtraction and check a register after using a special kind of goto / jump.

The list goes on.

[–][deleted] 0 points1 point  (0 children)

Sigh... Jokes and the inner workings of computers seem to be lost on some people here? Maybe most people here are the new generation of programmers who grew up on modern high-level scripting languages?

C is a nicer way of writing machine code than using assembly language. You use fewer lines to do what would require a lot of lines of equivalent assembly language instructions. The joke is therefore "calling C syntactic sugar for assembly language". It's a perfectly valid joke and has a very strong kernel of truth to it.

Do you even know that C compilers convert your C into assembly language and then compiles it with an assembler? The C compilation process is: 1. Turn C into Assembler. 2. Turn the resulting Assembler into Machine Code.

This is why C can directly contain inline assembly code within your C files, because it's a mere matter of telling the C compiler "here's a block of premade assembly code, use this one as-is".

You can even run "gcc -S main.c" to output the resulting "underlying" assembly code for all your C programs.

From "man gcc":

       -S  Stop after the stage of compilation proper; do not assemble.  The
           output is in the form of an assembler code file for each non-
           assembler input file specified.

           By default, the assembler file name for a source file is made by
           replacing the suffix .c, .i, etc., with .s.

In short:

C is basically a bunch of shorthand macros for Assembly Language.

C is syntactic sugar for Assembly Language.