how do computers know what to do with code?
i mean code is how what we see (the ui) is created and executed, the translator between graphics and hardware commands i guess, but whats between code and the computer? how does it know what it means?
- Shadow WolfLv 61 year agoFavorite Answer
There are different levels of "code". At the bottom is machine language which is the what the microprocessor understands. This is the most basic level of bits, bytes and words. The next level is assembly language which is also somewhat microrprocessor specific, but it is human readable and descriptive. This code gets turned directly into machine language. Next is languages like C which are sometimes called mid level languages. The programming language is more universal, but it is still capable of working directly with the hardware. Last is high level programming languages like Java, or Julia. They are interpreted or work through a virtual machine interface and don't generally work directly with the hardware.
What your programs look like when they run are also somewhat dependent on the operating system. Windows or Linux is an interface between your computer hardware and your programs. The programs give instructions like open a window to save a file and the file save window pops up. Each layer is built on top of layers and different interfaces are built on those layers. You can think of this like layers of an onion. At the center or core is the microprocessor and the associated hardware. On the outside is the user interface or operating system.
How things actually work aren't as clear as I just made it appear. For an example, C may be described as a mid level programming language, but it can do work as a high level programming language. In fact even assembly language could be used to build high level programs except it would be very time consuming and expensive.
In the end, it all eventually gets handled by the microprocessor whether it is indirectly like the Java virtual machine or more directly like a compiled C program.
- Andy TLv 71 year ago
OK, code compiles to binary code, that much you need to understand, either by compile or interpretation which is compiling on the fly if you got down to it.
Binaries got read in to be executed by CPU or FPLA, the microcodes is the magic, while FPLA is much simpler and if you really want to get to past that, study Intel 4004 and later Zilog and MOS Tech.
- StevenLv 41 year ago
As we know computer is a machine, so inventor have discovered some commands through it computer able to know what is the meaning of command?
- WhoLv 71 year ago
for me to give a meaningful answer to this question would take a LONG time (and several sheets of paper) - cos you would have to get down to the nitty-gritty of how processors actually work,(this is where the "code" comes in) then build from this to how a computer does what it does
(but to make it a little bit complicated - there is a level BELOW the level of the "code" . This is inbuilt into the circuitry of every processor (I mean the processor chip itself) and CANNOT be changed . THIS determines what steps the processor needs to do in response to EACH separate word of the "code" it receives)
but the easy bit is it doesnt "know" anything ,and it doesnt need to know what the code "means"
(you switch on a light - the light-bulb goes on
the bulb "knows" nothing about the switch or what you have done - all it it does is when a voltage is applied across its terminals if illuminates
(for a filament bulb - all the voltage does is make the filament get hot and therefore glow)
- How do you think about the answers? You can sign in to vote the answer.
- DIEGO.Lv 71 year ago
- Anonymous1 year ago
The code is compiled to binary. The binary values either turn switches on or off. So all that is happening is that the series of instructions turning switches on and off. Each instruction is doing something very simple but if you have lots of them it can do something complex.
A typical PC is nowadays 3.4GHz, that is 3,400,000,000 switches per second. It is that very high rate of switching which makes computer seem intelligent. You can even get multicore computers quite cheaply so multiply the above number of switches. e.g. a Quad Core PC will do 14,000,000,000 switches per second.
- ChrisLv 71 year ago
Your question doesn't really make sense unless you specify exactly what you mean by "computer".
A car doesn't "know" to accelerate when you step on the accelerator, it's just built this way.
Modern programming languages are built on layers of abstraction. If you want to see what happens inside the CPU, watch this: https://youtu.be/cxg-Vu9_mRM
And here somebody used Minecraft to build a scientific calculator:
- EddieJLv 71 year ago
Computer circuitry is designed to process machine code.
You could ask, "How does a light bulb know how to interpret it when you flick the light switch?"
I'm assuming you understand how that works. A computer is actually built of thousands of tiny switches.
The hardware is able to process 3 basic logic concepts, AND, OR, and NOT.
- Anonymous1 year ago
According to computer scientists, it apparently depends on luck. They have no idea how it actually works.