hepisec

Posted on

# Programming for bloody Beginners

I made my first steps in coding about 20 years ago. I can remember that I’ve created websites using WYSIWYG editors (What you see is what you get - graphical web page builders) and had a few books on certain programming topics (HTML, Perl, later PHP, Java, MySQL and so on).

Now, tens of thousands of lines of code, months of debugging and countless hours of programming later, I have the opportunity to teach an apprentice in software development. Before the apprenticeship will start in August, he took a one week internship with me to find out whether programming is the right choice for his future work life. He had no prior knowledge and watching him writing code showed me some essential lessons, which are missing in most coding tutorials.

These missing lessons will be discussed in this post.

# Lesson 1:

## What’s the purpose of a programming language?

With a programming language you can tell a computer what he has to do. Usually you have a certain problem. It doesn’t matter whether its a mathematical problem or a real life problem like remembering your grocery list. Using a programming language you can solve this problem using the seemingly unlimited computing power which is available today. As there are many very different problems in the world which want to get solved, there are also many different programming languages which may be more or less suitable to solve a certain problem. But there are a few basic elements which are part of almost any programming language.

# Lesson 2:

## How does a programming language work?

Most programming languages provide the following basic elements, which are used to write a program.

### 1. a statement

A statement is an instruction which is executed by the computer. E.g. it could be „print a line of text“ or „calculate 1+1 and assign the result to a variable“ (see below).

### 2. a variable

A variable is a named storage for data which is used within the program. Each variable holds a value in the computers memory.

### 3. a data type

The values which are stored in variables usually have a certain data type. Some basic data types are integers, floating point numbers, strings (think of it as a sequence of alphabetic characters if you have never heard of the term strings before) and booleans (true or false).

### 4. an operator

An operator is a special symbol of the programming language with a certain meaning. There are different kind of operators: assignment operators (e.g. to assign values to variables), comparison operators (e.g. to compare the values of two variables), increment and decrement operators and maybe more.

### 5. control structures

The most programs require some control structures to implement the business logic. These can be branching structures to tell the computer to run different code dependent on certain conditions (if … then … else …) or loops to let the computer repeat certain parts of the code.

### 6. input

A typical program requires some input to compute the result which is based on the input. The input can be data, which is entered by the user or data which is obtained from other programs or storage.

### 7. output

To let the user or other programs know the result of a computation, a program requires an output mechanism. The output can be a display, a kind of storage or the input of another program.

### 8. functions, methods, procedures

These terms usually mean very similar things. For this explanation I will use the term function. A function is a reusable part of code which may consist of all the other elements mentioned above. Functions are used to divide complex problems in many smaller problems. Each small problem is solved within its own function and the complex problem is solved by combining the functions for the smaller problems. Functions can have an input, typically called parameters, and an output, typically called return values.

# Lesson 3:

This is where a typical programming tutorial starts. We have examples of the basic elements from lesson 2 in a programming language specific syntax. The language syntax defines how each of the elements from lesson 2 has to be written so that the computer can understand the code.

Now that you’ve read about the missing lessons, pick the beginner tutorial for the language of your choice and continue with lesson 3 on your own. I hope my lessons have improved your understanding of what’s going on.

# Happy coding!

I appreciate any comments which can improve the lessons and help others to get more easily into programming.