Language Implementations for CS 152

The languages used for programming assignments in CS 152, Fall 2003, will be Java, C++, Scheme (a dialect of Lisp), and your choice of Ada, Haskell, or Prolog. You might want to experiment with the languages that you do not choose for this last assignment, since they will be covered to some extent in the lecture and on exams.

These languages are available as follows:

Through department facilities

The department maintains microcomputer labs for student use in WSQ 1 and MH 226. For regular access to the department computing facilities, you need to register for 1 unit of CS 110L, or sign up for access at the department office, MH 208. This latter option requires a $45 fee. In either case, you get access to Windows 2000, to Unix machines, and to the World Wide Web and thus to the class web site, whose URL is given on the class green sheet. Through department facilities you will have access to Windows versions of Visual C/C++, Eclipse and perhaps BlueJ for Java, and Dr. Scheme. Implementation of Haskell and Prolog should be available. Ada may be available later in the semester.

From non-department sources

Public domain Windows implementations of the languages to be used in this class are available as follows:

Java
The BlueJ implementation of Java is available at http://www.bluej.org/. The Eclipse implementation is available at http://www.eclipse.org/. The Eclipse download is about 64MB; the BlueJ download is about 1 MB. As you might suspect, BlueJ is easier to use, but not as full-featured. In particular, the BlueJ debugger is missing some useful but nonessential features. With this in mind, either of these two implementations should be satisfactory for this course. Note that in both cases you will need to download the Java IDE separately if you don't already have it. Both download sites give assistance on how to do this.

BlueJ has a decent tutorial, while Eclipse has massive assistance available from its Help menu. A very brief introduction to BlueJ (and to other public-domain IDEs) can be found at http://www.cs.sjsu.edu/faculty/smithj/oldclass/146s03/javaimpls.html.

Scheme
The Dr. Scheme version of Scheme is available at http://download.plt-scheme.org/drscheme/. I recommend installing it in the C:\Program Files\plt folder, in which case the excecutable version will be at C:\Program Files\plt\DrScheme.exe. The download is 5.3MB; about 35MB is required for the installed version. You needn't download the documentation separately; the tour of Scheme, the environment manual, the language reference manual, and the Revised(5) Report are all available from the Help|HelpDesk menu in the implementation above. Of these reference manuals, the "Revised (5) Report" is probably most useful. The PLT MzScheme language manual may be of some use in this class.

The "How to Design Programs" text available on this site (under Learning) is designed for liberal arts students. The tutorial "Teach Yourself Scheme in Fixnum Days" is somewhat better for CS students. Another more useful tutorial is available at http://www.cs.utexas.edu/users/wilson/schintro/schintro_toc.html.

When you first use the Dr. Scheme implementation, you will be asked which version of the language to use -- choose first PLT, and then Graphical.

C++
C and C++ are available at http://www.delorie.com/djgpp/zip-picker.html. Make sure to select the correct operating system, to ask for the RHIDE IDE, and to select C++. Otherwise the default choices will be ok. If you use RHIDE, you might want to enable the show user screen after exit option in the Options|Environment|Preferences menu.

When you unzip the files, it's safest to use the unzip32.exe program provided with the implementation. Otherwise you may run into trouble with long filenames (the implementation is fairly old).

See also the section below on updating your environment variables.

Haskell
A web site for Haskell is www.haskell.org. The Hugs for Haskell interpreter, which has a simple IDE is available at http://cvs.haskell.org/Hugs/downloads/Nov2002/hugs98-Nov2002.msi. I recommend installing it at C:\Program Files\Hugs98\winhugs.exe, in which case the executable will be at C:\Program Files\Hugs98\winhugs.exe

Links to two tutorials, one short and one long, are given on Prof. Louden's Programming Resource page at http://www.cs.sjsu.edu/faculty/louden/pltext/resources.htm

Prolog
An implementation of SWI Prolog is available at: http://www.swi-prolog.org/. Download the IDE (SWI-Prolog-Editor) separately from the implementation itself. The SWI Prolog Editor web page lists two manuals that are worth downloading (note that extraction will create new folders with the proper names). Also note that in the IDE, it is the Start|Consult that you use to load your edited program file into the interpreter.

See also the section below on updating your environment variables.

Ada
Ada-95 for many platforms is available from http://www.seas.gwu.edu/~mfeldman/ez2load.html.
You should download at least README.310, ginstall.exe, install.scr, unzip.exe, and the first 6 zip files, and look at the first of these for instructions. You might want to download the "postmortem debugger" ad.zip, although this is not a debugger in the modern sense. Finally, you may also want to download the documentation separately.

