Dark theme

How do programming languages work?

[ << ]

Instead of writing in binary code, we write in computer languages that we understand better and the computer changes them into ones and zeros for us ( it "compiles" ) them.

Different types of computer (Personal Computers ("PCs"); Macs; iPads; etc.) need different ones and zeros, so one other helpful thing computer languages give us is a way of writing that (usually) works on any computer. The computer just takes what we write and changes it to the right ones and zeros it needs.

There are lots of languages, but most of them work in the same kind of way. Most of them need you to type things for the computer to do, not drag them around. Otherwise they are like Scratch.

Here's some examples of Hello World. Most languages call writing to the screen "printing" because old computers had no screens and used to print everything on paper. Note that the computer does all the hard stuff, like telling the screen to light up in the place it needs to show the words. We just say what we want to happen. This is the other thing languages do – they hide loads of code inside short commands.

Python:
      print ("Hello World")

Lua:
      print ("Hello World!")

Ruby:
      puts 'Hello world'

Javascript:
      <SCRIPT>alert("Hello World");</SCRIPT>

Java:
      class Printer {
         public static void main (String args[]) {
            System.out.println("Hello World");
         }
      }

So, given there are hundreds of different languages, how do we pick one to learn, and why are there so many?