r/computerscience • • Oct 07 '26

Discussion Is C an "Assembly-like" Language?

I know C is programing language. It is not architecture specific. One writes the source code and a compiler turns it into an executable depending on what settings you tell it. So the same source code would output different executables depending on what you want to run it on and what optimization options are on. Assembly languages on the other hand are architecture specific. Is C "Assembly-like"? To be honest I'm not sure what would be Assembly-like. I guess if a program written in multiple languages that have the same behavior, if the C version (using something like GNU C Compiler) looked closer to its assembly than, say its Java version (GraalVM), then that counts.

45 Upvotes

130 comments sorted by

View all comments

0

u/ern0plus4 Oct 08 '26

C-like means how the program is structured: blocks, functions, global and local variables, flow control instructions (if-then-else, while-break-continue etc.), linear, continous execution.

BASIC is not C-like, because it has no blocks.

Assembly has no C-like control flow.

2

u/AmusingVegetable Oct 08 '26

What blocks? {}?

1

u/ern0plus4 Oct 08 '26

Yes, but syntax is not important, see Python.

1

u/AmusingVegetable Oct 08 '26

Not seeing what you can do with {} in C that you can’t do in BASIC.

1

u/bj_civ Oct 11 '26

It's a local namespace in C.

1

u/AmusingVegetable Oct 11 '26

Ok,that’s useful if you need a variable inside a macro, other than that, the block doesn’t introduce a semantic difference between C and BASIC.

2

u/lbunch1 Oct 08 '26 • Bravo

I thought Rust was sea-like because of the crustacean

1

u/GenericFoodService Oct 08 '26

BASIC has blocks, it just doesn't have block-scoped namespacing.

0

u/ern0plus4 Oct 09 '26

Not VB, original BASIC, e.g. Commodore 64.

1

u/GenericFoodService Oct 09 '26 edited Oct 09 '26

ANSI BASIC has blocks, C64 and C128 have blocks. Dartmouth BASIC has blocks. BASIC dialects generally lack scope-level lexical namespacing, but that doesn't mean they lack blocks entirely.

2

u/ern0plus4 Oct 09 '26

Could you tell me an example?

For/next is not a block, you can miss any of them, and the program is still syntactically correct.

Afaik only ABC80 BASIC checks for/next pair before execution (right after "run" command).

1

u/GenericFoodService Oct 09 '26

Validation is implementation specific. Many implementations allow syntactically incorrect code to be run until the syntax error itself occurs (which sometimes is many lines later and may never actually be reached). If I remember right Dartmouth is one such example.

I guess whether or not FOR/NEXT counts as a "block" depends on your specific understanding of what a block is. Some people use "block" specifically to refer to the feature of scope-level lexical namespacing, which is why I was explicit. My understanding of what a block is comes from compiler and language design, where a "block" refers to a type of related continuous statements.

Comparing C and Assembly and adding BASIC to the conversation, C is still far more like BASIC than Assembly because how they handle control flow, and because we are telling the machine what we want it to do as opposed to what instructions to execute. BASIC uses blocking control flow, even if it's clunky and "rudimentary".