Introduction To Computer Programming
Chapter 1
CS 2250, Chap 1 Slide 1 of 20
Language Levels
Where do they all go? PHigh-level
< Close to problem < System independent
PLow-level
< Close to system < Doesn’t reflect problem
Java, C# FORTRAN, COBOL, C++ C/C++ Assembler Machine
CS 2250, Chap 1 Slide 2 of 20
Relationship Between C and C++
C++ is (almost) a perfect subset of C
ANSI C C++
main functions syntax
- perators
flow of control
- rganization
compilation libraries
- bject-oriented
model
prototypes const inline references new / delete classes encapsulation inheritance polymorphism RTTI templates ctors/dtors
- verloading
CS 2250, Chap 1 Slide 3 of 20
PAdvantages
< Smaller generated code < More portable (machine independent) < Better diagnostics (debugging) < Can implement “very high-level” languages
P10 to 100 times slower than a compiled program!!
< Hybrid systems are 3 to 10 slower
Interpreter Operation
Dynamic translation
Text file Interpreter
runtime
PCPU executes the interpreter
< Program is data to interpreter < Parses each statement in the program (each every time it is executed) < Carries out the program statements
CS 2250, Chap 1 Slide 4 of 20
Compiling Programs
Multi-file programs (compare with Fig. 1.10, p. 15)
editor linker source code .c .asm compiler or assembler
- bject
files .obj .o libraries runtime executable
CS 2250, Chap 1 Slide 5 of 20
PC was created by Dennis Ritchie in the early 1970s to write a portable version of Unix PC and Unix came together in 1973 on a DEC PDP-11/20 running the 5th edition of Unix PThe line between C and Unix is not distinct (although they are governed by two standards: ANSI and POSIX) PANSI standard
< Committee was established in 1983 < Standard adopted 1989 and became available in 1990 < Is the base document for the ANSI C++ standard < Many features of C++ were back-ported to C either because they were good features or to avoid gratuitous differences
The Origins of C
A brief history
CS 2250, Chap 1 Slide 6 of 20