This implementation is rather old. I was able to install it successfully for Windows 2000, but not for Windows XP. As with C++, it's safest to download the given unzip32.exe program. Then you can complete the installation by executing the ginstall program, and updating the environment variables as described below.

The AdaCAPS environment that is included in these files is probably sufficient for this class; it will also be familiar if you've used the RHIDE environment for C++. To start AdaCAPS, execute gw-gnat\adacaps.exe, where the address is relative to the folder into which you installed Ada. Before loading your file, you should change your directory (using the File menu) to the folder in which your Ada progrm is located. To build your Ada program, load and select the top-level file and select Build from the L/C/R menu. You may compile a single file by seelcting Compile from this menu.

I was unable to install the AdaIDE environment quite correctly for either Windows 2000 or Windows NT, even after copying all the files from DISK2 to DISK1 and installing from DISK1. Note that AdaIDE has a separate installation procedure.

Even if you do use an IDE for Ada, there may be times when it's more convenient to use the command line interface. To build the file filename.adb, type

gnatmake filename.adb
This creates an executable which can be run simply by typing
filename
Recall that the output of this execution can be redirected to a file of your choosing, e.g., by
filename > outputfile
A single file can be compiled by typing
gcompile myfile.adb
Environment variables
For C++, Prolog, and Ada, you will need to modify your environment variables in order to use the IDE. The mechanism for doing this varies with different versions of Windows, so you might need to ask about "environment" in version's Help facility (the README.1ST file in the C++ download describes how to do this for some earlier versions of Windows). The batch files given with the Ada download will not work for later versions of Windows.

For Prolog, you need only create an environment variable PLTERM_CLASS with value RlcConsole.

For C++, assuming that you installed into the folder C:DJGPP, you will need to add C:\DJGPP\BIN; to the beginning of the value of the PATH variable. You will also need to define a new DJGPP variable with value C:\DJGPP\DJGPP.ENV.

For Ada, you will need to add C:\GNAT310\GW-GNAT;C:\GNAT310\BIN to the beginning of the value of the PATH variable, and make sure that the five other environment variables in the other five set statements in the file gnat310.bat are set or created to have the given values. Note that both C++ and Ada use a DJGPP variable, so you may need to reset its value when you switch between these languages.

Problems with installation
If there is a problem with your installation, the chances are excellent that it's related to the improper settings of your environment variables. Another possible source of error in installation is simply that you did not download all of the appropriate files.

In Ada, I encountered an occasional error regarding writing to a particular memory address. Usually retrying the command once or twice worked fine, although it is annoying to have the IDE crash as well.

If you are interested in using any of the public domain implementations, please download and install them early, so that you have time to deal with any installation problems that may arise. In the worst case, you may need to use department facilities even though you hadn't originally planned to.

From other sources

If you have language implementations available at home, at work, or elsewhere for any of these languages, it's probably ok to use them. The differences between various versions of a language are unlikely to be important for our simple assignments. The one exception is Scheme -- I do ask that you use Dr. Scheme.

Debugging

I strongly recommend that you get used to using debuggers for dealing with run-time errors, if you're not already. In particular, for Java I don't recommend the use of Textpad, or JDK by itself. If you're new to debugging, you might want to start with the BlueJ implementation, since both it and its debugger are easy to use and have helpful tutorials. Then if you feel you need more functionality (such as Run to Cursor or Step Return) in the debugger, you can switch to Eclipse. Visual C++ has debugging functionality similar to Eclipse.

For Ada, the DOS-based AD debugger is of some use for finding the source of run-time errors after they happen (thus the "post-mortem" tag). The ad.htm web page included with the download describes how to use it.

The recommended implementations of Scheme, Prolog, and Haskell have diverse mechanisms for "tracing" that are useful for debugging. In Scheme, tracing provides a record of calls to, and returns and return values of, selected functions. In Prolog, tracing may be used to step into or over invocation of predicates in queries, much as in Java debuggers. In Haskell, the Trace package allows an I/O function to return a value, which is somewhat slicker than inserting I/O functions directly into the code. A short description of tracing in SWI-Prolog is given in Section 2.9 of the manual (select Content from the Help menu to see the manual's table of contents). There is a longer description in the Clocksin & Mellish text.

Other links

Several other useful links, including links to tutorials, are maintained by Prof. Louden at http://www.cs.sjsu.edu/faculty/louden/pltext/resources.htm