Week 5

Exercises on WIG

  1. Using some standard language, implement a CGI script that makes the Python form on slides 6-7 work to produce the output on slide 12. (This form is simply generated from by a WIG service called Python containing a session called Questions; it has nothing to do with the language.) Provide a link to it running on your homepage.

    Motivation: you will generate CGI scripts as the output of your WIG compilers, and so you might want to experiment with or even just find out about the different options you have. For example, by default you will target C, but if you are feeling more adventurous you can target PHP. In the past, some groups have even built little stack machines. If you simply don't care and the default C target sounds good to you, just don't spend any time on this question.

  2. Now implement a WIG service for the Python form. Use a previous WIG compiler binary to compile it, following these directions. Provide a link to it running on your homepage.

    Motivation: it is critical for you to get the existing WIG compilers up and running, and to get basic Hello World-like WIG programs working and installable. It is expected that this question will expose some development environment problems.

  3. Where unclear, what do the environment variables on slide 9 contain, and what is the syntax for possible values? It is acceptable to copy and paste from online manuals.

    Motivation: trying to understand the specific process by which clients interact with servers and servers interact with scripts helps demystify some of the communication magic. If you simply don't care, just don't spend any time on this question.

  4. The game of NIM consists of some number of piles of matches, for example 7 piles of 5 matches each. Each player must in turn remove any number of matches from a single pile. The winner is the one that removes the last match. Implement a WIG service that allows clients to play against a server. The client should be able to select whether the server uses an optimal or non-optimal strategy, and you should have an initialization mechanism for determining the number of piles and the number of matches in each pile. Publish the game on your homepage and provide a link to it.

    Motivation: help familiarize you with the WIG language and improve your WIG benchmark programs due for the next milestone. If you want to limit your example to the simplest NIM implementation possible with a fixed number of piles and a naive server playing strategy, that's fine; however, you will probably discover more things about programming in WIG if you try to do this question more fully. For example, you could let multiple clients play not only against the server but also each other at the same time, and you could also arrange for multiple different groups of clients, much like tables at poker or bridge tournaments. (What happens if a player gets up?)

  5. For each security issue on slide 36, give an example scenario where a violation would be catastrophic. (For fun, the more ridiculous your scenario the better; online banking fraud does not count as ridiculous.) Outline an implementation for each of the given solutions.

    Motivation: help you think about security issues in client-server programming and possible solutions; your WIG compilers will implement these solutions. If you simply don't care, just don't spend any time on this question.

  6. Read through the code on slides 37-44. You should understand what each line of C code does and how it relates to the input WIG program. What parts of this code are unclear?

    Motivation: help you start thinking about code generation, and find out from you early on what's unclear about the output programs. If your compiler generates C-based CGI code, it will end up resembling this.

Maintained by Christopher J. F. Pickett. [HOME]