CPS 106 Programming Languages

Overview

Study 4-6 different programming languages in enough depth to be able to write moderate-size programs in each. One or two programming assignments in each. Learn some of the run-time data structures and algorithms needed for each language.

 

Purpose:

Learn the languages for possible use.

Observe differences in language philosophy, discuss those philosophies.

Why ARE there so many programming languages?

What are their commonalities and differences?

Compare from different viewpoints:

Speed of rough program development

Ease of producing a correct program by either design or debugging

Speed of program execution

Thought processes used in program development

Special properties

Portable program?

Safe to use untrusted programs written in this language?

Allows easy access to special peripherals – printers, plotters, mouse, sound-card, screen?

I/O features allow arbitrary computations on characters?

We will study the "pure" version of many of these languages, a version which does not include features imported from other languages:

Clarifies language philosophy

Shows that that philosophy can result in a "complete" programming language

Usually represents a simpler version of the language than the production version

Language sketches:

LISP (Scheme dialect):

Functional programming. All programming done by designing functions without side effects. Iteration done ONLY by recursion. NO assignment operation. Yet the language is easy to program in, gives insight into how "pure recursion" works. You can rapidly develop a hierarchy of functions which perform quite complex tasks, while each function remains very short, and easy to comprehend.

PROLOG (programming in logic):

Declarative programming (not procedural), OR procedural. Each definition is supposedly a predicate’s definition, which is "true" if the predicates in its definition can be evaluated as "true". Strange notion of "variables". PROLOG programs tend to be readable, perform complex AI tasks. Language has AI exhaustive search built in.

Standard Meta Language [SML] (example of a language with complex type structure, which usually needs no declarations, and yet does type checking at compile time; rich syntax, like C):

Convenient, modern programming

SML combines the power of PROLOG (rule-based programming), the simplicity of LISP functional programming, and a rich C-like syntax which makes expressions much easier to read than LISP expressions. SML also includes powerful modern features:

Polymorphic functions, which automatically operate on arguments of different types

User-defined types, including encapsulation of the access functions to those types (inheritance?)

Static, compile-time type checking, often without declarations

Recursion emphasized over iteration

Assignment to variables is the exception, not the rule

AWK and PERL (A, W, and K are initials of the designers)

String programming

AWK and PERL treat strings of characters as fundamental types, in a C-like programming language. AWK has a more forgiving syntax than C:

Semi-colons aren’t required

Both languages are "load-and-go", not separately compiled.

Strings are usable as subscripts of arrays, are searchable for "regular expression" patterns, can be formed by concatenation, and chopped apart usefully.

PERL adds convenient access to UNIX library functions, including many used mainly by system administrators. In the process, its syntax becomes much more complicated

These languages are great for developing report-writing applications quickly. I use AWK to prototype new C applications.

JAVA ("hot and stimulating")

Interactive, safe programming

Designed so one company can develop programs that

    1. Run on another company’s computers "safely", with neither company "trusting" the other
    2. Programs are dynamic, interact with user via animated displays, keyboard, and mouse

JAVA programs are "pure" object oriented programs – no easy ways around the type encapsulations; C-like OO programming, with convenient multi-threading, easy ways to incorporate programs (Classes) defined by others, good library for designing GUIs.

Other languages:

Language for expressing SIMD parallelism. APL is a possibility, but that language has a hard-to-read syntax.

Language for expressing distributed multi-tasking, clearly, with emphasis on speed of execution. FORTRAN, with message passing system like PVM? Or maybe MathCAD, Maple, or Mathematica).

Simulation language (maybe SIMSCRIPT)

Data-base language (SQL is the standard, but I don’t think it is a "complete" programming language)

General questions to ask:

    1. Are there language features which make the language slow in execution?
    2. Do some language features lead to more program errors, or errors that are hard to detect?
    3. Some languages have built in operators for common program actions, like array access, while others do this using subroutine call; C++ may allow definition of an operator to replace a user-defined function call. So these differences change any interesting parameter of the language?
    4. How much of the perceived difference in ease of use between languages is due to their storage allocation/freeing methods?
    5. What happens to ease-of-use, and other properties of the language, when you mix constructs from multiple languages together? (This may depend on the particular constructs:

Adding the ability to modify a LISP list structure to LISP may make programs harder to understand

Adding the ability to declare arrays indexed by non-integers might be relatively harmless

But consider the effect of allowing an entire array to be such an index in a C++ program…).