Inroduction to Programming

Software development

It is important to understand some common terminologies that are used in programming:
  • Programs – set of written instructions that humans give to computers to perform a task and produce a result. In other words, it is the solution developed by software engineers and written in a form that can be executed by the computer.
  • Programmers - people who write instructions for the computer to solve problems.
  • Programming Languages - special languages used by programmers to write instructions for the computer. E.g. C++, Java, Python, C# etc.
  • Software engineer - designs an appropriate solution to a user’s problem by using software development procedures. They meet the client to understand their requirements and analyse the problem to determine the problem’s input/output (I/O). The programmers then code the solution. Software engineers are like Architects who plan, design and oversee the construction of buildings. The programmers are like construction workers who perform a variety of general construction tasks and build the pieces together to complete the project.
  • Coding - is the process of writing computer instructions. It translates a solution into a language a computer can understand.
  • Source Code – the program written in a high-level or low-level language.
  • Syntax – rules of a programming language.

Brief History of Programming Languages

There are many different types of programming languages. Here we discuss Machine Languages, Assembly Languages and High-Level Languages.

Machine languages
This language consists of a sequence of instructions composed of binary numbers i.e. zeros and ones (0s and 1s).
Example: 0000 0101 1100 0000
Machine languages are the only way to communicate directly with the computer. Programming in this language is tedious and error-prone and also it requires highly trained programmers.

Assembly languages
In assembly language, Mnemonics (word-like symbols such as ADD, SUB and MUL) are used to represent the actual machine language instructions.
Example: ADD 2, 5
Assembly programs require an assembler to convert instructions into machine code. It is easier to write programs in assembly language compared to machine language however it is still tedious and requires highly trained programmers

High-level languages (HLL)
High-level language allows programmers to use English-like instructions.
Example: pay = hoursWorked * hourlyRate
The source code of HLL must be translated to machine instructions in one of two ways:
  • Interpreter: where each statement is translated individually and executed immediately after translation
  • Compiler: where all statements are translated and stored as an executable program, or object program; execution occurs later
Programs in this language are classified by their orientation:
  • Procedure-oriented programming is where the programmer concentrates on the major tasks that the program needs to perform. Self-contained units which are called procedures are created. Examples: COBOL, BASIC, C.
  • Object-oriented programming is where the programmer focuses on the objects that the program can use to accomplish its goal. Reusable objects, containing code and data are created. Examples: C++, Visual Basic, Java, C#.

Structures of Programming

All computer programs are written using one or more of three basic control structures: sequence, repetition, and selection.
  • The sequence-structure directs the computer to process the program instructions, one after another, in the order in which they are listed in the program.
  • The selection structure directs the computer to make a decision (evaluate a condition), and then take an appropriate action based upon that decision. The selection structure allows the programmer to evaluate data, therefore properly controlling the logic flow of the program. E.g stopping or going at a signal light
  • The repetition structure often called iteration or looping, directs the computer to repeat one or more program instructions until some condition is met. The repetition structure allows the programmer to repeatedly process a set of instructions, while only typing them once.