Computer code is very important. Almost every electronic device you use relies on code. The way things work can seem quite confusing, but when you break it down it's actually simple.

People who make code are called programmers, coders or developers. They all work with computers to create websites, apps, and even games! Today you'll learn what code it, what it's for, and how to start learning code yourself.

What Is Code?

Machine Code Example

Computers have their own language called Machine Code which tells them what to do. As you can see, it doesn't make a lot of sense to humans!

Each number or letter is telling the computer to change something in its memory. This could be a number or word, or a little part of a picture or video. By themselves, computers don't know how to do anything. It is the job of the programmer to give them instructions.

It's possible to learn Machine Code, but it would take a long time! Luckily there is an easier way to communicate with computers.

What Is a Programming Language?

Hello World in Python

Now, this looks a little easier to understand! This picture shows how to tell the computer to say Hello, world. Programming languages provide an interface between coders or programmers and machine language. So instead of using machine code, the image above uses a programming language called Python.

Almost all programming languages work the same way:

  1. You write code to tell it what to do: print("Hello, world").
  2. The code is compiled, which turns it into machine code the computer can understand.
  3. The computer executes the code, and writes Hello, world back to us.

Related: How to Get Started With Python Using a "Hello World" Script

There are hundreds of different programming languages which can seem confusing, but they all do the same thing. You type in what you want it to do, the compiler turns it into language the computer understands, then the computer does it, which is called executing the code in programming speak!

What Is Coding?

Sometimes Code is Easy to understand

Coding is the process of using a programming language to get a computer to behave how you want it to. In Python, every line of code tells the computer to do something, and a document full of lines of code is called a script.

Each script is designed to carry out a job. This job might be to take an image and change its size. It might play a certain sound or piece of music. When you click "like" on someone's post on social media, a script is what makes it happen.

Unlike people, computers will do exactly what you tell them to. This might sound great, but it can cause problems. If you tell a computer to start counting upwards, and don't tell it to stop, it'll keep counting forever! Being a good programmer is all about knowing how to tell a computer to act.

What Is a Program?

Programs are the building blocks of computers as they’re responsible for every operation that a computer performs. It's the set of instructions that are created during the programming process of software development. Without programs computers are useless.

Programs create software that an average user can recognize as a website or an application. When a program goes through the process of testing and debugging, it then becomes available to a user in the form of packaged software that can easily be installed on a device.

Is Coding Hard?

book on a desk in library

Coding can be very simple, and anyone can learn the basics. A good analogy is to think of coding like books in a library. Some books use simple language, and the stories are easy to understand. Others use very complex words and have stories that seem to make no sense. Whether they are simple or hard to read, they are all books.

The more books you read, the better you get at it. The complicated language or confusing stories get easier to understand until one day you can read things that you wouldn't even dream of in the past!

Learning to code is the same. The first time you try to code you will find it hard, but every time you do it you get better. If you find learning a programming language hard, you can still learn the important ideas behind it using a visual coding language. You can even make your own Mario game without typing any code at all!

What Does Code Look Like

Sample Python program

The image above shows a script called hello_name. You've already seen that a single line of code can make the computer print to the screen. Let's say that instead of just saying hello world, you want the user to type in their name, and for the computer to greet them by name? Let's break down what is happening here.

  1. When the script starts the computer prints a question to the screen.
  2. Next the computer waits for the user to input their name, and saves it.
  3. "Hello" prints to the screen, along with the saved name.
  4. In the Cmder window, the script compiles and executes using Python.
  5. The script ran just the way it was designed to, before exiting.

This example shows you a simple piece of code written in a code editor, and run in Cmder which is a type of terminal window. Don't worry too much about what either of these things is for now. You now know what Python code looks like and how this script works.

How Code Becomes a Program

Turning a Script into a Program

If you are totally new to code, you might still wonder how scripts like the one above become the kind of programs you are used to using. In the image above, the window on the left is a tool to turn Python scripts into programs. The window on the right has an icon called hello_name.exe. I think you can guess what happens if you were to click on it!

Gif of the working .EXE file

From no code to a finished program. This example is really simple, but this is how almost all coding works. Every day, people use programming languages they have learned, to write code, which will become programs we all use.

Coding Is Cool

From this article, you've developed a fundamental understanding of programming, as well as practical exposure to this discipline through the python examples. Coding is for everyone, regardless of age or background.

Python is a good place to start your coding journey as it's one of the leading programming languages in the world. However, exploring other programming languages and even other aspects of coding is always an option.