Lecture notes Wednesday 1/13/99

What is programming?

computer program = set of instructions that control how computers process data

computer languages

3 types:
machine language:
strings & numbers, directly understandable by computer, cumbersome for humans, machine-dependent
assembly language:
English-like abbreviations, need translation: assemblers, require many instructions for simple tasks
high-level language:
like "everyday" English & mathematical notations, need translation: compilers
examples: C, Fortran, Cobol, Pascal, Ada, Modula-2; Prolog; Lisp, Scheme, ML; Smalltalk, C++, ...

pros and cons of C

power -> possible to write "bad", convoluted code (difficult to read, more likely to behave strangely, more difficult to test & debug)

-> aim for clarity, KIS, structured programming, top-down stepwise refinement, functionalization, oo, ...

the C programming system

typical UNIX-bases C environment: edit, compile, execute

C development environment

1. edit:
type, make corrections, name: .c extension; e.g. vi, emacs, pico
2. compile: [gcc welcome.c -> a.out]
preprocessor: before translation, including other files or replacing special symbols with program text, preprocessor directives
compiler: translate into machine language code ("object code")
linker: link object code with code of functions referenced (e.g. libraries) -> "executable image"
3. load (place in memory) and execute
take input from stdin (standard input device)
output data to stdout (standard output device)
display error messages to stderr (standard error device)