Preview Part D: Software and Programming · Chapter 15 · 17 min read · 79 practice questions
After this chapter you will be able to
classify languages as low-level and high-level, and by generation (1GL–5GL)
match major languages with their creators, years and uses
compare compiler, interpreter and assembler
explain linker, loader, source code and object code
identify syntax, runtime and logical errors
Chapter 15 at a glance Recall the five language levels, the three translators and the three error types.
15.1 What Is a Programming Language?
A programming language is a formal set of words, symbols and rules (syntax) used to write instructions for a computer.
Syntax = grammar rules; semantics = meaning of the statements.
A program written by a programmer is called source code.
A namespace is a named container that keeps one set of names apart from another, so the same name can be used in different namespaces without a clash. Packages and directories play a similar grouping role.
15.2 Levels and Generations
Five generations of languagesLower rungs are closer to the CPU; higher rungs are closer to human language. Only 1GL runs directly on the CPU.Mouse Ate Hot Veg Lunch The first letters M, A, H, V, L give the five language generations, from machine (1GL) to logic / AI (5GL).
Generation
Type
Features
Examples
1GL
Machine language
Only 0s and 1s; directly understood by the CPU; fastest; machine-dependent; very hard to write
10110000 01100001
2GL
Assembly language
Uses mnemonics (ADD, SUB, MOV, JMP); needs an assembler; machine-dependent
Say what you want, not how; used for databases and reports
SQL, report generators, MATLAB, FOCUS
5GL
AI / logic / constraint-based
Solve problems from given rules and constraints
Prolog, Mercury, OPS5
Feature
Low-level (1GL, 2GL)
High-level (3GL+)
Closeness to
Machine
Human language
Portability
Machine-dependent
Machine-independent
Speed of execution
Faster
Slower (needs translation)
Ease of writing
Difficult
Easy
Debugging
Hard
Easier
Translator
Assembler (for assembly); none for machine code
Compiler / interpreter
Machine language is also called machine code or binary language.
LISP is the second-oldest high-level language still in use, after FORTRAN.
4GL examples include SQL, FoxPro and FOCUS. Many 4GLs use SQL as their base.
Machine language is the earliest type in time, but FORTRAN is the first major high-level language.
Problem-oriented languages are designed for one class of problems: COBOL (business), FORTRAN (science) and BASIC (teaching and general use). PL/1 was designed to combine scientific and business features. Machine-oriented languages, such as assembly, are tied to one computer’s hardware.
★ EXAM POINT
The only language the computer understands directly = machine language (binary).
Assembly language uses mnemonics and needs an assembler.
SQL is a 4GL; Prolog is a 5GL.
FORTRAN is the first widely used high-level language.
LISP is the second-oldest high-level language still in use (after FORTRAN).
What the full chapter covers
The full chapter has these sections:
15.1 What Is a Programming Language?
15.2 Levels and Generations
15.3 Important Languages
15.4 Language Translators
15.5 Types of Programming Errors
15.6 C Language Essentials
15.7 More Exam Facts
Chapter Quick Revision
Most Important Terms
Common Confusions
Rapid Recall
Sample questions from this chapter
1. Escape sequence for backspace?
\r
\n
\t
\b
Show answer
Answer: D. \b
\b is the backspace escape sequence; it moves the cursor one position back.
2. Symbol that ends a C statement?
Colon (:)
Period (.)
Semicolon (;)
Comma (,)
Show answer
Answer: C. Semicolon (;)
Every C statement ends with a semicolon; a missing semicolon is a syntax error.
3. Language for numerically controlled machine tools?
APT
LISP
COBOL
SNOBOL
Show answer
Answer: A. APT
APT (Automatically Programmed Tools) was developed at MIT to program numerically controlled machine tools.
4. Language used for web page structure?
CSS
JavaScript
HTML
PHP
Show answer
Answer: C. HTML
HTML (Hypertext Markup Language) defines the structure and content of a web page; it is a markup language.
5. Language whose applets run inside browsers?
Scala
Java
Ada
Erlang
Show answer
Answer: B. Java
Java applets are small programs that run inside a web browser, which made Java popular for Internet programming.