Programming Languages and Language Translators

Characteristics of a Good Computer Program

Efficiency, reusability, maintainability, reliability, correctness, robustness, documentation, portability, flexibility and readability.

Programming Languages

A programming language is a set of words, symbols and rules for writing computer programs, determined by its syntax (rules for formulating statements) and semantics (the meaning of those statements). There are two categories:

  • Low-level languages: allow low-level access to hardware features. Machine language (the first generation) is written in binary and directly executable by the processor. Assembly language (second generation) uses mnemonic codes like ADD, LOAD and STORE to represent machine instructions. Advantages: easier to write than machine language, produces small, very fast programs. Disadvantages: still hard to write/understand compared to high-level languages, and tied to specific hardware.
  • High-level languages: closer to human language, letting a programmer write programs without understanding the computer’s inner workings. Examples: C, BASIC, Pascal, Java, FORTRAN, C++, COBOL. Advantages: easy to write and understand, built-in libraries, portable across hardware. Disadvantages: slower than low-level languages, larger program files, and may not allow low-level hardware access.

Language Translators

A program needs to be translated into machine language to run on a computer. There are three types of translator:

  • Assembler: translates assembly language into machine language (assembling).
  • Compiler: translates an entire block of high-level source code into machine (object) code before execution. Advantages: fast execution, and the object code can be distributed/run without the compiler present. Disadvantages: harder to debug, and the whole program must be recompiled after any fix.
  • Interpreter: translates and executes high-level instructions one line at a time. Advantages: good at locating errors since translation is line-by-line, and no need to retranslate the whole program after a fix. Disadvantages: slow, and the interpreter must be present for the program to run.

Program Errors and Correction

  • Syntax error: a place where the language’s rules were not followed – stops compilation or interpretation.
  • Semantic error: the programmer misunderstood the meaning of something in the language; not detected by compilation/interpretation, only from wrong results (also called a logical error).
  • Run-time error: occurs while a program is executing, e.g. division by zero, and may stop execution.
  • Debugging: the process of finding and removing bugs (syntax and semantic errors), often using a debugger tool.

Key Words and Operators

A reserved word (keyword) has a specific meaning in a language and cannot be used for any other purpose, e.g. If, Else, For. Operators perform operations on data and may be arithmetic (+, -, *, %, ++, –, /), relational (<, >, ==, <=, >=, !=) or logical (NOT !, AND &&, OR ||).

Programming Paradigms

  • Imperative (procedural): sequences of instructions executed in the order designed, e.g. C, Pascal, FORTRAN, Ada.
  • Declarative: the programmer states only what the result should look like, not how to obtain it – made up of the logic paradigm (facts, rules and theorems, e.g. Prolog, Mercury) and the functional paradigm (construction of mathematical functions, e.g. Lisp).
  • Object Oriented (OOP): software is a collection of objects that receive messages and perform actions (methods), e.g. C++, Python, Java.

Software Development Tools and the Development Cycle

A source code editor is a text editor designed for editing code; an IDE (Integrated Development Environment) provides comprehensive facilities – a source code editor, compiler/interpreter, automation tools and a debugger; a linker combines object code modules into a complete program. The stages in the program development cycle are: Problem Analysis, Task Analysis, Algorithm Development, Coding, Testing and Debugging, and Documentation and Maintenance.

Leave a comment

Your email address will not be published. Required fields are marked *

sponsors Ads