Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Getting Started

It is time for our initial Tango foray. Before we begin, however, we need to make sure that the Tango package is properly installed and configured. This information is thoroughly covered in Appendix B, so before proceeding here it would be best to follow the directions contained there. Tango accomodates several different source building methods, therefore it is important to take a little time to familiarize ourselves with them before advancing into Tango particulars.

Some Basic Steps

In our first movement, we try a small D sample to verify that Tango is configured as expected for our system and compiler.

import tango.io.Console;

void main()
{
    Cout ("Hello, sweetheart \u263a").newline;
}

This illustrates bare console output, with no fancy formatting.

One could use the Stdout module instead, which supports quite sophisticated formatting options. Console I/O in Tango is UTF-8 across both Linux and Win32, and conversion between various unicode representations is handled as necessary by higher level constructs such as Stdout and Format. We will see this higher functionality demonstrated in later lessons.

Now we also expect our computer to tell us something. In this case, we use Cin.get() to retrieve a string from console:

import tango.io.Console;

void main()
{
    auto s = Cin.get();

    Cout ("Hello, ")(s).newline;
}

To compile this program using bud, the command would look something like this:

bud mytestprogram.d  # may need to specify the -op switch on Linux

Another option is to use dsss. If dsss is properly installed, we execute the following command which should work on any supported operating system:

dsss build mytestprogram.d

Success! We have completed the first lesson in Tango.