Skip to Content

PL: Intro to Programming Languages

From old CS 471 notes…

An intro to a PL course

First day: The compiling, linking, and running of C programs

C programs go through quite a bit from source to execution.

Preprocessing, compiling, (possibly assembling), static linking, dynamic linking during runtime

Java programs, from source to execution

Compile to Java Bytecode, possibly referring to other classes' bytecode.

Java .class files are self-describing, so there is no need for a header file as there is in C.

JVM runtime interprets the bytecode, also dynamically loads and links other class files.

JVM may have a built-in “just-in-time” compiler that compiles bytecode to native machine code, to avoid interpreting it all the time.

Other language execution models?

Python? PHP? Javascript?

Programming languages as abstract computation environments

Real computers execute very basic instructions over very basic data, making it hard to program them directly.

So, define an virtual computation environment, then define a language for writing programs in that environment.

  • must be able to somehow translate the virtual computations into real ones
  • Turing (19…) showed the equivalence of computation environments

Some language environments are very complex – i.e., Web languages assume a browser with server interaction.

Real hardware (computer architecture) has influenced language design tremendously, and will do so in the future.

The future of CPUs is one of massively parallel multi-core functionality.

Who will program these? What will the language look like?

Let’s look at math as a virtual computation environment

  • what is the data? numbers.
  • we can talk about sets of numbers – naturals, reals, integers, positives
  • what are some operations? plus, minus, times, greater-than, less-than, log
  • is there a difference between _doing _and just being? what is 4*3?
  • note that complex operations can be defined in terms of simpler ones – multiplication
  • algebra introduces unknowns – identifiers.
  • equality in math is a relation, not an assignment.
  • so, algebra also introduces functions.
  • functions as doing, or as being

Math, in this pure form, forms a functional computation environment.

  • all computation is in terms of relations
  • what values for the unkowns make the relations true?
  • function is a mapping from one set to another set

Our functional programming language is ML.

A Programming Language is:

  • a language for a virtual compuation environment
  • a very _formal _language
  • precise _syntax _(structure)
  • precise _semantics _(meaning)

Evaluation Table From Ch1, page 8

Characteristic Readability Writeability Reliability
Simplicity @ @ @
Orthogonality @ @ @
Control structures @ @ @
Data types and structures @ @ @
Syntax design @ @ @
Support for abstraction - @ @
Expressivity - @ @
Type checking - - @
Exception handling - - @
Restricted aliasing - - @

What about maintainabiity?

What about extra-language features?

Comments, structured comments? Assertions? IDE support? Libraries?

What is a Programming Language?

With C, we saw that the preprocessor is an integral part of the language; yet it is not part of the base syntax and semantics.

The C language cannot really be separated from the C library either.

Is Swing part of Java?

What about javadoc comments?

Creating a new programming language is much much more than just designing a new syntax and semantics. You must immediately provide a rich set of libraries for people to use, possibly provide debugging support, maybe even an IDE.

We saw in the ANSI/ISO C language specification that the official language description includes standard libraries, standard header files, preprocessing directives, and in general a lot of “stuff” beyond just the basic syntax and semantics of the C language.