• Question: How do you get computers to understand code?

    Asked by best1hake on 3 Jul 2024.
    • Photo: Amin Kassab-Bachi

      Amin Kassab-Bachi answered on 3 Jul 2024:


      Most coding software (may also be called an interpreter or an Integrated Development Environment (IDE) depending on its features), have an integrated piece of software called a compiler.
      The compiler reads the instructions (commands) you write into your code and translates them into what’s known as the machine language, which the computer can read and execute. The format of these instructions depends on what programming language you’re using. That’s why a programming language is called a language, because as a human language, it has syntax and rules that make it make sense. That’s why you need a specific compiler to act as a translator for your code.

    • Photo: Sheridan Williams

      Sheridan Williams answered on 3 Jul 2024:


      High-levellanguages need to be broken down (compiled) into indivdual instructions. At the fundamental level these instructions are in binary, so 1100001110101000 might mean add something to the accumulator.
      The CPU has built into its instruction set a number of thes binary codes. The decode part of the ‘fetch-decode-execute’ cycle determines what process is to be performed.

    • Photo: Andrew Parrott

      Andrew Parrott answered on 3 Jul 2024:


      As Amin suggests most coding languages work by a some point converting what the human inputs into machine code. The machine code tells the computer (processor usually) what to do. The computer is holding everything as binary representations (bits) and the machine code tells the computer what to do with the bits (i.e. move them, invert them, add them, etc.). The outcome is then fed back to the interpreter which then converts this back to something a human can more easily understand. One of the best explanations I have read for this is given in the book by Charles Petzold called “code”.

      Another answer is involving large language models and an AI “understanding” of the code. It can tell what the code is trying to achieve and convert it into other code (language) if required (e.g. convert Python in VBA). Or take human input and covert to code (e.g. I want to code that takes two numbers and finds a common factor it might be able to work out what code i need in a certain language). So that is another sort of “understanding”. ChatGPT and others like it do this sort of thing. In the background though at some point some conversion to machine code is required so the code that runs the AI can run on some computer hardware.

    • Photo: Luke Humphrey

      Luke Humphrey answered on 3 Jul 2024: last edited 3 Jul 2024 11:31 am


      Excellent question. See this webcomic: https://xkcd.com/378/

      (And here’s the explanation: https://explainxkcd.com/378/)

    • Photo: Amber Villegas - Williamson

      Amber Villegas - Williamson answered on 3 Jul 2024:


      As Sheridan has explained we store information as either a 1 or a 0.
      The way we tell computers what we are soring is the part of programming to make life / communication easier.

      As an example
      01001000 01100101 01101100 01101100 01101111 00100001

      doesn’t mean much right now but it is stored on a device somewhere and we need to work out way it means…. so we need to decode it

      Write Your Name In Binary Code

      On the weblink there is a conversion chart which tells you what 01001000 converts to…(H)

      so now if you look at the conversion you will see that
      01001000 01100101 01101100 01101100 01101111 00100001

      Simply means “HELLO”

      Well that’s a lot of 0 and 1 and it can be easy to get confused and whilst letters are great we need machines and systems to do more complex things so coding is basically a way of giving really long instructions in a simple form.

      If we told a dog to “fetch” we are using a simple command to ask them to “go pick up the ball and bring it to me” but fetch is simple and is decoded into the complete action by the dog.

      Hope this helps 🙂

    • Photo: Neil Barnby

      Neil Barnby answered on 4 Jul 2024:


      You have some very good answers here but I will add that computers don’t ‘understand’ code, they only read it and follow the instructions.

Comments