Getting Started


A 16.5 minutes walk-through guide, covering:

  • Introduction and prerequisites >>
  • Installation options >>
  • Downloading and installing NSF from source >>
  • Run your first NX and XOTcl 2.0 programs >>
  • Where to obtain further information >>


NFS Overview The Next Scripting Language (NX) is a highly flexible, Tcl based, object oriented scripting language. It is a descendant of XOTcl, providing many additional and improved features. The scripting language NX and the Next Scripting Framework (NSF) extend the basic ideas of XOTcl by providing facilities for language-oriented programming. NSF supports multiple object systems in a single Tcl interpreter. Currently, the most prominent object systems are NX and XOTcl 2.0, but every developer is free to implement their own.

If you have experienced XOTcl in the past, you may want to take a quick look at the main differences between NX and XOTcl here. If you are happy with XOTcl, but want to take your programming skills one step further, we highly recommend our migration guide for NX. There you will learn how to use the new features introduced in NX and combine them with your existing XOTcl scripts. But don't panic: most of the existing XOTcl 1 programs can be used without modification in NSF by using XOTcl 2.0.


Installation options

There are several ways to install NSF.

  • Package managers: You can install Tcl/Tk through your distribution's package manager.
    • Debian (Ubuntu): We actively maintain a Debian and Ubuntu package. Run:
      sudo apt-get install nsf nsf-shells
    • Mac OS X: We also provide a MacPorts port:
      sudo port install nsf
  • Installers & Tclkits:
  • Source: And finally, you can build NSF from its sources. See the prerequisites and the compilation instructions.

What you need!


Not much! You only need to install Tcl/Tk in version 8.5 or higher. In most Linux distributions Tcl/Tk gets shipped right away. For those of you, who haven't installed Tcl/Tk yet, just get it from Alternatively you can do the following:

  • Linux: You can install Tcl/Tk through your distribution's package manager, e.g. for Debian/Ubuntu execute sudo apt-get install tcl tcl-dev. If you are operating another Linux distribution, use your installed update or package manager accordingly.
  • Mac OS X and Windows: An option is to obtain pre-combiled Tcl/Tk binaries for your operating system from, e.g. ActiveState (Linux, too). Here is a direct link to the ActiveTcl Community Edition binaries (they are free, supported by the community, and you most likely don't need more): download page.

One last thing: In order to compile the NSF sources you need a C compiler, of course. Again, in most Linux distributions a C compiler is pre-installed (e.g., gcc). Although there are possibilities to install gcc on other platforms (check their website), you might want to try the off-the-shelf C compilers first: for Mac OS X install Apple's Xcode Developer Tools and for Windows try Microsoft's Visual Studio Express & Community Editions (both are free).

OK, now everything is set for installing NSF - are you excited already?

Download latest: NSF 2.1.0

Download and Installation

Simply fetch the latest NSF package from our download page (or try the direct link on the left) and extract it to a directory of your choice (e.g., /usr/local/src/nsf/). After unpacking, open a shell (Linux), a terminal (Mac), or a command-line interface (MS-DOS or PowerShell on Windows) and switch to the directory you just put NSF in (e.g., cd /usr/local/src/nsf/). The next steps will show how to install NSF on a Unix-based system. If you are running another operating system, you just have to adapt slightly, but the steps remain the same.

First of all, you have to check if your system meets all requirements for compilation and configure the sources according to your computer's environment. To do that, execute the following command in the NSF directory:


If no errors show up, you can build the NSF sources by entering:


You have just compiled the NSF sources and optionally can test your compilation by executing:

make test

In order to properly install NSF on your system (i.e., in the right place) type:

make install

This will copy binary files to the corresponding directories and set environment paths in order to be able to execute NSF from everywhere on your system. So, you don't have to bother if you are in the right directory anymore.

Congratulations, if all of the above steps finished without errors, you have successfully installed NSF and are ready to proceed.

If you experience any problems, try to get help by exactly following the installation instructions provided in the README file. If you still are having difficulties, then do not hesitate to get in touch with the community.


Your first Steps

After successfully installing NSF, you may want to execute your first program. In order to do this, open your operating systems command-line interface (e.g., a Unix shell) again - only, if you closed it already after the installation was completed. As introduced earlier, NSF supports NX and XOTcl 2.0 as object systems. Further below, we provide the exact same examples for both (NX on the left, XOTcl 2.0 on the right). So, as a first step we want to open a Tcl shell:


Now you should be in the Tcl shell and can execute both Tcl and NX/XOTcl commands, respectively. Let's try an ordinary Tcl command:

A first 'Hello World' example

% puts "Hello World"
#=> Hello World

Of course, you can alternatively save any command in a textfile (e.g., helloWorld.tcl) and execute it by typing:

$ tclsh helloWorld.tcl

Build Graphical User Interfaces

You want to build sophisticated GUIs? Here is a 'Hello World' example by using the Tk Toolkit:

label .hello -text "Hello World"
pack .hello

In the small example, a new label widget is defined and some text is added. The second line tells the geometry manager to arrange the widget automatically. Save these two lines of code to a text file of your choice (e.g. helloWorldGUI.tcl) and execute it with the corresponding WIndowing SHell (wish), which provides a way to bring up tclsh in a graphical window as well as providing Tk support:

$ wish helloWorldGUI.tcl

The really cool things start here

OK, so Tcl commands are working (also graphically). Let's move to the interesting part: We will use features provided by NX and XOTcl2.0 (namely possibilities for object-oriented programming). Therefore, we will define a minimalistic Greeter class extending the 'Hello World' example. The class will consist of two methods for saying hello and goodbye.

As shown earlier, you basically have two options for executing the script:

  • Interactive mode: Open a Tcl shell (like above) and type/copy the few lines into it.
  • Batch mode: Type/copy the script into a textfile and execute it like shown above (e.g., tclsh yourFileName.tcl).

package require nx

nx::Class create Greeter {
  :property name:required
  :public method "say hello" {} {
    puts "Welcome ${:name}!"
  :public method "say bye" {} {
    puts "Goodbye ${:name}!"
package require XOTcl

xotcl::Class create Greeter \
  -parameter name
Greeter instproc say_hello {} {
  my instvar name
  puts "Welcome $name!"
Greeter instproc say_bye {} {
  my instvar name
  puts "Goodbye $name!"

As you can see, the NX class owns a required property (the name of the person we would like to greet) and two methods - one for greetings, the other to say goodbye. In the case of XOTcl 2.0, we define a class with the same two methods for saying hello and goodbye. The name of the person we would like to greet is passed as a parameter at the time the class is instantiated.

Our example in action

Now we want to see the Greeter class in motion. Therefore, we instantiate a Greeter object and call methods on it (interactively in an open Tcl shell):

% Greeter create g -name Anna
#=> ::g
% g say hello
#=> Welcome Anna!
% g say bye
#=> Goodbye Anna!
% Greeter create g -name Anna
#=> ::g
% g say_hello
#=> Welcome Anna!
% g say_bye
#=> Goodbye Anna!

Congratulations, if you come this far, you have installed NSF correctly and even managed to run your very first code examples!

Still hungry?

Further Information

OK, if you want to dig deeper, there are many resources you can get information from. At best you start by grapping information from the links provided in the table below.

Resource NX XOTcl Tcl/Tk
Tutorial/Documentation Link Link Link
API reference Link Link Link
Migration guide for NX Link

Latest news and information Link Link Link
Mailing list Link Link Link
Link Link
Ask questions, if you need help Link Link Link
Issues Link  Link Link



Have fun with the Next Scripting Framework!

We do.