This write-up captures what I teach when I get coaching requests. I won’t jump into the code or a setup of any sort. I will teach concepts.

If you work in a software development company as a non-programmer, you may wonder what the programmers do. And you hear new buzzwords everyday. This post was written with you in mind. Whether you are a sales person, a medical doctor, attorney, a business lead, or an accountant, if you’ve ever had it in mind to learn how to code, this is a good place to start.

How this article is organized

This write-up is divided into 4 parts. After reading through each part, you will find a quiz section to help you better recall what you’ve read. Then you’ll find a “going forward” section and answers to the quiz.

Note that each buzzword introduced in this series is in bold , such as algorithm.

Illustration by John Adesanya

Part 1 — What is Programming?

A simple answer would be, “Programming is the act of instructing computers to carry out tasks.” It is often referred to as coding, see: What is coding? 

So then, what is a computer program? A computer program is a sequence of instructions that the computer executes.

Computer in the definition above is any device that is capable of processing code. This could be smartphones, ATMs, the Raspberry Pi, Servers to name a few.

A Good Analogy for Programming

First, there are patterns to our every day lives. The universe operates in a somewhat predictable way; For example — day and night, seasons, sunrise and sunset. People go through routines such as rising in the morning, going to school or to work. We get instructions from other people such as our superiors at work. How we cook certain recipes can be explained in finite steps.

Second, every time we use smart devices, some code is running in the background. Moving a mouse pointer from one part of your computer screen to the other may seem like a simple task, but in reality, so many lines of code just ran. An act as simple as typing letters into Google Docs leads to lines of code being executed in the background. It’s all code everywhere.

Computer programs are also referred to as codeDo not use the word ‘codes’ (code should be used as an uncountable noun). Okay, this is not an English class, let’s get back to business.

The Natural Language of the Computer

Machines have their natural language like humans do. Computers do not understand the human language. The natural language of computers is the binary code — 1 and 0. These represent two states: on (1) and off (0).

That is the natural language of electronic equipment. It would be hectic for us as humans to communicate with the computer in binary.

Enter Programming Languages

To communicate with machines who speak binary, we do so in a language that’s closer to our own natural language. Such as English, French, Swahili or Arabic. Programming languages are close to our natural languages. But they are more structured and must be thoroughly learned.

They could be high level or low level languages. High level programming languages are farther away from the machine language than low level languages. This “farther away” is usually called an abstraction , but we will not go into that in this series. Let’s not get distracted :)

The computer needs a way to understand our human language. To do this, we’ll need a translator.

What are Translators

Source code refers to code written in a particular programming language. More of this in Part 2.

Translators have the responsibility of converting your source code to the machine language. This is also known as binary. Remember ones and zeros. We may refer to the binaries as Object Code , the Program or a common word today: App.

Translators can be any of:

  • Interpreters
  • Compilers
  • A hybrid of Interpreters and Compilers
  • Assemblers

Interpreters

Some languages are interpreted. The translator processes the source code line by line and runs every line in the final program or app. This means that interpreted source code starts running until it encounters an error. Then the interpreter stops to report such errors. More of this in detail in Part 3.

Python is a good example of an interpreted programming language.

Compilers

Compilers function differently. They convert the source code in its entirety via a compilation process to binary. The binary is then executed. If there were errors in the source code, they are detected during the compilation time and flagged. This interrupts the compilation process, and no binary is generated.

Interpreters translate line by line and execute the line before going on to the next line. Compilers translate all lines of a program to a file (binary) and execute the whole file.

Remember the definition of computer program? It’s a sequence of instructions that is executed by a computer.

An executing program is usually called a process. Such programs use certain resources on the computer system or smartphone such as memory, disk space and the file system. An executing program can also be said to be running.

We use the word ‘run’ when we execute a computer program. The time it takes to run such programs is known as the run-time of the program.

It is common to see programs referred to as Apps. We also associate programs with the platforms or environment in which they run, or are designed for. There are web apps, which run on web browsers, such as Google Spreadsheet. There are mobile apps, which run on smartphones such as CandyCrush. There are also desktop apps such as the Evernote desktop app.

Again, interpreted source code is executed directly from the source file. Compiled source code is converted to a binary file. The binary file is then executed. Compiled source code may fail during run-time even after successfully compiling. See Part 3.

Hybrid Translators

A hybrid translator is a combination of the Interpreter and Compiler. A popular hybrid programming language is Java. Java first compiles your source code to an intermediate format known as the Bytecode.

The Bytecode is then interpreted and executed by a runtime engine also known as a Virtual machine. This enables the hybrid translators to run the bytecode on various operating systems.

Assemblers

There’s the Assembler as well for translating low-level Assembly language to binary.

For this series, we will only focus on the High level languages.

