COMP348 Tutorial Notes
Principles of Programming Languages - Concordia University

Programmer on Duty (One-on-one assistance) @ H921 Mo--We--Fr 09:00-11:00
Tutorial Leader Section EI @ H907 Mo-------- 16:15-17:05
Remember to fill out the TA/Lab instructor online evaluations

您好,我是 阿德里安娜.迪亚兹。我目前是康考迪亚大学软件工程专业四年级的学生,同时也是COMP348 的助教。如果大家有什么关于这门课程的问题,可以来POD问我,谢谢!

List of tutorials

  1. Tutorial 1 - UNIX and C - A «Nano» Introduction
  2. Tutorial 2 - C - Starting out
  3. Tutorial 3 - C - Debugging
  4. Tutorial 4 - C - GNU Standard C Library
  5. Tutorial 5 - Python 3 - Assignment 1
  6. Tutorial 6 - Python 3 - Data Structures
  7. Tutorial 7 - Tools and Codesigning GDB
  8. Tutorial 8 - Sockets in Python
  9. Tutorial 9 - A1 Review
  10. Tutorial 10 - Getting Clojure to run scripts on the school computers
  11. Tutorial 11 - Skeleton for A3
  12. Tutorial 12 - Basic Erlang program

Tutorial 12 - Basic Erlang program

The following materials are based on How to Install Erlang on Ubuntu (Linux) and Erlang getting started.

Download the zip file of the program we made from here

Tutorial 11 - Skeleton for A3

An entrypoint is where control is being passed to your program from the operating system...

If it wasn’t explicit in my previous post and in Professor Eavis’ slides (refer to slideset 18-Clojure Programs, slides 13 to 15), Clojure is extremely sensitive to namespaces and from where you run the Clojure command... you must put all your code in src/ or in a subfolder inside src/, you must run the Clojure command from the root next to src/ ... you get it wrong and you will probably get a cryptic exception from the JVM...

This is a working example that will help you in your assignment A3... I have included the ZIP file below. 💜

You can download the skeleton here

Tutorial 10 - Getting Clojure to run scripts on the school computers

The school computers only have Clojure 1.8 (from 2016), and it can't run scripts (all it does is REPL). The following instructions allow you to have your own commandline tools for Clojure 1.9, both for REPL and to be able to run scripts!

  1. Download this zip file from here
  2. chmod 755
  3. ./
  4. Now you can run the program with clojure -m main inside the folder that contains src/

IMPORTANT: Next time you open a new terminal window, in order to have Clojure 1.9 available, which has been installed in your .local/bin/clojure ... you have to type
source, and now clojure will correctly point to your locally installed version 1.9.0 👩🏻‍💻

Tutorial 8 - Sockets in Python

Example from official documentation

Instantiate a UDP socket server... UDP is simpler and has less overhead compared to TCP.

Useful documentation

Download here the program we developed server program, and the client program.

Tutorial 7 - Tools and Codesigning GDB

You need to codesign GDB in order to be able to debug programs in macOS.

The instructions are OK except for
codesign -f -s "Your Name GDB" /usr/local/bin/gdb
for the location of GDB. Your certificate name is Your Name GDB...

Tutorial 6 (26 February 2018)

Installing VisualStudio Code in the school computers!!!!

  1. Download rpm to install manually from here
  2. Go in your Downloads folder from the command line rpm2cpio code-1.20.1-1518536126.el7.x86_64.rpm | cpio -idv
  3. cd ~ & & chmod 755 ~/Downloads/usr/share/code/bin/code & & ln -s ~/Downloads/usr/share/code/bin/code code

You have now made a symbolic link in your home folder! To use it just type ./code &

Debugging with VSCode.
  1. Download the VSCode project from here

Tutorial 5 (12 February 2018)

In this tutorial we will see how to use Python to do something similar to your first assignment but in less than 20 lines of Python code!

TODO: At home, on your own, you must read the documentation for every single function used here that you not understand, check the imports, they give a clue as to which modules are being used, also anything not explicitly declared is either built-in or imported... So check the official documentation (link above)!!!!

Also important. Log on to ORWELL...ssh That is a computing node. Logging into will sign you into a random machine.

Once inside run module load python/3.5.1, because if not python will actually be Python2 not Python3..., you can always check with python --version

Download here the program we developed this session.

Tutorial 4 (5 February 2018)

This is just one way of many to read and write simultaneously. Watch for the flags when opening the stream. Also this would only work when the replacement is of the same length -> when we are only changing the case of words...

Download here the program we developed this session.

Tutorial 3 (29 January 2018)

Download here the program we developed this session.

Note: You don't write to a file, you write to a stream, the file is only written when the stream is flushed by fclose(...);, if you forget to close your output streams, then you will never write to file...

Useful links:
GNU C Standard Library (glibc) reference manual
Some information on GDB, the Gnu Debugger
How to use VIM with a mouse in Visual mode
How to connect and run GUI applications on the school servers from your own Windows Laptop
How to connect and run GUI applications on the school servers using your macOS computer
Official GDB Manual is here

Tutorial 2 (22 January 2018)

The purpose of this tutorial is to familiarize you with input arguments from the command line into a C program.

Download here the program we developed this session. ERRATA: I removed the brackets for the char** argv

Tutorial 1 (15 January 2018)

We will cover the basics of the UNIX commandline, compiling your first C program and using Git for basic version control.

Linux commandline

Location directives:

Overview of commands:

Get a GitHub account (Freemium service) student pack
An excellent OpenSource and Free alternative is Gitlab, here.

What we do next depends on your choice of operating system... Three options:
  1. You use Linux🛸 you're all set
  2. You use macOS🧐, install command-line tools xcode-select --install
  3. You use Windows🏚, you either:

Download Here my bash history for this session