Monday: C#

  • Obtain Visual Studio: (n.b. not the same thing as Visual Studio Code)
    • If you're using a university machine, it should already be there and you don't need to do anything - but check!
    • If you're using your own Windows machine, click here - "Windows desktop development" will be a good configuration
    • If you're using a Mac, click here
    • If you're using Linux, install MonoDevelop, which is probably in your package manager (maybe as part of the mono package)
  • You can log in using your university account username@student.vuw.ac.nz, use an existing Microsoft account, or make a new account yourself

Virtual machines (if you prefer that to above)

You can get a free expiring Windows virtual machine with Visual Studio from Microsoft and use it for development and run it on your machine using VirtualBox.

Reference material:

Suggested older exercises

Tuesday: Unix shell scripting with Bash; Haskell

Shell Scripting

  • General Usage
    • Start either the Ubuntu terminal (Windows, either of them) or Terminal (macOS). Everything will be the same from there on.
    • In the terminal, push enter to run the command you typed.
    • To terminate a program, press Ctrl-C (nb not cmd-C)
    • To stop a command reading from standard input, press Ctrl-D (not cmd-D)
  • Syntax
    • In each line, the first word is the command to run and the rest are arguments, which the command interprets how it wants.
    • Operators can join commands and files together.
    • Quotes ' and " can join multiple words into a single argument.
    • Some constructs, written with $, substitute some other text into the command, as though you wrote it there
  • Variables ("parameters"): x=123 ; $x ; ${x} (nb no spaces around the equals sign)
    • Arithmetic expansion: $((i + 1))
    • Command substitution: $(command args...) - substitutes the output of the command in the brackets into the program
  • Control structures
    • Conditionals: if cmd ; then ... ; fi
    • While loops: while cmd ; do ... ; done
    • Test: [ $x -lt 10 ] or [ $x -eq 10 ] or [ "$x" = "start" ] - you need to have spaces on both sides of the [ ]
      • e.g. while [ $x -gt 10 ] ; do x=$((x - 1)) ; done
      • This is because the [ is actually the name of a command!
  • Some common commands:
    • echo - print text
    • cd new/directory - change to a new current directory
    • cat file - output the contents of file (con*cat*enate multiple file arguments)
    • cat - just output the input
    • ls - list files
    • grep - print lines matching a pattern: grep PATTERN FILE FILE2... ; ... | grep PATTERN
    • man - read manual pages (`man chmod`)
    • cp - copy files: cp source destination
    • mv - move files: mv source destination
    • tr x y - replace all xs in input with ys
    • ln -s TARGET LINKNAME - make a symbolic link (an alias) to TARGET called LINKNAME
    • wc - count characters/words/lines: wc file.txt
    • sed - replace text (and other things)
    • sort - sort input and print to output: sort file.txt ; ... | sort
    • cut - chop out parts of lines: cut -d: -f2,4-6
    • vim - text editor (exit with :w and :q - may need to hit escape first. i to insert, escape to leave insert mode)
    • nano - text editor (exit with Ctrl-X. Just type)
  • Redirection operators:
    • cmd > /file/path - put the output of cmd into the file /file/path
    • cmd < /file/path - give the contents of /file/path to cmd as its input (as though typed at the keyboard)
    • cmd1 arg1... | cmd2 arg2... - give the output of cmd1 arg1... to cmd2 arg2... as its input
    • cmd >> /file/path - append the output of cmd to the file /file/path
  • Files, paths, and directories
    • File names and paths can be written directly in commands
    • The top-level directory is called /
    • Directories and files in a path are separated with /
    • If a path doesn't start with /, the file is looked for starting in the "current directory" (which you change with cd)
    • . is a name that explicitly means the current directory
    • .. means the parent directory, the one outside the one you're otherwise talking about
    • Filename expansion
      • * expands to all the files in the current directory, as though you wrote them in the command
      • *.txt expands to all .txt files
      • abc*.txt expands to all files whose names start with abc and end with .txt
      • /tmp/*/*.log expands to all files whose names end in .log that are inside directories inside the /tmp directory
  • Control operators:
    • cmd1 && cmd2 - run cmd2 only if cmd1 succeeds; the whole thing succeeds if cmd2 does
    • cmd1 || cmd2 - run cmd2 only if cmd1 fails; the whole thing succeeds if either cmd1 or cmd2 does
    • cmd1 ; cmd2 - run cmd1, and then run cmd2 afterwards
    • cmd1 & - run cmd1 in the background and run the next command immediately * Use wait to wait for a background command to finish

Useful resources:

Haskell, a functional programming language

  • Installing:
    • Windows: sudo apt update ; sudo apt install haskell-platform swi-prolog ; sudo apt install ghc
    • Mac: brew update ; brew install haskell-stack swi-prolog ; brew install ghc
  • Running:
    • Run ghci for an interactive interpreter
    • ghci file.hs to load functions from a file

Wednesday: Python

  • Python documentation
  • Download Python - you probably won't need to do this, because you will already have at least one version of Python installed. The linked download will include the IDLE Python IDE if you want to use that
  • It is also available in the Windows Store
  • You can edit your Python code with IDLE, Eclipse, Visual Studio, Visual Studio Code, nano, vim, Notepad, ..., entirely at your preference, and the first four at least will offer you running and debugging support too.

Thursday: ...

Assignment: Comparing languages

Implement the same program in two different languages we have covered. Afterwards, you write a brief report (approximately one page) comparing and contrasting the languages, your experience with each, and the strengths, weaknesses, and roles that you thought suitable to each, and reflecting on your experience using them. Your program can be anything non-trivial within reason. If you're stuck for ideas, there is a suggestion below, but any reasonable program that makes use of appropriate data structures and language features is sufficient.

The report should discuss how you found using the languages for the task, and any parts of the task or language that you found a good or a poor match. What sorts of tasks might each language be suited for, based on your experience using both? Were some elements easier or harder? Consider what you would take away to inform your future choices of language when you have a new problem to solve, and when you might choose one over the other.

Suggestion: Contact List

You can make any non-trivial program you like, but if you're stuck for ideas then this structure will make sense:

Make a program (or programs) that allows the user to maintain a simple contact list, where each contact may have different information associated with them (names, phone numbers, email addresses, etc). Contacts can be added and removed, updated, and searched.

Your program(s) may be interactive or have a command-line interface, and may use either text or a GUI. Data may be stored in any fashion you find appropriate.

It is not expected that your program be large, nor necessarily be complete . Focus on the key structural and language elements first, and consider the user interaction and data storage and retrieval afterwards. It is not an issue if one or other of these is omitted, partial, or mocked up, provided that the rest of the program makes sense. You may wish to reflect on why certain parts were omitted from your implementation.

To submit

  • Both of your implementations of the task.
  • A brief report comparing and contrasting the languages used as applied to the task and reflecting on the experience.
Submit your code and report in the submission system by 23:59 Sunday.
Topic attachments
I Attachment Action Size Date Who Comment
Program.cscs Program.cs manage 4 K 11 Jan 2021 - 13:40 Main.mwh  
sample.hshs sample.hs manage 1 K 12 Jan 2021 - 14:29 Main.mwh  
todo.py.txttxt todo.py.txt manage 2 K 13 Jan 2021 - 13:37 Main.mwh