2110316  Programming Languages Principles 3(3-0-6)

1st semester  2010

official course description

this course description

This course is divided into three equal parts.  Three parts are taught by three different lecturers.

1) Programming Language concepts, Twittee  MO 13:00-16:00  Eng3 418
2) Real programming languages, Vishnu          MO 13:00-16:00  Eng3 420
3) Language and implementation, Prabhas       MO 13:00-16:00  Eng3 403


Principal lecturer: Twittee

The goal of this course is to make you understand the languages you use. To make you appreciate diversity of ideas in programming and prepare you for new programming methods and paradigms. Theoretical foundations will be presented. You will know properties of language, not just syntax. Moreover, you will recognize the cost of presenting an abstract view of machine and understand trade-offs in programming language design.  

Each part will be taught separately and independently. It is logical that the assessment will also be arranged according to this structure. There is no midterm exam (besides whatever assess by the lecturer at that time) and the final exam will contain all materials taught in the course.

Assessment

each part  20%  by 3  = 60%
final exam                      40%

the lecture schedule:
section 1: A, B, C  
section 2: B, C, A
section 3: C, A, B

A) Programming Language concepts, Twittee
B) Real programming languages, Vishnu
C) Language and implementation, Prabhas

part C: Language and implementation

This part concerns a compiler for a programming language. To teach effectively, I choose to design and implement a new language and its compiler written in this new language. There are two aspects of learning this part: theory and practice.  The theory will be given in the lectures.  The practice is carried on as homework. As the whole system is avaible for inspection and experimentation, students are encouraged to play with it.  In a nutshell, we will study Nut compiler (written in Nut language).  I provide the tools such as Nut compiler and Nut virtual machine so students can actually program and test it.

old lecture  2009

Announcement

14 June    The first quiz (1)  will be on Monday 21 June  13:00-13:30. 
                The topics are 1) Nut programing 2) scanner 3) CFG

22 June     Second quiz (2) will be on Monday 5 July 13:00-13:30.
19 July      Sec 2: quiz (1)  will be on Monday 9 Aug  13:00-13:30. 
                Topics 1) Nut programming 2) scanner 3) CFG 

23 Aug         For sec 2: Extra lecture on code generation on Monday 30 Aug 9:30-10:30
                     at Hardware Lab floor 18, Eng Building 4.  There will be the last quiz on the topic:
                     Given a grammar, write a Nut parser for it.  Quiz starts at 10:30-11:00.
27 Sept        Summary of the content of the compiler part

Study Plan

each week has 3 hrs, max 5 weeks
plan for 4 weeks, with one to spare
each week has 2 sessions of 1 1/2 hrs. each.

a homework will be handed out each week.
one project will be issued on week 4.

workload

one small project
two mini exams
homeworks, running the code

Lecture sessions

1  structure of a compiler      Overview of the course   (from Stanford slide)     Compiler (ppt)
   HLL to LLL to processor architecture 
2  lexical analyser                 Scanner (ppt)       Scanner in Nut  (use with nvm34.exe)
   automaton
   actual code                          Session on how to use the tools      Overview of Nut compiler
--------------
3  parser
4  grammar                           Context Free Grammar  (ppt)
    mini-exam1
----------------
5  recursive descent              Parsing (ppt)    we are interested only in top-down parsing
6  actual parser                     Parsing  Nut program to N-code          
-----------------
7  code generator                 Code Generation  (with examples)   
    recursive evaluator                                          
8  actual code generator       How to do code generation     code generator (gen21.txt)
    generate s-code             
   mini-exam2
-----------------
9-10  additional topics
  submit project

Assessment for part C

homework 5%     2 quizes  5+5%    one project 5%      total 20%

Extra reading

Programming Recursion   (to familiar yourself with recursive programming)
Nut language manual 
Summary of the content of the compiler part

My text   (website)

Chapter 2    Nut language manual
Chapter 3    Nut compiler
Chapter 4    Code generator

Homework

Section 3
Section 2

Section 1

week 1 
 aim: familarise with Nut language and her compiler

1) Write Nut program to increment each element of an array by k.
2) Write a version of the above program using recursion.
Compile and run these programs.  Use the nut32 tools.


week 4
Write a parser (modify from the Nut compiler) to include a new operator "mod".  Test it.
(no need to submit this one, I discovered that it is too hard.  I will scale the score from other homeworks)

Project

The nature of the project is to read and write a report based on topics in programming language processing.  The report is a short one (4-5 pages) and should take around one week to complete.  You should take about 10 hours reading.  Then, write in your own words, not more than 4-5 pages, analyse and summarise what you "know" about it.

Section 3
We will focus on Java Virtual Machine (JVM).  There are many interesting topics concerning JVM many of which concentrate on making JVM faster (such as Jalapeño project by IBM) and many others.  Or to convert from Java byte code to odinary programming languages. Or Concurrent JVM, or many other extensions such as functional etc. The least is to compare S-code to Java byte code, or their differences in internal structure (such as Stack frame arrangement).  In short, anything that you fancy (or and get your hands on) the topic of implementation of JVM and related topics.  Have fun! 

Section 2
Read and write about the implementation of dynamic langauge.  Dynamic language are languages that are mostly interpret so they can be typed in and executed immediately.  Most scripting languages are dynamic langauges.  The examples of dynamic languages include Python, Ruby, Javascript etc.

Section 1
We are interested in the future of programming languages.  What will they look like in 20 years time?  Please search the current literature on the research of programming languages.  What most research universities are doing?  What about other research labs such as HP, Microsoft, IBM?  Use the knowledge you gain from this course to imagine the future of programming langauges.  Write a report about it.

Reference Text

  1. Aho, Sethi, Ullman, Compilers: Principles, Techniques, and Tools. Addison-Wesley, latest edition.
  2. Louden, K.C., Compiler Construction: Principles and Practice. PWS Publishing Co., 1997.
  3. A few chapters from my textbook, Essence of Computer System Engineering, forthcoming, 2010.


The first one is the standard text book on compiler. It has been used in more than 100 universities in North America.  It is a bit difficult to read as it contains a lot of theory.   The second one (Louden) is much easier to read.  I will update some chapter from my textbook from time to time as necessary.


Tools

Nut compiler in Nut  (The compiler)
Nut compiler source   executable with examples

The code generator  (gen21.txt)
New Nut virtual machine   nvm34


Prabhas Chongstitvatana
contact address:   prabhas at chula dot ac dot th     
office   room 18-13  Engineering Building 4, floor 18.  tel 02-2186982
research lab:  Intelligent Systems,  floor 20.

Last update  27 Sept 2010