promotion image of download ymail app
Promoted
Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 1 year ago

how do computers know what to do with code?

Update:

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?

9 Answers

Relevance
  • 1 year ago
    Favourite 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.

    • Commenter avatarLog in to reply to the answers
  • Andy T
    Lv 7
    1 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.

    • Commenter avatarLog in to reply to the answers
  • Steven
    Lv 4
    1 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?

    Attachment image
    • Commenter avatarLog in to reply to the answers
  • Who
    Lv 7
    1 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)

    • Commenter avatarLog in to reply to the answers
  • What do you think of the answers? You can sign in to give your opinion on the answer.
  • DIEGO.
    Lv 7
    1 year ago

    good question.

    • Commenter avatarLog in to reply to the answers
  • Anonymous
    1 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.

    • Commenter avatarLog in to reply to the answers
  • Chris
    Lv 7
    1 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.

    And a browser is built to parse HTML and interpret JavaScript.

    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

    Youtube thumbnail

    ?list=PL5dr1EHvfwpNmDCslZRX82pP2XAQHzUzr&t=584

    And here somebody used Minecraft to build a scientific calculator:

    https://www.youtube.com/watch?v=wgJfVRhotlQ

    Youtube thumbnail

    • Commenter avatarLog in to reply to the answers
  • EddieJ
    Lv 7
    1 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.

    • Commenter avatarLog in to reply to the answers
  • Anonymous
    1 year ago

    According to computer scientists, it apparently depends on luck. They have no idea how it actually works.

    • Commenter avatarLog in to reply to the answers
Still have questions? Get answers by asking now.