CS 313 - Installation instructions
As the semester progresses, I will add instructions for installing each of the CS 313 compilers/interpreters for Mac and Windows:
Pascal
We will use "fpc", the Free Pascal Compiler
Mac
- download the Mac OS installer from soureforge (wait for 5 seconds, don’t click on another link)
- Open the "fpc-3.2.2.intelarm64-macosx.dmg" disk image file.
- Run the .pkg file inside the disk image by right-clicking on it and choosing "Open".
- Note the requirements for installing the Pascal compiler (you need to have Xcode or command line tools installed – they provide instructions on the opening screen of the installer if you don’t know whether you have either installed). Once you have Xcode or command line tools installed, click "Continue".
- Continue the installation with all the default options.
- To verify the install worked, open terminal and type "fpc", and the Free Pascal Compiler should run.
Windows
- download the Windows installer from soureforge (wait for 5 seconds, don’t click on another link)
- Run the executable once it downloads
- When the install wizard opens, follow the instructions
- Use all the default options and "Full Installation"
- To test a successful install, open a command prompt or PowerShell and type "fpc", and the Free Pascal Compiler should run.
basin
- fpc is installed on basin, so you can also develop and compile your code there.
Here’s a sample program to test your installation: hello.p
Save this file, navigate to it in your terminal, and type "fpc hello.p".
This should result in an executable "hello" that you can run.
C
We will use "gcc", the GNU C Compiler.
Mac
- On Macs "gcc" actually refers to the C compiler clang, which is fine. See if it’s already installed:
gcc --version
- If it prints "Apple clang version …" you are all set. If it can’t find gcc, try installing the xcode command-line tools:
xcode-select --install
Windows
Install the Windows package manager Chocolatey by following the installation instructions. This will involve running Powershell with administrator privileges.
Once Chocolatey is installed, install the MinGW version of gcc from the Powershell:
choco install mingw
You should now be able to compile C programs, and also to run Makefiles via "make".
Type gcc --version and make sure it says "gcc.exe (MinGW …)"; the version number should be 11 or higher.
Note: if you don’t see the MinGW version or you get an error, it might be caused by an older GCC version installed during the Free Pascal installation. See here for the fix.
basin
- gcc is installed on basin, so you can also develop and compile your code there.
Here’s a sample program to test your installation: hello.c
Save this file, navigate to it in your terminal, and type "gcc -o hello hello.c".
This should result in an executable "hello" that you can run.
Smalltalk
We will use Squeak, an integrated development environment for Smalltalk. You can download Squeak via the buttons near the top of the main Squeak page.
Mac
- Click on the "macOS" button.
- Extract the zip file once it downloads. This should create a Squeak
.app file - Drag and drop the .app file into your applications folder and you should be all set.
Windows
- Click on the "Windows" button.
- Extract the zip file when it finishes downloading.
- If you want, rename and/or move the folder to a convenient location.
- Inside the extracted folder will be a Squeak application; double-click it to run Squeak.
basin / Linux
- We can’t use basin, since Squeak uses a GUI which we can’t run remotely. However, if you happen to run Linux on your computer you can download the Linux version.
If you start Squeak you should get an environment with a few windows open. See Lecture 10 for a quick intro.
If you want to get a head start, check out Squeak by Example. (See if you can figure out to make it print Hello World! :)
Ruby
We are only taking a brief look at Ruby, so installing it is optional. (You can also run Ruby in your browser.)
To install Ruby on your computer:
Mac
- Ruby should already be installed. Type ruby -v to see what version you have. Type irb to get an interactive Ruby prompt.
- You can install the latest version using Homebrew via the command brew install ruby
Windows
- You can install Ruby via Chocolatey.
- If you have cygwin, just install the "ruby" package. Test it by typing irb.
- There is also RubyInstaller for Windows but I haven’t tried it.
basin / Linux
- Ruby is installed on basin. Type irb.
Scheme
We will use DrRacket to program in Scheme. More precisely we will program in Racket, which was derived from Scheme and supports several different language flavors. We will stick with the basic Racket language, however, which only has minor differences to Scheme.
To install DrRacket, go to the Racket download page and follow the instructions, which should work for both Mac and PC. Use the default settings – Distribution: Racket and Variant: Regular. This will take a fair bit of space, about 500MB… If you are low on disk space you can try the "Minimal Racket" distribution but this will likely require additional steps to download packages which I haven’t tried.
Once installed, be sure to start the DrRacket app (not Racket or GRacket). You should get a window with two panes. The top pane is for "Definitions", i.e., it’s the editor where you will be defining your functions. The bottom pane is for "Interactions", where you see printed output and also get an interactive prompt.
The first time you start DrRacket, click on "Choose Language" at the bottom and select the first option, "The Racket Language". This will put the line
#lang racket
at the top of your Definitions, which always needs to be the first line in any of your Scheme programs.
Underneath this line, try typing
(display "hello world")
and click on Run at the top. You should see the output in the bottom pane. Next, try typing an expression like
(+ 3 4)
at the interactive prompt in the bottom pane.
You’re ready to go!
Note: when saving your code (from the top pane), use the default extension .rkt. Make sure you don’t have any special characters (like fractions, images, or lambda) in you file, otherwise it will not save your code in plaintext.
basin
- Racket, an interactive command-line tool, is installed on basin. (The IDE DrRacket is not available.) To interact with Racket on the command line, type "racket".
ML
We will use "SML/NJ", Standard ML of New Jersey
Mac
- Installation via Homebrew is easiest. Check if you already have brew installed by typing "brew". If it says "Command not found", install brew by running the following command in the MacOS Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- Once brew is installed, install SML/NJ by typing
brew cask install smlnj
- Since it will installed in a non-standard location (/usr/local/smlnj/), create a symbolic link in /usr/local/bin/. To do so, run the following command in a terminal:
sudo ln -s /usr/local/smlnj/bin/sml /usr/local/bin/sml
- Also install rlwrap, a "command-line wrapper" which lets you use the arrow keys to access previous commands and edit the current command, by typing
brew install rlwrap
To run ML, type "sml". Better yet, type "rlwrap sml" so you can use the arrow keys.
Type "3+4;" at the prompt to test it. To quit, type Control-D.
Windows
Download the Windows installer from the SML/NJ page. Here’s a direct link to smlnj-110.99.2.msi.
Run the installer. If you get a message "windows protected your PC", click on "More info", then on "Run anyway".
Run the "SML of New Jersey" App from the Windows menu.
Type "3+4;" at the prompt to test it. To quit, type Control-Z followed by Enter.
In order to be able to easily load any .sml files you write, create a shortcut to the SML App as follows:
- create a folder where you will be doing your work, e.g., Desktop\cs313\ml
- use a text editor like Atom or Code to create a file in that folder, e.g., a file "test.sml" containing the line "3+4;"
- search for the SML App in the Windows start menu and click on "Open file location"
- right-click on the "SML of New Jersey" shortcut and select "Copy"
- go to your cs313\ml folder and select "Paste"
- start SML by double-clicking on the new shortcut
- at the SML prompt, type 'use "test.sml";'
- to quit type ^Z followed by Enter
- create a folder where you will be doing your work, e.g., Desktop\cs313\ml
basin
- sml is installed on basin.
If you use Atom as your text editor, you can install the package language-sml.
Prolog
We will use SWI-Prolog
Mac
- Assuming you have homebrew (see instructions for ML above), install swi-prolog as follows:
brew install swi-prolog
To run Prolog, type "swipl".
Type "X is 2+2." at the prompt to test it. To quit, type Control-D.
Windows
Choose the Windows download corresponding to your architecture (most likely the first link: the 64-bit version).
Run the executable once it finishes downloading.
Agree to the license and choose a "typical" installation. Click "Next" and accept the default install location. Then click "Install".
You will find the SWIProlog application in your All Programs list in your Start Menu.
Type "X is 2+2." at the prompt to test it. To quit, type Control-D.
In order to be able to easily load any .pl files you write by double-clicking, do the following:
- save family.pl in a folder where you plan to do your work, e.g. Desktop\cs313\prolog
- double-click on the .pl file
- when asked "How do you want to open this file?", click on "More Apps"
- make sure the box "always use this app" is checked
- scroll all the way down and select "Look for more apps on this PC"
- navigate to This PC -> Local Disk (C:) -> Program Files -> swipl -> bin
- double-click on "swipl-win.exe"
- save family.pl in a folder where you plan to do your work, e.g. Desktop\cs313\prolog
The next time you double-click on a ".pl" file it should now start SWI-Prolog with your file loaded.
basin
- swipl is installed on basin.
If you use Atom as your text editor, you can install the package language-prolog.
To test loading a file, save family.pl in a folder, e.g. cs313/prolog/. On a Mac, navigate to this folder and type "swipl"; on a PC double-click on the file. At the prompt, type "[family]." It should respond "true."
Haskell
You can get Haskell from haskell.org. Try typing Haskell expressions in the purple box right on the main web page!
If you have enough disk space, install the Haskell Platform
Mac
- Follow the instructions to install ghcup and stack
Windows
- Follow the instructions to Chocolatey, and then haskell-dev
basin
- ghc and ghci are installed on basin.
Start the interactive Haskell prompt by typing ghci
.