Class 01: Introduction
Held Monday, January 25
Summary
- Background
- Models
- Administrative Details
- Reading: Louden, Chapter 1
- Assignment:
Introductory survey.
Due before class on Wednesday!
Contents
- I believe in beginning my courses with a discussion of the topic of
study. In particular, what are we studying,
why do we study that topic, and
how do we study that topic.
- The following are my notes on the topic. I'd prefer if you waited
to read them until we've had some discussion.
- Those of you who've been in my classes before probably have a
good sense of how to balance reading and discussing.
- Surprisingly, different people (even different programming language
theorists) seem to have different definitions of ``programming
language''.
- What is your definition?
- Here are some garnered from notes and books. Are they all
the same? What accounts for the differences?
- Hoare (in part): A tool to aid the programmer.
- Louden: A notational system for describing computation
in machine-readable and human-readable form.
- Reade One, rather narrow, view is that a program is a
sequence of instructions for a machine. We hope to show that there is
much to be gained from taking the much broader view that programs
are descriptions of values, properties, methods, problems, and
solutions. The role of the machine is to speed up the manipulation
of these descriptions to provide solutions to particular problems.
A programming language is a convention for writing descriptions
which can be evaluated.
- Rebelsky: A notation for expressing algorithms so that they
may be understood by humans and processed by machines.
- Stansifer. The purpose of language is communication. Human
beings use natural languages to communicate among themselves.
Programming languages are used to communicate with literal-minded
machines.
- Different languages provide significantly different perspectives on
how to express algorithms, data structures, and control. They may also
provide different features for developing algorithms. By visiting
these different perspectives, you will find new ways to express your
ideas (and perhaps even find ways to express ideas that were previously
too difficult to express).
- Most of us will need to write programs in the future. Exposure to
a wider variety of paradigms, principles, and languages
- gives you tools and methodologies for choosing which language to
use for a project;
- increases your ability to learn new languages;
- often improves your programming ability in your language of choice.
- Most major software packages end up including some form of programming
language. By studying languages, you will be better able to design your
own languages.
- The Tcl crowd would tell you that everyone should just include
Tcl in their package.
- The FSF crowd might tell you that Scheme would be even better.
- There are many different perspectives on how best to study
programming languages. At times, it seems every course (or at
least every text) promotes a different perspective.
- Each perspective has certain advantages and disadvantages.
- Some perspectives are language-based.
- One might cover a new language every week. This provides a
wide introduction to languages and gives some basis for comparison.
At the same time, it makes it difficult to cover languages and
issues in any depth.
- One might cover a new language ever month. This permits greater
understanding of the particular languages covered, but often at
the expense of higher-level understanding.
- One might cover one language that is so complex and multifacted
that it introduces a wide variety of topics.
- Some perspectives are implementation-based.
- One might develop interpreters for a number of languages. This
enhances understanding of many design issues and their advantages
and disadvantages. At the same time, implementation is difficult
and can detract from learning of more general issues.
- One might develop an interpreter or compiler for a single language
that expresses concepts from multiple paradigms. Again, this
helps illustrate a number of key concepts and allows you to
experiment with variations on a theme, but has the potential
to miss many important issues.
- Some perspectives are semantics-based.
- One might investigate a single form of semantic notation and develop
semantics for a number of languages (or for one large language).
- One might investigate a number of forms of semantic notation and
develop semantics for a small language.
- Some perspectives are concept-based.
- One might study the various paradigms and design possibilities.
This is the most general strategy, but runs the risk of ignoring
more concrete details.
- We will use the last strategy, and will attempt to ground our discussions
in actual languages. We will also draw upon the other strategies at times,
discussing everything from semantics to implementation to usage.
- I'll use some labs to help ground concepts in particular languages.
See the handouts in the
course web.
- Suppose you are asked to describe a programming language. What
are some of the general attributes you might use in your description?
- Many people emphasize the syntax of the language. That is,
the way in which you express the concepts of the language. More
abstractly, the syntax provides the legal combinations of symbols
permitted by the language.
- In practice, the syntax often provides
a superset of the legal combinations provided by the language.
- Underlying this is a semantics which assigns meaning to
the various utterances.
- In practice, the semantics also limits the legal combinations
provided by the language.
- However, most language design is guided by an overall model,
paradigm, or philosophy. That is, how does the language view
computation?
- Are there other aspects you would add? Are these three appropriate
for describing natural languages?
- If you were confused by those side notes on syntax and semantics,
let's consider English.
- We have some basic rules for forming sentences. For example,
``Noun Phrase'' + ``Transitive Verb'' + ``Noun Phrase'' is one form of
sentence. That's part of the syntax of English.
- We can assign meaning to sentences. For example, you all understand
and describe
what the sentence ``SamR scribbled some hieroglyphics'' means.
- But semantics also limits the sentences we might utter. For example,
few would accept ``The hieroglyphics scribbled SamR'' as a valid
sentence.
- Since the concept of ``model'' may be confusing to some, we will
take a quick look at some of the standard models of programming
languages, possibly grounding our discussion in examples.
- In imperative languages programs
are collections of basic commands (most often assignments and I/O)
where the execution is sequenced by control structures (e.g.,
loops, conditionals, blocks).
- Imperative languages include C, Pascal, Fortan, and Assembly.
- In object-oriented languages
programs consist of a number of objects that
interact with each other.
- Some also associate inheritance and polymorphism with object-oriented
languages.
- Object-oriented languages include Simula, Smalltalk-80, Eiffel, and
Java.
- In parallel languages programs
are collections of processes (or, sometimes, structured
data) that communicate with each other.
- Parallel languages include C* and Ada.
- In logic languages programs are collections of
statements within a particular logic. Most typically,
that logic is the predicate logic.
- Prolog is the prototypical logic language.
- OBJ and the equational programming language are others.
- In functional languages programs are collections of
function definitions and function applications.
- Some also associate higher-order functions, abstract functions, and
a lack of side-effects with functional languages.
- Functional languages include FP, ``pure'' Scheme and LISP, ML, and Haskell.
- In declarative languages programs are collections of
declarations. Many functional and logic languages are also
declarative languages.
- If you've used regular expressions, you've used a small declarative
language. In effect, you've described the pattern to be matched
without writing the code to match the pattern. (If you think about
it, some patterns could be fairly difficult to code by hand.)
- In scripting languages programs typically work in
conjunction with a larger application, support control of a variety
of applications, are interpreted, or some combination thereof.
This is a rough attempt to flesh out some of the differences between
the paradigms by looking at how one might write a sorting algorithm
in the different paradigms. Sorting is a fairly imperative process,
so all will look somewhat imperative.
Imperative
- You should know a number of sorting algrorithms by now.
Declarative
S is a sorted version of L if
S is a permutation of L AND
the elements of S are in order
Object-oriented
An object-oriented sorting algorithm would presumably ask objects to
compare themselves to each other, rather than using an explicit comparison.
Functional
A functional sorting algorithm would probably take a compares function
as an argument.
Parallel
Guess.
History
- Created Tuesday, January 19, 1999 as a blank outline.
- Filled in the details on Monday, January 25, 1999. These were
taken mostly from last year's class.