Principal lecturer: Twittee. This course is divided into three equal
parts. Three parts are taught by three different lecturers.
1) Programming Language concepts, Twittee
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%
Language and implementation
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 homework and
classwork. To teach effectively I choose to design a toy language and
implement its compiler. There are two implementation, in C and in
1. Learn how to write in Rz by reading Quick
2. Download and compiler the compiler used in this class (rz35-3.zip).
Use whatever compiler for C that you are familiar with and compile it. Try
it out to compile some simple program. For recommended free C
compiler, see Tools section below.
3. Compile and try this lexical analyser (lex-rz35-3.zip),
it is a part of rz35-3.
A language that "verbalise" programming. Imagine how to help a blind
person to write a computer program. We can use speech recognition to
"transcribe" sound to text. However it is cumbersome to just spell
out text of our conventional programing language. Try to read this
"hello world" aloud.
Let us improve the "verbalisation" a little bit. We can use "command"
then follow by "parameters". When the number of parameters is
variable, we can use the word "stop" to delimit them. We can also use that
to say the end of the code block. Let us use this example:
return x * x;
We can verbalise it like this:
function square parameter x stop block return expression x mul x stop
Wow, this will be super good!
Now, back to your project, use this idea to design your small language
(you can use the above example, it is good enough to be used to write a
simple program with no data type). Give examples of your program, both
input "speech" and output (C like). Write the grammar for your
language. Write a parser in pseudo code (no need to generate output),
a pure parser that parses proper input is sufficient.
What you have to submit:
1) Your design of the language, examples of the language
2) Grammar of your language
3) Parser (in pseudo code) for your language
All the above in paper, put the report in "inbox" in front of my office
(room 13 floor 18, Eng building 4) before 4pm 15 Dec 2017.
You don't have to write an executable parser (such as writing it in
C). But, if you do write the "executable" parser, I will give an extra
bonus (5 points) to be add to your final exam. score (however, the maximum
of my part is still 20% now and 13% final). If you did submit a real
parser please email your project to me (I would like to give it a try)
at email@example.com with the subject line clearly
state: prog lang prin project. Remember to include your name and
id in your email so that I can give the credit correctly.
-- NEW ! Jaruloj Chongstitvatana, Programming
Languages, 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.
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).
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 rz35 to compile and run your programs. Here is what a
session looks like. Go to rz35/test directory (that you unzip
the package to). There are two executable files:
rz35.exe and somv2x.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 ))))))