Hello World! An Invitation to Computer Science
Lecture Slides
Survey of Programming Languages
Monday March 31, 2008
Recapping the Big Picture
- how to phrase problems in way that computers can solve?
- what are limits of computer v. human brain?
- what are fundamental elements of problem solving of this kind?
- we have identified key concepts:
- algorithms
- bits
- Boolean expressions and circuits (hardware realization)
- low-level software realization:
assembly and machine languages
- key tool at our disposal: abstraction
lets us zoom/in out on problem
creates hierarchies of ways of thinking about problem
so we can tackle large or small problems
and take context into consideration
- now we get more serious about software realization
by considering spectrum of programming languages
Assembly language v. machine code
- mnemonics rather than numbers for instruction names
easier to remember, to read, to understand
single typo can be flagged as an error
- symbolic addresses
as with symbolic ops - easier to read, etc.
no need to change if instruction inserted, deleted, moved
- pseudo-operations for specifying data
- natural language comments
but what are limits of assembly?
Weaknesses of assembly language
- explicit management of all data
- microscopic view
even "algorithmic primitives" may need to be broken down
- machine specific (not portable!)
- still cryptic: nowhere near natural language
or standard arithmetic notation
Motivations for high-level languages
- do not have to understand inner workings to write programs
(is that a good thing?)
- "back in the day": resources were scarce
major factor in terms of tools/languages available
and in way people programmed
- positive feedback loop:
easier-to-use prog langs → more users
&rarr more demand for computers → more powerful
computers
→ more expressive/powerful languages can be developed → ...
3rd generation languages
- addresses above issues (some more than others)
- macroscopic view: allows for abstraction/encapsulation
- require more system software : compilers, interpreters
- libraries, separate compilation, and linking
increase development speed (see figure 8.1, p. 341)
programs can be developed using multiple languages
Why are there so many programming languages?
(there are thousands of others aside from those mentioned in
text!)
- Tower of Babel effect
- book's analogy of choice among cars
- effect of competitive marketplace
- history of computers and computer science important
- example: polyglot
Hello World!
General purpose programming languages
- "Turing complete" (more on that later)
any program that can be solved via algorithm can
(in principle) be solved in one a general purpose PL
- important questions remain:
compactness, efficiency, readability, maintainability, ...
- philosophical debates - can get almost religious!
- "general"; but usually developed for specific
different PLs better suited for different problem domains
- how fast do you need problem solved?
- is speed of execution v. speed of development?
- how much is riding on correctness?
and how bad is it if an error is found?
- who else will be reading/using this program?
- will it have to run on different machines?
and does it need existing programs or data?
-
a
crash course in history of high-level PLs
The C programming language
most important language of modern cs (and of last 30+ years)
- intimate relationship with operating system (UNIX)
- portability
- (eventual) standardization
- combination of high-level and low-level features
- C's family: C is ancestor of many popular languages
very directly: Java, C++, PHP, C#
less directly: Perl, Python, Ruby, Ada, ...
PL considerations
- language features v. library options
- "GOTO deemed harmful" debate
- legacy code and Y2K
- ambiguity for computer v. programmer/reader
- compactness v. mistakes
C, C++ allow short cuts: hard to read, easy to screw up
implicit v. explicit distinction among data types
Imperative/procedural PLs
- FORTRAN
- Algol family and Pascal
- BASIC
- C: pointers and exposing low-level details v. abstraction
- C++: C plus much more (object-oriented features)
- Ada - and why it failed
- Java
why it is so popular?
why are we not focusing on it in this course?
- C# v. Java
Domain Specific Languages
- SQL (a declarative language)
- markup languages (not programming languages)
HTML: formatting language for Web browser
XML: meta language
- Javascript (a scripting language)
Scripting languages
- Perl
- PHP and dynamic Web pages
- Python
- Ruby
Functional programming
- elegant underlying theory
- lists and recursion
- LISP, Scheme, Standard ML
Other programming paradigms
- logic programming
- parallel programming
SIMD v. MIMD; asymmetric v. symmetric
distributed v. concurrent v. parallel