The Basic Elements of Structured Programming

Overview

Programming is a complex exercise of giving instructions to a computing machine for it to execute. The computer is an electrical machine that is made up of a lot of transistors that are little switches with positions of either on or off. On is represented by the number 1 and Off by the number 0. This therefore means that a unit of data in a computer (one byte) is a combination of eight (8) switches that are on and off. The central processing unit (CPU) and random access memory (RAM) read all data in binary then interpret and execute the instruction if possible.

This site is intended to help you to understand the critical programming topics necessary to be Turing complete i.e. knowing how to solve many programming concepts. These concepts will focus on variables and data, decision structures, looping structures, and functions. If you can handle these concepts, you are ready for the next step in programming.

Language

Languages are tools of coommunication. Language allows people to speak and pass instructions or queries to each other. The computer also has a language defined in binary code. As you will see throughout this site, programming languages are developed to give humans the opportunity to pass instructions on to the computer for execution. Languages require unambiguity in syntax. Many researchers have devoted hours to the understand of how to parse code and create Turing machines that allow programming languages to be created. Each developer will make the case that their language is the most fun to work with. However, any programmer has to spend time learning the syntax of the language. The algorithms of problem solution will translate to whatever language. This to say that once you know what the programming solution is, the language is a matter of preference rather than necessity.

IDEs

IDE stands for Integrated Development Environment. Every program needs code to be written. The code can be written in a few applications such as Notepad for Windows or TextEdit for Mac. The developer then has to make sure that the proper tools of the programming language are installed and would use command prompts (or Terminal for Mac) in order to run the program. The IDE is an all-in-one place for programmers to code, edit, and run their program solutions. All IDEs provide an editor window, a compile function, and an output window. The IDE chosen will depend on the language choosen. Eclipse is great for Java, but can also be used for C++ and PHP. Microsoft Visual Studio is very common for programming in languages such as C++, C#, and even some work in SQL. JetBrains has a huge repository of programming IDEs tailored to whatever language a programmer can desire. The website Repl.it is a great website that allow programmer to program in just about any programming language without the the stress of downloading the software to the machine.

Low-level Programming Langauges

Assembly Language

Since we are not generally good at holding sequences of 1s and 0s (machine code) in our heads, programming languages were created to allow us to think of programming one instruction at at time. Assembly language was created in 1949 to allow programmers to provide line by line instructions to the computer. Each instruction is known as a mnemonic and typically includes an action statement as well as the registers that will be impacted by the action. E.g. mov eax, 5;

Programming languages give programmers the ability to access memory locations. Typically, the memory locations are in RAM. However, assembly language provides complete access to the computer system. Registers are fast access memory located directly in the CPU. These locations are smaller than RAM and assist the CPU in accessing information for instruction execution since the CPU is the fastest operating component in a computer.

Assembly language is referred to as a low-level programming language because the code is designed for the machine (or at least the processor) that is intended to run the program. Writing code of an intel machine is slightly different from writing for an AMD or a mobile processor. These make Assembly language programs not very portable and unable to be executed on various types of machine without writing specific code for each machine.

Additionally, Assembly language is a tedious programming language that requires uses to consider a single exection step at a time. This means that a simple addition is not simple. E.g

In order to execute x = 5 + 7, the code could look like this:
mov eax, 5;
mov ebx, 7;
add eax, ebx;

An assembler is required to interpret the code and translate the correct code to machine language inorder to be executed. While there is much use for assembly language programming, not many programmers are first introduced to this low-level programming language.

High-level Programming Langauges

Why the term high-level?

In the coding example in the Assembly language statement, the simple goal was to just add 5 and 7. We have developed a practical mind as it concerns arithmetic that does not consider storage of date. For this example were trying to do an addition where we could get the result of a + b outputted. Assembly language becomes tedious because all actions have to be phrased in terms of a single instruction. Most programmers usually think in terms of expressions. We want to divide something, then add something, then multiply something, then print something. Algorithms (step-by-step instructions for a programming solution) are derived using expressions. There is additional work to devise algorithms for assembly language. High-level programming languages allow programs to be written based on expressions as opposed to instructional statements in order to solve the desired programming problem.

What high-level languages allow

Use of variables

High level languages incorporate the use of variable as the foundation of data manipulation and interactivity. Variables (as is the case in algebra) represent a placeholder. The use of variables are intended to show that a value is determiined through a relationship. This means that for the example earlier, x is based on the relationship of 5 and 7 (addition). The variable x is unknown but will be determined through execution.

Each programming laanguage differs in how variables are viewed and introduced to the code. Some programming languages allow the programmer to create a variable name and begin programming. Other programming languages require the programmer to specify the data type (the kind of values the programmer intends to hold in the variable) and name prior to using the variable in any expression.

Use of expressions

High-level programming languages are designed to allow programmers to create instruction in an expression-based format while following the rules associated with the programming language that is being used. High-level languages incorporate assignment statement (=), arithmetic operators (+. -, *, /, and %) for all arithmetic expressions. Relational operators (e.g. >, >=, <, <=, ==, !=) along with logical operator counterparts are used in the creation of decision-based expressions.

All programming languages have rules about variable creation and expression usage in programming. The programmer must learn about the rules of the programming language and adhere to them strictly.

Programming Languages

Interpreted vs Compiled

High-level programming languages are either compiled languages or interpreted languages. Both are focused on what is necessary for the programming languages mediator between source code and operating system to begn executing the written code.

Source Code
Source code is simply the organized set of instructions written by a programmer that is intended to be executed.
Compiled Languge
A compiled language is one that requires the source code to be complete and the code to be free of any syntax errors. The entire source code will be translated to machine language and executed if the programming environment is free of issues.
Interpreted langauges
Interpreted languages do not require the source code to be complete in order for execution to take place. The interpretter will read each line of code and execute the line. If the code is incomplete, the programmer (or end user) will see an undesireable result in the output.

Compiled languages typically run faster than interpreted languages however, the cost of compiled languages is the size of the application, time spent parsing the source code to machine language, and less portability than interpreted languages. Interpreted languages require less application storage and allows programmers to not have completed code that is still executable.

Short list of programming languages

Language Year first developed Generation Compiled or Interpreted
* - This is not an exhaustive list
Machine Language cannot be verified 1GL Neither
Assembly Language 1949 2GL Neither
FORTRAN 1957 3GL Compiled
Lisp 1958 3GL Compiled
Pascal 1970 3GL Compiled
C 1972 3GL Compiled
SQL 1978 4GL Interpreted
C++ 1980 3GL Compiled
Python 1990 4GL Interpreted
Visual Basic 1991 3GL Compiled
R 1993 4GL Interpreted
Java 1995 3GL Interpreted
Javascript 1995 3GL Interpreted
PHP 1995 4GL Both
C# 2001 3GL Both
Swift 2014 3GL Compiled