This guide is to help you get used to using the ML interpreter for your homework assignments. First I'll give some general advice on the easiest way to work. Then I'll explain what you need to know or do depending on where you choose to work-- both what platform you prefer and whether you want to work in the lab or on your own computer.
In addition to "ML", you will sometimes see the name "SML." The "S" is for "Standard," so this indicates a particular variety of ML. Since SML is the version of ML we're using, "SML" and "ML" are synonymous for our purposes. You also may see "SMLNJ" or "SML/NJ", which stands for "Standard ML of New Jersey." This refers to the implementation of SML that we're using. It was developed (initially) at Princeton University and Bell Labs---since both of those are in New Jersey, that's how the software got its name.
Since you will usually need to make corrections to your code as you go along, and since you will always want to turn in your completed code, you will want to have two windows open. First, you need the ML interpreter window; second, you should have a text editor window. Use the text editor to write the code. When you think it's right, copy and paste it into the ML interpreter. If you get an error, then make some corrections in the text editor and try again. Use the text editor to save your work to a file. Then, for each problem, go to the turn-in site and submit.
You can do your work either in the computer science lab (SCI 154), one of the math project rooms (SCI 168 and SCI 182), or your own computer. The advantage of working in the CS lab is that you can learn from your classmates who are there working with you (that would require you to learn to use Ubuntu, the operating system the CS lab machines run... it's not too hard, though.)
In the CS lab
If you already are familiar with the CS lab (from taking Programming I or Programming II, for example), then this should be your favorite place to work. Everyone else is welcome to work there, too---in fact, encouraged to do so because that's where you can get help from others working on the same problems.
The CS lab machines use an operating system called CentOS (a distribution of Linux). If you haven't used a system like that before, your best bet is to find a friend who has and ask that person to give you a quick tour. It isn't too hard to learn it well enough to be able to do all you need for this course.
In the math project rooms
The math department has a couple of "project rooms" that can be used as computer labs. The computers in SCI 182 and SCI 168 are running Windows 7 and they have ML installed. You can find it under All Programs -> SML of New Jersey.
At home.
You can install the ML interpreter on your own computer. SML/NJ is freely available for download for Linux/Unix, Macintosh, and Windows. See www.smlnj.org for the software homepage or http://www.smlnj.org/dist/working/110.82/index.html for the downloads page.
If you are downloading it to use on a Mac, you can get the installer here. You will need to run sml through the terminal, which you can find under Applications->Utilities->Terminal (you'll probably want to add Terminal to your dock for the semester). However, there may be one last step you need to do after it installs to make sml convenient to use. Details:
The installer will put the binary for sml some place that is not in your path. The latest version I've used installs sml to/usr/local/smlnj/bin
. Once the installer finishes, you can confirm that it works by running the interpreter as/usr/local/smlnj/bin/sml
. If that works, then the final step is to change yourPATH
environment variable to include that bin folder. Open the file.bash_profile
in your home folder (or make that file if it doesn't exist) and include the lineexport PATH="$PATH:/usr/local/smlnj/bin/"
Save the file and open a new terminal window. You now should be able to start the interpreter with justsml
.
If you don't know what those details meant, then stop by my office and it will take me around 30 seconds to fix up your computer.
If you are downloading it to use on a MS Windows machine, you can use the installer found at http://smlnj.cs.uchicago.edu/dist/working/110.82/smlnj-110.82.msi
If you want to use ML on your own computer but for whatever reason
don't want to go through the hassle of installing it, there
is yet another (pretty simple) option:
You can ssh
(remotely login) to one of the
computers in the lab machine and run the interpreter that way.
It won't feel much different from having the interpreter running
on your machine.
See below, "Virtual logon to the lab."
Linux and other UNIX. GEdit and Xemacs have modes for a language called Objective CaML, which is related to ML. These should help you make your ML programs nice and pretty. Don't forget that to copy and paste, all you need to do is highlight the text and then middle-click into the window where you want to paste.
Macintosh. If you're not familiar with "text editors", it just refers to a program that's similar to a word processor, but a lot simpler. The standard one that comes with MacOS is called "TextEdit", and you should find it under "Applications" on your computer. Copying and pasting between the two programs shouldn't be too hard---it's a Mac, after all.
Windows. The standard text editor in Windows is NotePad. Copying and pasting between NotePad and SML is a bit tricky: Highlight in NotePad and copy it as you normally would (either from the Edit menu or using shortcut keys); then right-click in the ML window and select "paste." If you ever need to copy and paste from the interpreter to NotePad, then right-click in the interpreter window and select "mark"; drag over the code you want to copy; press enter; and then paste into NotePad.
If you would like to work on your own computer but are unable to install the software, one solution is to logon to the lab from your computer.
Macintosh. On a Mac, you can log into the machines in the cslab using a program called "ssh" from the Terminal window. You can find the Terminal under Finder->Applications->Utilities->Terminal. If you find that you prefer working this way, you'll probably want to put a shortcut to Terminal in your dock. If you are on campus, then you can log into a cslab machine by typing "ssh (your id)@(name of cslab machine)". The machines in the cslab are named "cslab01" through "cslab25". You may use any of them. For example:
ssh tvandrun@cslab05
The first time you do this you'll get warning about "Permanently added the RSA host blah blah blah." Don't worry about that.
Once you are on a lab machine, you can run the ML interpreter by just typing "sml", as you would if you were in the lab.
If you are doing this off campus, this will take two steps. Do as you did before except give the machine names as "csgate.wheaton.edu". For example
ssh tvandrun@csgate.wheaton.edu
Once you are on csgate, then ssh from there to one of the lab machines as before.
Windows. To logon to the lab machines, use a program called Putty, which you can download from here. From on campus, use Putty to log onto any of the cslab machines (cslab01 through cslab25). Once there, you can run the ML interpreter by just typing "sml", as you would if you were in the lab.
From off campus, first use Putty to log onto csgate.wheaton.edu. Then from csgate.wheaton.edu ssh to one of the other lab machines, for example
ssh cslab05