A good way to look at Translators is to see them as a program in themselves. You need to download or get them, install them on your computer system and understand their basic workings.

An Often Asked Question

Here’s a question beginners usually ask.

What language do I learn first?

There are hundreds of programming languages. They are ranked by popularity, community, long term support, pedagogy, business use. They can also be ranked by technicality, such as whether they are functional, imperative, static, strong, or loosely typed.

Some languages are more pedagogical than others. Some languages are for educational purposes and not for business use. There are languages written, for example, for kids to learn how to code.

There are very powerful languages that are easy to setup and learn. Python is one such programming language. I usually recommend it to beginners.

If you are interested in exploring more on your options for “first language,” here’ssome good research by Philip Guo.

When you want to learn a new language, you know now that you would need that language translator. This is a program you install and setup on your computer system.

I recommend that you start learning how to use a CLI (Command Line Interface). The CLI is the terminal or shell. Think of the terminal as an alternative to a GUI (Graphical User Interface).

In GUIs, you interact with the computer through the mouse pointer. You also depend on visual renditions of directories, and about everything you do.

But, when using a CLI you interact with the computer using commands which you type at the prompt or a blinking cursor

$_

In Windows, the shipped-in terminal is the command prompt. For Mac and Linux users, you already have a default Bash terminal. 

Going Forward

Now that you’ve been mildly introduced to what programming is. You need to prepare yourself for your first line of code :)

To get started you will need the following:

  • A computer system
    At this point, you do not need a sophisticated or very expensive one, you only need a computer that works well.
  • Install the CLI
  • Install a text editor
    We will come back to this in Part 2
  • Learn a programming language
    In this series you will learn the basic elements that make up the fundamental knowledge of most programming languages.

Quiz

  • What basic tools do you need to start programming?
  • What command would you use for the following in bash (CLI)?
  • Check your current directory
  • Change to a directory named ‘bin’ (bin is in your current directory)
  • make a new directory called ‘lib’
  • create a new file called ‘book.py’
  • list all the contents the current directory

Summary

We have gone through the basics of programming, with an introduction to Translators. The word “source code” is no longer strange to you. We will examine what a source code is in detail in the next part.

Answers to the Quiz

What basic tools do you need to start programming?
A computer, a text editor, the shell(terminal), and a compiler/interpreter

What command would you use for the following in bash(CLI)?

  • Check your current directory: pwd
  • Change to a directory named ‘bin’ : cd bin
  • make a new directory called ‘lib’: mkdir lib
  • create a new file called ‘book.py’: touch book.py
  • list all the contents the current directory: ls
From Wikimedia Commons, the free media repository

Part 2 — Source Code

Now that you understand the concept of programming, we will examine source code.

A source code is basically a file, just like a Microsoft (.doc) file, but slightly different. It is a raw text file, written on very simple editors, like the Windows Notepad. You will recall from the previous section that you need either interpreters or compilers to convert your source code to binary. The source code must be saved in a file, which is passed as an input to the translator.

Depending on the language you are writing, there are designated extensions for saving your source code file. Python’s extension is ‘.py’. Java is ‘.java’. Php is ‘.php’ and PERL is ‘.pl’ to name a few.

When you are done writing your source code, you must run it through the translator. As an example, here’s how to run your Python source code using the pythoncommand.

Getting Started: Your First Program

  • Follow the instructions to setup Python on your computer system.
  • Install a simple editor to type in your source code. You can use sublime text editor for a start.
  • Open a new file on your editor, and type in the following:
print ‘Hello Python!’
  • Remember to save the file as main.py
  • Find the path to the file on your CLI, and type the command below:
$ python main.py

The result should look like this:

The Anatomy of a Typical Source Code

We will now examine the content of a typical source code file. Below are the regular components:

Keywords

Short, human readable words, usually known as keywords. They are peculiar to the language you are learning, and they are special. We’ll come back to this in a jiffy. You need to learn some of the keywords by heart.

Identifiers

Words invented by You — Yes You, the programmer. These words are generally referred to as Identifiers. They could be created by you or other programmers. They are packaged in form of plugins, better known as Libraries.

An example of a library is the Math library. It lets you access functions like the square root (Math.sqrt), used in Javascript.

Many programming languages ship with loads of libraries. These are generally referred to as their SDK s (Software Development Kits). You will download them together with the compiler to start building technologies, apps and projects. Besides these, there are frameworks , designed to help with building on a particular platform such as web or mobile.

Some identifiers are bundled with a language you’re using and may not be used as a user-named identifier. An example is the word string in java. Such identifiers, together with keywords are known as Reserved Words. They are not keywords, but like keywords, they are also special.

All keywords are reserved words, the inverse is not true.

