-
Notifications
You must be signed in to change notification settings - Fork 3
Topaz : Getting Started
The easiest way to take a quick look at Topaz is to visit [Try Topaz] (http://www.colellachiara.com/soft/topaz/try-topaz.html) and try some simple Topaz out.
print "Hello, World"
(What else did you expect.)
You can also compile code with Topaz. At the moment Try Topaz generates JavaScript, in the future Topaz will be capable of generating code in other languages.
Enter the following into the Try Topaz console:
compile [i: 0 while [i < 10] [i: i + 1]]
The JavaScript produced by Topaz will be displayed.
####Ubuntu In order to install Topaz on Ubuntu you first need to install node.js and the rlwrap unix utility. The lazy way is to:
-
Open the Ubuntu Software Centre
-
Search for rlwrap
-
Mouse over the response for rlwrap and click install
-
Search for node.js
-
Mouse over the response for node.js and click install
####OS X There are a number of pre-requisites for installing Topaz under OS X. Currently, you need node.js to run Topaz. If you want to use the supplied make files, you will also need two unix utilities, rlwrap and wget, in order to build Topaz. Though you might find rlwrap very useful anyway.
The easiest way to install node.js and the npm package manager is to download the Mac package from [the Node download page] (http://nodejs.org/#download).
The package installs both node and npm in the /usr/local/bin folder for ready use.
Probably, the easiest way to get rlwrap and wget them is by using [HomeBrew] (http://mxcl.github.com/homebrew/) the new package manager for OS X.
Assuming you are using Homebrew, installing rlwrap and wget is just a matter of:
brew install rlwrap
brew install wget
####Windows There is now a native Windows version of node.js. It can be obtained as a self-installing file from [the Node download page] (http://nodejs.org/#download).
###Getting Topaz Source You can either simply download an archive of the source from [The Project-SnowBall GitHub Page] (https://github.com/giesse/Project-SnowBall) or, if you have it, use git to clone the repository:
git clone git@github.com:giesse/Project-Snowball.git
Windows Note: there is currently an issue when running compile-topaz.topaz, a few paragraphs down, if source is cloned using a git with default Windows line ending handling. Use *nix style line endings or use Cygwin's git to pull down the source.
###Making Topaz
Note: At the moment Node will display the following informatory message:
The "sys" module is now called "util". It should have a similar interface.
Whilst it is a little annoying, it does not affect topaz and should not be visible in future versions of Topaz.
####Ubuntu & OS X via supplied Makefile There is a Makefile for Topaz in the main Project-Snowball directory. In it node.js is referred to as nodejs whereas it is more often created as simply node. The easiest thing to do is to edit the first two lines of the Makefile from
NODE = nodejs
NODEINT = rlwrap nodejs
to
NODE = node
NODEINT = rlwrap node
Then you simply make Topaz (from the Project-SnowBall directory):
TM:Project-SnowBall topaz-user$ make
You should see output like this:
wget -O topaz/bootstrap.js http://www.colellachiara.com/soft/topaz/bootstrap.js
--2011-06-26 22:44:28-- http://www.colellachiara.com/soft/topaz/bootstrap.js
Resolving www.colellachiara.com... 97.107.140.5
Connecting to www.colellachiara.com|97.107.140.5|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 53477 (52K) [application/javascript]
Saving to: `topaz/bootstrap.js'
100%[======================================>] 53,477 34.4K/s in 1.5s
2011-06-26 22:44:30 (34.4 KB/s) - `topaz/bootstrap.js' saved [53477/53477]
node topaz/bootstrap.js topaz/compile.topaz
####Windows, OS X & Ubuntu not using the Makefile It is much easier to make Topaz manually on Windows rather than download Windows version of the tools used to make Topaz and edit the Makefile. OS X and Ubuntu users may also prefer this approach to editing the supplied Makefile.
The first thing to do is fetch the bootstrap.js file from [here] (http://www.colellachiara.com/soft/topaz/bootstrap.js) and save it in the Project-SnowBall/topaz/ directory.
Then run the following command from the Project-SnowBall directory:
Project-SnowBall>node topaz/bootstrap.js topaz/compile-topaz.topaz
###Checking Topaz is working
You can run the Topaz tests either by using the Makefile
Project-SnowBall>make tests
or with the following command
Project-SnowBall>node topaz/topaz.js topaz/tests/run.topaz
You can test your application with a simple Hello World
Run your test from the Project-Snowball directory:
Project-SnowBall>rlwrap node topaz/topaz.js ;; OS X & Ubuntu
or
Project-SnowBall>node topaz/topaz.js ;; Windows
You will then be presented with the Topaz "console":
Topaz Interpreter - (C) 2011 Gabriele Santilli - MIT License
>> print "hello world" ;; Windows Note - this fails if running in the Cygwin terminal.
hello world
== "hello world"
>> quit 0