1) Programming Language concepts, Prabhas and Vishnu
2) Non-imperative programming language, Vishnu
3) Language and implementation, Prabhas
The goal of this course is to make you understand computer 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
machines 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.
each part 20% by 3 = 60%
. . .
each section lasts 4 weeks.
an in-class work will be handed out each week.
no midterm exam.
at the end of each section, one quiz will be issued.
This part concerns a compiler for a programming 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 classwork. To
teach effectively I choose to design a toy language and implement its
compiler. You will be studying actual compilers and modify them.
-- Jaruloj Chongstitvatana, Programming Languages Principles and Processing,
(local copy) Dept. of Math and CS,
Chulalongkorn, 2017. (main text)
-- Aho, Sethi, Ullman, Compilers: Principles, Techniques, and Tools.
Addison-Wesley, latest edition.
-- Louden, K.C., Compiler Construction: Principles and Practice. PWS
Publishing Co., 1997.
The main text is Jaruloj. It covers larger topics than required in
this class. Our presentation follows this textbook. Aho,Sethi,
Ullman is the standard textbook 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. Louden is much easier to
read. The latest edition is 1997, you can find it in Amazon.
I mentioned "how the first compiler is built" in the class. Here
is a zero compiler in 128 lines and the full reference to my research
paper: Chongstitvatana, P., "Self-generating systems: how to a
10,000,000_2 line compiler assembles itself", invited paper, National
Computer Science and Engineering Conf., Bangkok, Thailand, October
27-28, 2005. (pdf )
Your friend comes to ask me about Functional programming and why it
does not have assignment. A simple answer is that Functional
Programming relies on "referential transparency" hence it does not have
side-effect. Unlike "imperative" (or we can call it "procedural")
programming, functional programming does not even have to use
"variable". Can you imagine that? For those curious mind,
read this foundation paper on Functional Programming. Backus
Turing award lecture 1978
Recommended free C compiler for
Windows lcc-win32 . (for
Windows 7, 8, 8.1 and 10). Please also download and install "User
Manual". You need it to look up the library function of this C. (for
OS X you need xcode, also free).
New example of a recursive descent parser for a simple assembly
LL1 parser from lecture parsing page 25 LL1-parser.zip the
updated package LL1-parser-2.zip
works on both Windows 10 and MacOS (I use xcode to compile on Mac). The
executable file for Mac is used this way, on Mac opens a terminal:
$ ./xparser test.txt
To practice recursive programming in the lecture, you need this
library ailib.zip (in C).
Example of building parse tree ex-parse-tree-2.zip
How to use the compiler
Use rz36 to compile and run your programs. Here is what a
session looks like. Go to rz36/test directory (that you unzip
the package to). There are three executable files:
rz36.exe, as21.exe, sim21.exe . Try to compile "fac.txt".
It is shown here:
if( n == 0 ) return 1
else return n * fac(n-1)
Here is the command line and the output at the screen:
(fun main (print (call fac 6 )))
(fun fac (else (== #1 0 )(return 1 )(return (* #1 (call fac (- #1 1 ))))))
You will get the assembly file as an output file. Then, use as21.exe
to "assemble" (change assembly file into object code file). You can
"run" it under s2 simulator (execute machine code) s21.exe.
That's it. Enjoy!
contact address: prabhas at chula dot ac dot
office room 18-13 Engineering Building 4, floor 18.
research lab: Intelligent Systems, floor 20.