Working RemotelyYou can do all your work on the department lab machines, but if you want to work remotely on your own computer, you'll need a program that lets you interact with the department server (the same program you'll use in lab):
ssh(which stands for Secure SHell).
- For Windows:
- Download puTTY from
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. The most comprehensive choice is the Installer option on that page. To make windows created on the server work, you will need something called X-windows forwarding. Installing
You'll use puTTY to connect to
homework.cs.tufts.edu(that's the “host name or IP address” you'll be asked about). You can save that so puTTY will connect to that host in the future without your having to type it. You'll want to go to Connection → SSH → X11 and check “Enable X11 Forwarding.” You can also go to Connection → Data and enter your CS login name in the Auto-Login Username field.*
*Thanks to Dalia Berkowitz and Tom Magerlein for the information on the menu selections!
- Download puTTY from
- For GNU Linux/Unix: Open a terminal. On Macs, that's done
using Applications→Utilities→Terminal in the Finder. On a
GNU/Linux machine, you'll have to hunt around and there terminal
application is in different places depending on the distribution.
When you get a terminal, type
usernameis your CS department user name.
In fact, if you want to open up a separate window running emacs or kate, then you'll need to tell the server that it can open windows on your machine. This is almost the same as above:
ssh -X firstname.lastname@example.org
-Xtells homework it can use X-Windows, to communicate with your computer.
http://www.cppreference.com/a very good reference site.
http://www.cs.brown.edu/courses/cs123/resources/c++_mini_course.pdfis a good quick and dirty summary of C++.
http://www.cs.brown.edu/courses/cs123/docs/java_to_cpp.shtmlis a C++ tutorial for Java programmers.
- For you Java types, the Brown folks also have a C minicourse.
- Ben Blais recommends
http://www.cplusplus.com/for generall C++ information, documentation of standard library functions, and examples.
GNU/Linux and EMACS
You might consider installing GNU/Linux on your computer. The Ubuntu distribution is popular, and I have successfully installed it on a laptop with relative ease. Running it in a VM is reasonable. Any flavor of Linux should work for most things, and, for that matter, most code will run under any Unix (such as MacOS, which uses a Unix system descended from BSD Unix).
Larry Greenfield wrote a useful Linux Users' Guide.
Here is a useful Unix/Linux Command Reference (thanks to Margaret Gorguissian for this link).
Norman Matloff has also written Emacs: The Software Engineer's “Swiss Army Knife.” Larry Greenfield wrote a handy GNU Emacs reference card that you can carry around with you. There is also an XEmacs reference card. (Thanks to Karl Schults for sending this link.)
Programming StyleThere are many approaches to programming style. To help you get started, we will provide a Comp 11 C++ Style Guide, which you should follow for your C++ programming assignments.
Formatting code in Emacs
You can set Emacs's indentation style to to various things. At
the moment, I'm using
k&r for C++. For an idividual
editing session, you can type
It will be easier still if you change your
C-c . k&r
.emacsfile to make this apply every time you edit a C file. Here is what I have in my
.emacsfile, and you should add this to your
.emacsfile right away:
(setq c-default-style '((java-mode . "java") (c-mode . "linux") (c++-mode . "k&r") (other . "gnu")))
When you are typing your code and you come to the end of a line,
C-j, rather than a return. If you do this, Emacs
indents the next line automatically according to the indentation
rules. Alternatively, hitting
Tab will indent the
current line according to the current rules. If you have edited a
function and ruined the indentation (or you fear you may have brace
or parenthesis problems), you can indent an entire block by placing
the curser over the opening curly brace of the block and typing
M-C-q. You can also select a region and then type
Search engines like Google have really changed debugging: it is very common now to cut and paste an error message one doesn't understand into a search engine and look it up that way. But that is not enough.
You will benefit by becoming familiar with a proper debugger.
Runtime error messages are generally uninformative, and
sometimes, a flood of print statements won't do the trick.
is the GNU debugger and has a line-oriented interface. It has a
GUI front end called
ddd, which has documentation
available via the web
and in a downloadable PDF document.
Here is a brief
lab with exercises for learning
Think of a debugger as a replacement for the interactive read-eval-print loop in interpreted environments that you may have used in languages like Python, ML, or Scheme.