# CSCI3180 Principles of Programming Language - CUHK Course Review

Term Taken: 2020 Spring

Remote Teaching due to COVID19

Instructor: Prof. Lee Ho Man Jimmy

• Programming assignments x4 (60%)
• Final exam (40%)

# Topics Covered

• Names, bindings, scoping.
• Data types.
• Expressions and assignment statements.
• Statement-level control structures.
• Subprograms.
• Declarative programming languages: logic programming, functional programming.

Covered in tutorials:

• COBOL
• Python: duck typing
• Perl: dynamic scoping
• Prolog
• ML

# Textbook

Concepts of Programming Languages. (Robert W. Sebesta)

This book is required because the final exam is open-book. Though I didn’t have time to even take a glimpse at the book while doing exam.

# Review

This is a major required course for Computer Science students. Many people regard this course as difficult and demanding, I don’t know why. I think most of the topics were very interesting and straightforward to understand. The whole course was like extracting all the essence of popular programming languages and discussing the decisions made between different designs. For me, the course was pretty enlightening because though I enjoyed learning new programming languages, I always learned them blindly by following online tutorial nonsense. After taking this course, I could fully grasp the gist of a language by first looking at the decisions made by its designers. Also, after the course, many of the commonly heard technical terms gained rigorous definitions in my brain. To list a few, “compiled vs interpreted vs hybrid”, “static typing vs dynamic typing”, “subtype polymorphism”, “ad-hoc polymorphism”, “pointer vs reference”, “union type”, “static vs stack vs heap”, “functional programming”, “closure”, etc.

The professor didn’t teach us any specific programming languages in the lectures, but in the assignments, we had to write projects using multiple languages. I heard the languages used change every semester. For us, it was COBOL, C, Python, Java, Perl, Prolog, and ML. Noteworthily, the assignments weren’t designed solely for the sake of learning a new language, they were designed for us to compare some important concepts of programming languages, for example:

Assignment 1: COBOL vs. C

We were only allowed to use GO TO in COBOL (i.e. COBOL in the old way) for loops and control statements, so that we could understand the importance of having different control statements in modern programming languages.

Assignment 2: Java vs. Python

Comparison between duck typing in dynamically-typed languages (Python) and inheritance in statically-typed languages (Java).

Assignment 3: Python vs. Perl

Comparison between static scoping (Python) and dynamic scoping (Perl).

Assignment 4: Prolog vs. ML

Understanding the logic programming and pure functional programming paradigm.

Many people complained that the workload of the assignments were too heavy, I didn’t think so. Since all students already knew C, Java, and most likely Python before the course, studying for an additional 1-2 hours would grant them enough COBOL and Perl knowledge to do the assignments. This is because COBOL and Perl are both imperative languages, so coming from a C and Java background, we already knew the meat of the COBOL and Perl. What’s left to do was simply learning the syntax. ML is also easy in the sense that its exactly like mathematics taught in high school, you just need to shift your mind set and pretend you are writing math equations instead of programming to finish the assignment. Prolog is a little trickier, since most of us had no prior experiences in formal logic. To make it simpler, I usually think of mathematical induction when I wrote Prolog programs (though it was a wrong mindset implementation-wise). For example, when writing a predicate for finding the last element of a list:

element_last(X, [X]).


is just like the base case of induction.

element_last(X, [_|Tail]) :- element_last(X, Tail).


is just like the inductive step. It’s like stating since element_last(X, Tail) is true, the next step we could obtain is element_last(X, [_|Tail]), which increases the length of the list by 1 (a single step).

Just to rant a bit here. There were two flaws of the course: the quality of assignment specifications and the online exam. Most of the assignment specifications were pretty ambiguous and it kept on updating after receiving student’s questions on Piazza. That made it a punishment for starting early on assignments, since you never knew whether the code you finished aligned with the latest specifications. Also, the templates of the assignment code followed very poor naming conventions, we could see both snake_case, PascalCase, and camelCase in a single code base. I think the TAs who designed the homework should know better about the naming conventions of a language and follow good programming practices. The second rant is about the online exam. Due to COVID-19, the professor announced the exam to be taken online, we had to stay on ZOOM with camera and microphone turned on and record a 2-hour long video of ourselves from the side during the whole exam. I know the professor wanted to make the exam fair for everyone, but I think it was still easy for students to cheat in this way and it simply made students extremely nervous for the exam. (Many of us worried about power shortage, internet disconnection, Windows Updates, and so on while doing the exam.) Also, the exam was divided into two parts with only 40 and 50 minutes for each. Most of the students had to rush to finish the exam, which resulted in many careless mistakes across the exam paper.

Still, I think this was a really enjoyable course which solidified my knowledge in programming language design and gave me the opportunity to dabble in multiple interesting programming languages.