@PanGalactic,
Such as something that has to interface with hardware directly. You also can't write stand-alone executables in Python AFAIK. I don't know of an AOT compiler for Python. At the same time, Python doesn't need one.
Disch wrote: |
---|
Where did Python come from? I was talking about C vs. C++ |
When you said anything that can be written in one language can be written in another, I decided it meant we could discuss any obscure language I wanted.
The way I see it, most code written in C will compile in a C++ compiler... so why not just use a C++ compiler all the time in case you ever want something C++ specific? |
I'm not entirely sure about this, but doesn't C++ have constructors and destructors for primitive types like
int
s? If so, then that would mean you'd have to call a function just to create an integer.
Something as simple as
int i = 0;
in C, would usually compile to something like
mov i, 0
or
1 2
|
xor eax, eax
mov i, eax
|
if the compiler was any good
But in C++, if I'm right about primitives and constructors (I hope I'm not, though), that would probably compile to something like
1 2 3 4 5
|
mov eax, i
push eax
call int_constructor
pop eax
mov i, eax
|
In the first example, if the compiler was smart enough to optimize assigning 0 to a variable into a xor, that would produce two very quick instructions (otherwise the CPU has to pull 0 out of the data cache, work out the absolute memory location for i, and then put zero there) to make i 0. In the second example, the compiler had to push i onto the stack (in a very round-about way because I don't think
push i
or
pop i
would work), call the constructor, and then get the new value for i off of the stack.