The iframe on this page is empty and contains no contentSkip to content
People

Department of Computing

# MCS Programming Laboratory Welcome to the laboratory programme for the MSc in Computing Science course at Imperial. Here you'll find introductory information on the languages you will be using, as well as primers for some of the various editors you might want to use. In addition, this page will be updated with information about online tests and any corrections/clarifications that might arise from the lab exercises. ## Getting Started The following resources from the department will help you get started using the computers in the labs: Lab Information Pack An Introduction To Unix (Dr. Will Knottenbelt) Linux and Unix user guide (CSG) Windows user guide (CSG) You can also find more information on using linux and unix systems by following the external links below: A Unix tutorial for beginners Getting started with Linux An online Linux book Introduction to SSH ## Lab Exercise Schedule The table below outlines the laboratory exercise schedule. For the most up-to-date information, however, please refer to CATE.
Week | Issued | Due | Supported in Lab
--- | --- | --- | ---
1 |  |  | C++ Intro
2 | C++ 1 |  | C++ Intro
3 |  |  | C++ 1
4 |  | C++ 1 | C++ 1
5 | C++ 2 |  | C++ 2
6 |  |  | C++ 2
7 | Minix | C++ 2 | C++ 2, Minix
8 | C++ 3 |  | C++ 3, Minix
9 | Prolog, Assembler |  | C++ 3, Minix, Prolog, Assembler
10 |  |  | C++ 3, Minix, Prolog, Assembler
11 |  | C++ 3, Prolog Minix, Assembler | C++ 3, Minix, Prolog, Assembler
## Electronic Coursework Submission You will be using the CATE system throughout the year to obtain information about the various assessed exercises and more importantly to submit your work electronically or to retrieve cover pages for hardcopy submissions. Access to CATE is done by authentication i.e. you must type your login and password when prompted for. In the timetables section, the “Autumn Term” is already pre-selected, just click on the button “View” and the timetable for the Autumn Term will be presented to you. Locate the relevant module and within it, the white coloured box labelled with the name of the exercise. Click on the icon “D” (for data supplied). You'll be presented with a page that contains the specification for this exercise and, further down, the data files, if any. To submit click on the “H” icon ## Programming Language Resources You will learn a number of programming languages on the course. Below, you can find some useful resources to support your learning. ### C++ The introductory lecture notes and exercises C++ FAQ The C++ Resources Network The Boost Libraries Quick C++ tutorial for programmers who already know C While the 'make' tool is standalone, and can be used to compile programs written in all sorts of languages, you will use it mostly when writing C++ programs. The GNU make manual A good make tutorial ### Prolog An introduction to Sicstus Prolog, and the provided file that it refers to. Sicstus Homepage CSG Sicstus Resources ### Assembly Language Computer Architecture course webpage (Prof. Kin Leung) A386/D386 home page ### Java Oracle's New To Java Programming webpage The official Java documentation page ## Text Editors It's a good idea to spend some time picking a text editor that you like, as being familiar with your tools can save an enormous amount of time and effort. Here are some common Linux editors you might like to try. Don't worry if you're not a Linux command-line guru; you don't have to memorise a million keyboard shortcuts to speed up your work (although learning a few might not hurt). Broadly speaking, editors come in two types; graphical editors and text-mode ones. The former (unsurprisingly) appear in a graphical window on your desktop, while the latter run directly in your console (i.e. they fill the window your command prompt was showing in). While text-mode may sound a bit primitive, it does have some benefits, particularly when remotely connecting to department machines over the internet. And if you think it still sounds bad, you don't want to know what people used before there was text-mode. It's a good idea to have a passing familiarity with at least one text-mode editor, because you will almost certainly at some point find yourself needing to edit a text file without full access to a GUI. There are many horr ible ways to experience vi for the first time (some would say they are all horrible), but without question the very worst is when dialling in to a college computer to try and fix the typo you just noticed in your project, five minutes before the submission deadline expires. Here are some common editors, all found on the standard department Linux installation. Give them a try, and see which you like best. ### Emacs GNU Emacs is a much more complex graphical editor, but almost infinitely customisable. It has editing modes for every programming language you've ever heard of, plus most of the ones you haven't. These can be very useful, as the better ones are sufficiently intelligent that if you spot them highlighting or indenting something in a way that doesn't seem right, it's often a sign that you've made a mistake (catches a lot of missing semicolons, this). Its command system is based heavily around “chords”, i.e. combined keypresses like ctrl-C. It takes this to rather more complex levels than you'll have seen before, though. For example, C-w means “hold Ctrl and press w” (so far, so simple). C-x s means “hold Ctrl, press x, then let go of Ctrl and press s”. C-x C-c means “hold Ctrl, press x then c and let go of Ctrl”. Here are some common commands to get you started:
C-x s | save file
C-x C-w | save as… (you will be prompted for a filename)
C-x C-b | see a list of currently open files (or “buffers” in emacs-speak)
C-x C-c | quit
C-space | sets the “mark” (see below)
C-w | cut, or “wipe”. Deletes highlighted text and keeps it in a temporary buffer.
C-y | paste, or “yank” (as in, “yank the text from the temporary buffer and put it here.”)
C-g | exit command. Very useful if you've got yourself into a mess with other commands, and want to start again.
The “mark” mentioned above is how you highlight text without using the mouse. Rather than holding shift and using the arrow keys as in many graphical editors, you use C-space to set a mark, then move the cursor; text between the cursor and mark will be highlighted, and can then be manipulated with other commands. Here are some proper references should you decide you like Emacs and want to learn it properly: A quick guide to Emacs commands Emacs tutorial at linuxhelp Emacs FAQ at gnu.org Prolog Mode: Emacs can be used as a fairly full-featured IDE for Prolog, by enabling the Prolog mode. To do this you'll need to edit the .emacs file in your home directory (create one if it doesn't already exist). Full instructions on how to do this can be found at the Sicstus website. The Prolog mode enables syntax highlighting, hooks to run sicstus within emacs and some basic editing shortcuts. These features will be enabled by default for the Lexis tests. ### NEdit NEdit is a relatively simple window-based editor that will be familiar to anyone who's used the more common editors for Windows (the basic keyboard shortcuts are very Windows-y). It has some basic syntax highlighting for things like C and C++, a tabbed user interface for multiple files, and a macro recording and editing facility. It doesn't have Prolog syntax highlighting as standard, though. There's a patch you can download, but it's not particularly sophisticated. The NEdit online manual ### Vi vi is a text-mode editor, and if you've not come across it before, has a rather steep learning curve. It's referred to as a “modal” editor, because it operates in two modes - “insert” and “command”. In command mode, your keystrokes are interpreted as commands to the editor itself, while in insert mode the text you type becomes part of the document. This is why if you open a file and try to start typing, nothing happens; you're in command mode. The idea of this is to cut down on the chord-style commands found in Emacs and the like, which some people believe can cause RSI. vi is far too powerful to helpfully describe here, so here are just a couple of commands to get you started. Remember you must be in command mode for these to work - press escape a couple of times if you're not sure.
a | enter insert mode (inserts after cursor)
i | enter insert mode (inserts before cursor)
escape | exit insert mode (returns to command mode)
:w | write file to disk (the colon is important)
:q | quit (will give an error if unsaved changes exist)
:wq | save and quit all at once
:q! | quit without saving
That's enough for now; should you want to know more, these links contain much more information (particularly “Learning the vi editor”): A vi command summary sheet Learning the vi editor Why, oh WHY, do those #?@! nutheads use vi? (a bit evangelistic) ### Pico Pico is a much (much) friendlier text-mode editor, having a list of common commands at the bottom of the screen, and only one mode to remember. However, it doesn't really have any of the features you'll need for heavy programming use, having been initially designed as an editor for writing emails. Handy for some very light editing when you don't have a graphical terminal, though. Pico quick reference

- Print
- Email to a Friend
- Report incorrect content

## Email to a Friend

### Page URL:

### Your Information:

Your Name Your Email

### Friend’s Information:

Friend’s Name Friend’s Email
Close