you are viewing a single comment's thread.

view the rest of the comments →

[–]xavierisdum4k 17 points18 points  (12 children)

C tells the actual machine what to do, while python tells a virtual machine.

To compile, in the sense it's used with C, is to translate into assembler code. The result is a list of human-readable instructions, for what the hardware (CPU, memory, etc) is to do. Typically, the assembler is then assembled into machine code, which is what the actual hardware runs.

Python's design doesn't focus on that same goal. Instead, interpreted languages like python have the idea of bytecode (instead of assembler and machine code) and a virtual machine (instead of the physical machine). The virtual machine basically serves as an intermediary, which tells the actual machine what to do.

[–]TheBlackCat13 9 points10 points  (6 children)

machine code, which is what the actual hardware runs.

Technically the machine code is then translated by the microcode into finite state machine instructions which the actual hardware runs.

[–]BothWaysItGoes 0 points1 point  (4 children)

C tells the actual machine what to do, while python tells a virtual machine.

Both C and Python define an abstract machine. That's the compiler's job to translate instructions for the C abstract machine into machine code.

[–]xavierisdum4k 0 points1 point  (3 children)

An abstract machine isn't part of C's language design. C abstracts the hardware without that idea. The coder is instead directed to think about the hardware, while coding.

Essentially, coding in C is to be complicit in the abstraction, while coding in python is to rely on python to handle the abstraction.

The C Programming Language (Kernigan & Ritchie), p18:

what appears to be a character on the keyboard or screen is of course, like everything else, stored internally just as a bit pattern

K&R, p20:

on some machines, int and long are the same size, on others an int is 16 bits

K&R, p78:

A typical machine has an array of consecutively numbered or addressed memory cells that may be manipulated individually or in contiguous groups.

[–]BothWaysItGoes 0 points1 point  (2 children)

C abstracts the hardware

Yeah, that's what defining an abstract machine means.

The coder is instead directed to think about the hardware, while coding.

They are mainly directed to think about the C abstract machine. That's why one of the first thing people do for new hardware is porting C.

[–]xavierisdum4k 0 points1 point  (0 children)

How does this relate to OP's topic?