+ 1
How does computer interpret code written in any programming language? What parts are triggered inside computer ?
8 Answers
+ 6
Two hours later, I've nothing to do, so here's more informative answer (it uses all the characters available here):
There are so called "levels" of programming languages, more strictly — levels of abstraction. The higher the level, the farther the language is from the machine code. A computer can only execute it's machine code, which is a stream of ones and zeros.
There is also an assembly language — a readable representation for machine codes. For example, here's a machine code, that will output a '!' character to the screen in DOS: "101101000000001010110010001000011100110100100001", and here's the assembly: "mov ah, 0x02 \n mov dl, 0x21 \n int 0x21". The assembly language is "translated" to the machine code by the program called assembler.
An instruction in pure assembly language represents exact instruction of the computer. To abstract away from the machine, make code portable, and more readable, higher level languages have been created. Keywords and statements of high level languages have almost nothing to do with the machine code, but rather represent constructs, that are easy for humans to work with. A high level language is "translated" to the machine code, using a program called compiler.
The remainder of the question is about how the machine code gets executed by a computer. And this topic is very broad and deep. Broad, because there are a lot of computer architectures, and each one is quite complex. A datasheet for current Intel processor, that describes it's functions is two volumes 650 pages in total. And deep, because this topic covers few levels of abstraction in the computer architecture and few levels of electronics and circuit design. And that's not even touching the peripheral devices and data interpretation.
Here are few computer simulators you can play with (read the help), maybe it will help you understand the workflow inside a CPU:
https://peterhigginson.co.uk/LMC
http://www.peterhigginson.co.uk/RISC
https://schweigi.github.io/assembler-simulator
http://www.teach-sim.com
+ 4
Ehm... They taught me the answer for your question for 5 years in the university. And you want to get it in one comment?
Short answer will be kind of useless, bur here you go:
>> How does a computer interpret code written in any programming language?
- it uses a program, called interpreter, or compiler, or assembler. Depends on the type of the language. Sometimes, a virtual machine may be involved in the process.
>> What parts are triggered inside a computer?
- They are actually called triggers. They store one bit of information.
+ 3
Paul, your answer is completely wrong. The code is converted into unintelligible machine code. Assembly is a completely normal language.
+ 3
ugh, sorry, guess i still have to learn. thanks for pointing that out Private
+ 3
@Private [GER], Computer Engineering. Didn't work a single day in this field though.
+ 2
cpu only execute low level programing language, binary machine codes. so high level programing language make this "low" simple
+ 2
To expand on Marvin's answer: A good way to train Assembly is also SHENZHEN I/O.
+ 1
Oh, one question to you Marvin. What did you study? CS?