Why are some programming languages ​​faster than others?

I know that ASM is basically the fastest you can get, but what makes HLL slower than ASM abstraction? What I mean by abstraction is that, for example, in C ++ you have a class, the data should be stored in what is stored in the class, what it comes from, private / public accessors, etc. When this code compiles, is there an actual assembly code that really works to figure out the class information? Just as CPython is built in C, there is even more abstraction and instructions to run at run time than C. Is any of what I'm telling the truth? I think I answered my question, but I would like to receive an answer from a more experienced person, besides me.

EDIT: I understand that Python is interpreted, but wouldn’t it be even slower than C if it were compiled?

+5
source share
4 answers

This is a broad question.

In essence, compiled languages ​​are translated into machine instructions (op codes) just like ASM (ASM is also an abstraction layer). A good compiler is likely to come out of the average result of an ASM encoder because it can examine a large patch of code and apply optimization rules that most programmers could not do manually (ordering instructions for optimal execution, etc.).

"". , . , , , . , , ( , , , ).

, , , , . , . , ( , ), , .

, ( P- ). , , ( - P- ). Java .

+5

, .

, .

, " ", , Java .Net, , , .

, , , . .

...

+2

, (, , ) , . C , . , Java, , . .

, . paulsm4, , , ( ).

+1

, , , . , , , .

. , , , - , .

, ( ), , , . , , .

, , , , , , .

In those cases when it comes to speed in this basement. If you write only code of a higher level, the speed of the compiled code is slow. The important thing is that your code calls subordinate procedures more than it really needs. The compiler cannot do this. Here is an example of how to fix this problem.

+1
source

All Articles