CSCI 431 -- Introduction


Why Study Programming Languages

What is a Programming Language

A language used to express instructions to a computer.

Taxonomy of Programming Languages

How Many Languages?

Programming Language Classifications

``High-Level'' Programming Languages

Consider a simple algorithm for testing primality.


In Java:

public static boolean isprime (int n) {
  int d;
  for (d = 2; d < n; d++)
    if (n % d == 0)
      return false;
  return true;


In Standard ML (using a recursive function):

  fun isprime (n:int) : bool =
    let fun no_divisor (d:int) : bool =
          (d >= n) orelse
          ((n mod d <> 0) andalso
           (no_divisor (d+1)))
    in no_divisor 2
    end

In Intel X86 Assembler:

( here's a little tutorial on the I386 if you want it)

.globl isprime
isprime:
        pushl %ebp         ; set up procedure entry
        movl %esp,%ebp
        pushl %esi
        pushl %ebx
        movl 8(%ebp),%ebx  ; fetch arg n from stack
        movl $2,%esi       ; set divisor d := 2
        cmpl %ebx,%esi     ; compare n,d
        jge true           ; jump if d >= n
loop:   movl %ebx,%eax     ; set n into ....
        cltd               ; ... dividend register
        idivl %esi         ; divide by d
        testl %edx,%edx    ; remainder 0?
        jne next           ; jump if remainder non-0
        xorl %eax,%eax     ; set ret value := false(0)
        jmp done
next:   incl %esi          ; increment d
        cmpl %ebx,%esi     ; compare n,d
        jl loop            ; jump if d < n
true:   movl $1,%eax       ; set ret value := true(1)
done:   leal -8(%ebp),%esp ; clean up and exit
        popl %ebx
        popl %esi
        leave
        ret

General Characteristics of HLLs:


Machine Code Characteristics:

Programming Paradigms

What Makes a Good Language?

Ease of Programming:

High Expressive Power:

Language Security Concept:

A language is secure if it guarantees that programming errors cannot ``give rise to machine or implementation dependent effects, which are inexplicable in terms of the language itself.'' [C.A.R. Hoare '73]


What this means is that the behavior of any program, even one with bugs, can be understood within the framework of the language itself.


Example: C has numerous insecure features:


Design Issues:

Fast Translation Techniques:

How to Make Programs Portable:



Acknowledgements: Some of this material adapted from Course notes by Jingke Li