+ 3
How a language works
How does a computer know how to execute the commands just how it is,like why do we get an output with print statement only,and not with something like output.
1 Respuesta
+ 3
In the beginning, people would write machine code. A knowledge of the computer architecture was needed, and specific bit sequences correspond to an instruction. For example 00101101 - the first 4 bits are an instruction (e.g. save to register A) and the second 4 bits are the data. People then developed more human readable ways of doing this, e.g "save A" followed by your data would be broken down into the machine code.
Fast forward and keep applying this methodology and we have languages like we have today. Reserved keywords in the language are broken down to specific instructions. This is why you can't name a variable "for" or "int" (depending on the language) because the language expects that to be an instruction. It like storing your name using all 8 bits in the beginning, the first 4 are interpreted as an instruction, and ultimately that's how bugs and exploits might happen (e.g. look at the ways you can break the old Pokemon games by tricking it into using data to execute instructions)