CSC 280 · Introduction to Computer Programming
Our notes
2 min readGenerations of languages
| Generation | Example | Notes |
|---|---|---|
| 1st: machine language | 10110000 01100001 | binary, runs directly, specific to one processor |
| 2nd: assembly language | MOV AL, 61h | short words (mnemonics), needs an assembler |
| 3rd: high-level languages | FORTRAN, C, Java, Python | English-like, portable |
| 4th: very high-level | SQL, report generators | say what you want, not how |
| 5th: logic/AI languages | Prolog | solve problems from rules and facts |
Famous high-level languages
- FORTRAN (FORmula TRANslation, 1957): science and engineering maths.
- COBOL (1959): business records.
- BASIC: teaching beginners.
- C (1972): operating systems, fast programs.
- Java, C#: large applications, Android (Java/Kotlin).
- Python (1991): simple syntax, data science, AI, automation, now the most common teaching language.
- JavaScript and PHP: websites (UniHive itself is written in PHP).
Translators
A computer runs only machine code, so other code must be translated.
| Translator | What it does |
|---|---|
| Assembler | assembly → machine code |
| Compiler | translates the whole program into machine code first (object code), then it runs; fast to run; reports all errors after compiling (C, FORTRAN) |
| Interpreter | translates and runs one statement at a time; slower, but easy to test; stops at the first error (Python, BASIC) |
Source code is what the programmer writes; object code is the translated version; a linker joins object code with library code into an executable; a loader puts it in memory to run.
Three kinds of errors
| Error | When found | Example |
|---|---|---|
| Syntax error | when translating | `prnt("hi")`, a missing bracket or colon |
| Run-time error | while running, program crashes | dividing by zero, opening a file that is not there |
| Logic error | program runs but gives wrong answers | writing `avg = a + b / 2` instead of `avg = (a + b) / 2` |
A first Python program
name = input("Your name: ")
print("Hello,", name)
The first line shows a prompt and stores what the user types; the second prints a greeting.
Integrated development environments (IDEs)
An IDE puts an editor, translator and debugger together: IDLE, Thonny and VS Code for Python; Code::Blocks for C and FORTRAN. On a phone, apps like Pydroid 3 run Python offline, useful when the lab is full.
Exams usually ask: generations of languages; compiler vs interpreter; define source code, object code, linker, loader; the three kinds of errors with examples.
Common mistake: saying a program with no syntax errors is correct. Logic errors are only found by testing with known answers.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Best pick Introduction to Computer Science, 7.4 Programming Language Implementation
(opens openstax.org in a new tab)
OpenStax, Introduction to Computer Science, 7.4 Programming Language Implementation, CC BY-NC-SA 4.0 · licence
-
Introduction to Computer Science, 7.1 Programming Language Foundations
(opens openstax.org in a new tab)
OpenStax, Introduction to Computer Science, 7.1 Programming Language Foundations, CC BY-NC-SA 4.0 · licence
-
Compiler
(opens en.wikipedia.org in a new tab)
Wikipedia, Compiler, CC BY-SA 4.0 · licence
-
Interpreter (computing)
(opens en.wikipedia.org in a new tab)
Wikipedia, Interpreter (computing), CC BY-SA 4.0 · licence
-
Introduction to Python Programming, 1.6 Error messages
(opens openstax.org in a new tab)
OpenStax, Introduction to Python Programming, 1.6 Error messages, CC BY-NC-SA 4.0 · licence
Watch
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.