Stack-based Languages (Forth, Postscript)

Official Title

185.310 Stack-based Languages (VU2)

Curricula

Mandatory elective course in the Master programs "Software Engineering und Internet Computing" and "Logic and Computation".

Course dates

Register on TISS. Please register before the end of the day of the first lecture. Accounts will be created on the next day.

Lecture date: Wednesday, 16:15-18:00, starting on 2024-10-02, EI6 (Old EI, Gusshausstrasse 25, Stiege 9, 4th Floor or Stiege 10, 6th floor).

If you miss a lecture, you find old lectures in German online

After the lecture part there are presentations of the student projects (the exercise part) at the same date, starting at 2024-12-04. Attendance is obligatory at these presentations.

Setting

Forth is a low-level programming language; unlike other low-level languages, e.g., C, Forth can be used interactively. It can be used in very resource-constraint environments and therefore many Forth applications are in embedded systems. Another prominent application of Forth is in the Open Firmware of PowerPC- and SPARC-based systems.

Postscript is known as page description language for laser printers. A descendent of Postscript is PDF; however, the programming language part has been removed in PDF, while Postscript is a Turing-complete high-level programming language.

The commonality of these languages is the programmer-visible stack that plays a central role. The differences are in type checking, name binding, and in memory management.

There are a number of well-known stack-based languages that serve as intermedate representations for transporting programs between compilers and execution environments, such as the Java VM and WebAssembly. However, these languages are not designed to be directly used by humans and therefore this course does not cover them.

Course goal

Programming knowlegde in Forth and Postscript. Knowledge about the special properties of these languages, and the resulting effects on the programming style (short procedures, much reuse) and programming methods (meta-programming, different debugging methods). Improved understanding of the concepts of programming languages (e.g., name binding, type checking).

Contents

Overview of Forth and Postscript. Simple programming examples in these languages. Program a small project of your own choice in a stack-based programming language.

Deliverables

Write a small project of your own choice in a stack-based programming language, and present it: present what the program does and how it is implemented.

In the presentation, point out program parts that use special properties of the chosen language (i.e., program parts that cannot be translated 1:1 into C or Java; the graphics of Postscript does not count, that could be added to C or Java with a library). If your program has such program parts, it can be arbitrarily short.

Most students have a hard time coming up with a program that uses the special properties to advantage, at least in advance planning. So instead, plan for a program on the order of 50-200 lines, and write it idiomatically (short definitions, using an order of stack items that reduces stack juggling). If you find a use of a special property along the way, make use of it; if you don't, present the program without such a use; if the program is written idiomatically, you will still get a positive grade.

You present the problem and its programmatic solution in two presentations, each with up to 15 minutes.

Programs from this course in earlier years

Course notes

Course notes. Slides

Lecturer

Anton Ertl