Transd Programming Guide

(Work in progress)


Transd is a general-purpose programming language with enhanced text data processing capabilities and strong emphasis on compactness of implementation. The latter property makes Transd especially suitable for being used as an embeddable or extension language.

Transd is statically typed: the type of each object and expression is known on the stage of compilation. This not only helps in increasing performance, but also in writing correct programs by early detecting many errors.

Transd has usual basic types - Int, Double, String, Bool, etc. It has vectors, associative arrays, tuples, etc. It has classes, first-class functions (lambdas), exceptions, etc.

It has built-in basic support for processing structured textual data (tables, records, etc.) and this support will be expanding in future language development.

One of the main principles in Transd's design is the compactness of implementation and, second, minimization of dependencies. Currently, the full C++ embedding implementation of Transd is distributed as a two-files library (one header, one source file), which doesn't have any additional dependencies.

Another important design consideration is performance. The very first C++ application in which Transd was used as an extension language was a ray-tracer, which rendered graphics by applying a shading function to each pixel of the image. The user could define their own shading function in Transd language, store it in a configuration file, and the ray-tracer would use it for rendering. This Transd plug-in performed rendering at about 70% of native speed.

Compactness, minimal dependencies and speed make Transd a good choice for an embedding or extension language for extending or customizing a C++ program's functionality by the user, for parsing and processing structured textual data in custom formats, etc.

For using Transd as an extension language in a C++ program it's enough to add "transd.hpp" and "transd.cpp" files to the project and have your program communicate with Transd environment via Transd embedding API.

Getting started

This chapter begins the description of the language. One might find it useful to work through this and following chapters with a Transd REPL interpreter running in a shell window. The TREE3 command line interpreter can be obtained here.

The code examples that consist of a single expression can be run in the interpreter by typing them on the command line and pressing 'Return'. The text in the examples can contain comments, which start with two slashes // and continue until the end of line. The symbol => within comments precedes the text of the output that the expression in the example produces:

(sqrt 64) // => 8

This means that after executing (evaluating) the (sqrt 64) expression, the intepreter produces 8 as the value (or result) of this expression.

Another kind of code examples is the text of source files that can be run in the interpreter. These examples begin with the #lang directive line:

#lang transd
MainModule : {
  _start: (λ (textout "Hello, Transd!"))

You can run such code examples by first copying the code to a text file and then running it in the interpreter as follows:

/usr/bin/tree3 /tmp/

You need to replace the example file paths above with the actual paths on your machine to the tree3 interpreter and the source code file.

The 'lambda' keyword and 'λ' symbol

Transd has a keyword - lambda, - which has a one-letter alias - the Greek letter λ (called "lambda", Unicode symbol 955 (0x3BB)). The keyword and the alias can be used interchangeably, and for the sake of brevity in this manual the one-letter alias is used. The λ symbol in code examples can be replaced with lambda keyword if the reader prefers so. That is, the line:

  _start: (λ (textout "Hello, Transd!"))

can be spelled in the source code file as

  _start: (lambda (textout "Hello, Transd!"))

For the interpreter these two lines have no difference.


All Transd syntax can be reduced to two most basic syntactic units: data declaration and function definition:

varName: Type(), // data declaration

funcName: (lambda ...) // function definition

All computation in Transd is done, like in most other languages, within function definitions by applying operations to values and producing new values. The syntactic unit describing such an application is called expression. Transd has a universal syntactic construct for all kinds of expressions. This construct is called form. Form is, basically, a list of items, which is enclosed in parentheses for separating it from other forms.

An example of a form, which represents a call of pow function, raising 2 into 4 power:

(pow 2 4) // => 16

The first item within the form is always the name of the operation or function which is to be performed, and all subsequent items are the arguments to that function:

(+ 1 1)     // => 2

(sqrt 16)   // => 4

Form's arguments can themselves be forms, thus making up a nested form:

(sqrt (* 8 2))  // => 4

(+ (pow 3 2) (pow 2 4)) // => 25

Nested forms are evaluated by first evaluating from left to right all the nested arguments, and then passing the results of their evaluation as arguments to the form's operation.

In Transd all arguments to functions are passed by reference. That is, all modifications of function's parameters inside a function will modify the actual arguments that were passed to the function by the caller:

#lang transd

MainModule: {
  func: (λ par Int() (set par 25)),

  _start: (λ (with i Int(5) 
               (textout i)   // => 5
               (func i)
               (textout i)   // => 25



The programming language defined in the Transd Reference Manual.


A REPL command line interpreter for Transd programming language. TREE3 uses the Tourbillon compiler as the Transd implementation.

Tourbillon compiler

A compiler and run-time environment of Transd programming language written in C++. Tourbillon compiler compiles and runs Transd programs using the meta-compilation technology.

Meta-compilation (or virtual compilation)

A working name for the technology used in Tourbillon compiler for building and running computer programs. The technology works by representing the program source code as a network of finite automata. The advantages of technology are the higher speed of program execution than that of virtual machines, and the absence of necessity to perform just-in-time compilation to machine code.