The words you choose should be meaningful to whoever sees them at first glance.

A common use of identifiers is in naming variables , we will look into this in a bit.

Basic Data Types

You will also find data of different types in a source code, numbers (3, 5.7, -100, 3.142) and characters (M, A). In some programming languages, numbers are further broken down into their own types such as integers.

Integers can be Signed or Unsigned , big integers, and small integers. Big or small actually depends on the amount of memory space reserved for such numbers. There are numbers with decimal parts, usually called double and float , depending on the language you are learning.

We also have boolean data types which evaluate to true or false.

Complex Data Types

The data types explained above are known as the elementary, primary or basic data types. We can build more complex data types from these basic data types.

An Array is the simplest form of the complex data type. A String is an Array of characters. We cannot do without these complex data types and often use them when writing our source code.

A combination of characters is a string. To use an analogy, a string is to a computer what a word is to a human being. The word ‘Thermometer’ is made up of 11 characters — we simply call it a string of characters. String processing is a broad topic in itself to learn, and must be studied by every aspiring programmer.

Complex data types are shipped with most programming languages you use. There are others that we build ourselves as programmers, such as the Class systems. These are also known as ( OOP ) Object Oriented Programming.

Variables

Variables are simply named memory locations. We sometimes want to keep data in our source code in a place where we can recall the data, to use again. This is usually a memory location which our compiler/interpreter reserves for us. We need to name these memory locations to recall them later. Consider the Python code snippet below:

pet_name = 'Hippo'print pet_name

pet_name is an example of a variable. Because the type of data stored in pet_name is a string. It is known as a string variable. There are numeric variables as well. Variables are categorized by their data types.

Constants

Constants are values that do not change throughout the lifetime of the program. We use capital letters to enforce that some values are to be constant values. Some languages provide a way to create constant values, while others do not.

Some languages provide the luxury of declaring types that variables should be. We often call these strongly typed languages. Java is a good example.

Others do not provide these features. They are loosely typed or dynamic programming languages . Python is a good example.

Here’s how to declare constant values in JavaScript.

const petName = 'Hippo'

Literals

In every source code, there are data types you use everywhere around your code that will only change if you edit them yourself. We call these literals, which are not to be confused with variables or constants. Literals can be seen once you glance through the source code. They could be strings, numbers, decimals, or other data types.

In the source code snippet above, the word ‘Hippo’ is a literal — a string literal. It will always be ‘Hippo’ until you edit the source code. As you learn to code, you will learn how to manage literals in your source code in a way that is easy to maintain without changing much of your source code.

Punctuations/Symbols

In most source code, you will generally find different punctuation marks depending on the programming language. Java has more punctuation marks, for example than Python.

Common punctuation marks include the comma (,), semi-colon(;), colon(:), braces ({}), Brackets (()), square braces ([]), quotation marks (“ ”), pipe (|), slash (\), period (.), question mark (?), caret(^) and percentage (%).

Welcome to the world of coding, where punctuation marks are your best friends. You will find yourself typing them a lot.

Operators

The chances that you will write code to perform an operation is very high. In the slightest way, you will perform an assignment operation in your source code. We are presented with a large number of operators by the programming languages we use. Examples include addition(+), division(/) multiplication(*), subtraction(-) and greater than(>).

Operators can generally be classified as follows:

  • Assignment Operators
    This is sometimes misconstrued as equal-to. Equal to is used to compare two values. Assignment Operator puts a value in a variable, such as pet_name = 'Hippo'
  • Arithmetic Operators
    Comprises operators for carrying out arithmetic tasks such as addition, and subtraction. Some languages provide some arithmetic operators which others may not have. For example the modulus operator (%) returns the remainder value in division operations.
  • Relational Operators
    are used for comparing values. They include greater than, less than, equal-to, not-equal-to. Their representation varies as well depending on what programming language you are learning. <> is not equal-to in some languages, while in others, it’s != or !==.
  • Logical Operators
    are used to compute logical operations. The commonly used logical operators are and , or , not. Some languages represent these operators with symbols such as && for and , || for or , and ! for not. Logical Operation values usually evaluate to Boolean valuestrue or false.

Comments

Documentation will be an important aspect of your coding activities. It is how you explain your code to other programmers. This is done via comments that are occasionally added to parts of your code. Through comments, you can guide other programmers through what kind of data your code works with and the kind of output that it generates.

Usually, the compiler ignores lines of code that are comments.

Comments vary across languages. The #is used to introduce comments in Python.

Here’s an example of a comment in Python.

# program snippet to compute fibonacci of N numbers

In Java, C and C++ , there are comments for a single line just like the # in Python, but the // symbol is used instead. There are multi-line comments as well /* … */. You can read more about comments in the language that you have chosen to learn.