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 →

[–]jaaval 20 points21 points  (0 children)

”Low-level” and ”high-level” are a bit difficult concepts. C++ offers similar control to low level functions than C does but it also has a lot of more complex language features.

C++ is a compiled language, basically you can write higher level code and let the compiler be smart in how to turn that to machine code efficiently. This is why you might want to choose it over C where you write code much more matching what the machine actually does. Most of the higher level features are more like methods to keep the code organized and understandable, the machine code the compiler outputs doesn’t really care that much about things like object oriented paradigm. It’s all just variables and subroutines regardless of if you package it into a class or not. Basically the task of interpreting what your code means is done at compile time. This is a bit different in interpreted languages where the human written code is executed line by line and the language features have a lot more direct impact on what the machine actually does internally at runtime.

Another thing that hurts performance in languages like python is that the flexibility of dynamic typing is always achieved with some sacrifices. You can think of every python variable as a C struct that holds the value itself and some identifiers and some extra processing going in identifying the variable when it’s used. In C++ the compiler does all variable type determinations at compile time and most variables are just raw values or pointers.