Racket Start (Install, Setup)

By Xah Lee. Date:
drracket 2015-10-07
DrRacket, the Racket IDE. Top pane for source code. Bottom is REPL.

First, download and install. Just follow instructions. It's easy.

download

download at http://download.racket-lang.org/

install

just run the downloaded thing.

it'll ask you about 3 questions.

on linux, it'll ask you if you want to install in your own directory in one place. Say yes to that.

Here's the terminal session log:

2015-10-05

~/Downloads/xxx43912 $ sh racket-6.2.1-x86_64-linux-ubuntu-precise.sh
This program will extract and install Racket v6.2.1.

Note: the required diskspace for this installation is 474M.

Do you want a Unix-style distribution?
  In this distribution mode files go into different directories according
  to Unix conventions.  A "racket-uninstall" script will be generated
  to be used when you want to remove the installation.  If you say 'no',
  the whole Racket directory is kept in a single installation directory
  (movable and erasable), possibly with external links into it -- this is
  often more convenient, especially if you want to install multiple
  versions or keep it in your home directory.
Enter yes/no (default: no) >

Where do you want to install the "racket" directory tree?
  1 - /usr/racket [default]
  2 - /usr/local/racket
  3 - ~/racket (/home/xah/racket)
  4 - ./racket (here)
  Or enter a different "racket" directory to install in.
> 3

Checking the integrity of the binary archive... ok.
Unpacking into "/home/xah/racket" (Ctrl+C to abort)...
Done.

If you want to install new system links within the "bin", "man"
  and "share/applications" subdirectories of a common directory prefix
  (for example, "/usr/local") then enter the prefix of an existing
  directory that you want to use.  This might overwrite existing symlinks,
  but not files.
(default: skip links) >

Installation complete.
~/Downloads/xxx43912 $

important directories

after install, here are 2 important directories.

the Racket directory path may be at whatever path you specified during install. You can move it to a new path. Do that now.

On linux, you want to add racket binary path to your PATH environment variable.

# add racket path
PATH=$HOME/racket/bin:$PATH

put it in your bash init file. [see Difference Between .bashrc, .profile, .bash_profile, …?]

Important Terminal Commands

you can run

To start REPL, type racket in terminal.

in REPL, try (+ 3 4)

to exit racket REPL, type 【Ctrl+d】 or (exit).

drracket is simple IDE, mostly for beginner programer.

Using Emacs

You can use emacs to code racket. See: Racket: Using Emacs racket-mode.

run racket source file

to run a racket file, do racket file_name

racket file ends in .rkt (and others)

sample racket program

#lang racket
(+ 3 2)

it should start with #lang racket. This is a sugar syntax that expands to (module …) which creates a module (named based on current file name) and other things.

http://docs.racket-lang.org/guide/Module_Syntax.html

create executable

racket can create binary executable.

raco exe src-filename

Learning Racket

Racket documentation is very well organized. You can find it all, at

http://docs.racket-lang.org/index.html

there are 2 main things.

There are also several tutorials. It's all linked above at the doc page.

If you have a question, put $5 at patreon and message me.