Principles of Programming Languages Tasks. There are two tasks, both entry level, which are,Assignment 0 – Some Sample Programs in Shank and Task 1 – The Lexer.
4 attachmentsSlide 1 of 4attachment_1attachment_1attachment_2attachment_2attachment_3attachment_3attachment_4attachment_4
Unformatted Attachment Preview
From the beginning, programming was hard
Programming was done,
at first, by re-wiring.
With the adoption
memory as a way
to store programs,
we moved to
Machine Language – First Generation Language
Machine language is made up of instructions, stored in bits.
1001 1100 1010 0011 (for example)
These bits might indicate that the computer should add two numbers
together (stored at addresses 14 and 10) and saving them into another
No loops or advanced flow control
You can jump to a different instruction by comparing two values:
Is the first less than the second?
Greater than the second?
There were also no variable names – everything was by address in the
Clearly this was difficult…
To write a program, you had to:
Understand the algorithm
Break it down to the instructions that the computer could do
Manage your resources (memory, input, output)
Deal with infinite loops
All with no debugging capability
And if the program is wrong, you have to fix and re-enter by hand!
Asssembly – Second Generation Language
The most pressing need (and it was done fairly quickly) was to get out
of flipping switches and entering bit values.
Assembly language is a textual representation of machine language.
It is a 1-1 translation – one line of assembly is one machine language
1001 1100 1010 0011 ➔ ADD R14, R10, R3
Assembly Language is the language. An assembler is the program that
takes the text (ADD R14, R10, R3) and converts it into bits.
This is still slow and arduous, but easier than working in bits.
Assembly language is still used today by people who work close to the
Often game developers will do some level of high performance work in
Growth of computing
While assembly language was a big jump, it still presents a number of
problems that started to be pressing.
Computers were getting cheaper and more of them were being made.
Companies started looking at how computers could help them with
handling their exploding data needs.
What they found, at first, was not an easy path.
Problems with working in Assembly
Assembly language is
machine (brand) specific
labor-intensive (and therefore expensive)
arduous (tedious and difficult to write long programs)
unintelligible (hard for others to read what you wrote)
highly detailed (even things we don’t care about)
hard to reuse any existing work
Begin the abstraction…
While the 1st and 2nd generation languages were all very tied to the
machine design, the 3rd generation were far less so – they were more
By taking a step back from the hardware and writing programs based
on what one wants to do, a number of the issues with assembly were
Procedural languages solve issues!
Assembly procedural language(s) is(are):
machine (brand) specific “portable”
labor-intensive (and therefore expensive) Quick to develop in
arduous (tedious and difficult to write long programs) Easy
unintelligible (hard for others to read what you wrote) Clear
highly detailed (even things we don’t care about) Abstract
hard to reuse any existing work Encourage reuse
Procedural Language Innovations
Loops (for, while)
abstractions for reading/writing
Functions/Procedures/Subroutines (parameters and return values!)
Data structures (Cobol records)
Enforcement of data types
A hint of the flavor – Fortran
In 1956, John Backus (you will hear his name later!) and his team
created a language called Fortran (FORmula TRANslator).
A team at IBM spent 25 person-years to build a language designed to
take scientific formulae and convert them (nearly) 100% efficiently to
Fortran is still used in scientific computing because of its high
performance and wide-spread use.
C AREA OF A TRIANGLE – HERON’S FORMULA
C INPUT – CARD READER UNIT 5, INTEGER INPUT
C OUTPUT – LINE PRINTER UNIT 6, REAL OUTPUT
C INPUT ERROR DISPAY ERROR OUTPUT CODE 1 IN JOB CONTROL LISTING
IF(A.EQ.0 .OR. B.EQ.0 .OR. C.EQ.0) STOP 1
S = (A + B + C) / 2.0
AREA = SQRT( S * (S – A) * (S – B) * (S – C) )
601 FORMAT(4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA=
A hint of the flavor – Algol 60
The ACM (Association for Computing Machinery) worked together to
design a language that was “Fortran for algorithms” (and not tied to
A number of features were included in Algol that Fortran did not have,
including local variables, dynamic arrays and recursion.
FOR i := i WHILE i0 THEN 150
90 LET X=XD
100 GOTO 160
150 LET X = X – D
160 IF D < .0001 THEN 200 170 LET D=D/2 180 GO TO 60 200 PRINT “ROOT = “ X 999 END A hint of the flavor – Pascal (1968-1972) Designed by Niklaus Wirth, a Swiss computer scientist. We wanted to simplify ALGOL and focus on education. Simple highly structured conditionals and loops The ability to make enumerations More data structures (records, files, sets) Included pointers Used “P-Code” – a stack based virtual machine Program TowersOfHanoi(input,output); Var disks: integer; Procedure Hanoi(source, temp, destination: char; n: integer); begin if n > 0 then
Hanoi(source, destination, temp, n – 1);
writeln(‘Move disk ‘,n:1,’ from peg ‘,source,’ to peg ‘,destination);
Hanoi(temp, source, destination, n – 1);
write(‘Enter the number of disks: ‘);
C, Shell, UNIX
The C programming language, the Bash (and other) shell language and
UNIX all came from Bell Labs in the early 1970’s. These are so critical to
our understanding of Computer Science that they get their own course.
Of all of the procedural programming languages, C is, by far, the most
popular today. It is highly portable and is particularly designed for
“systems programming” – writing operating systems and other low
* a simple C program
#define LAST 10
int i, sum = 0;
for ( i = 1; i
Purchase answer to see full
User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.