Version: v0.5.1 - Beta.  We welcome contributors & feedback.  THanks!

Welcome to THT


THT is a lot like JavaScript and other curly-brace languages. If you already know one of those languages, THT will feel very familiar.

However, there are cases where THT is more tightly defined than its counterparts. For example, identifiers are always camelCase.

Because of these small constraints, THT code tends to be simpler and more consistent — within your own projects and code online. This frees up more of your “cognitive bandwidth” so you can focus on higher-level problems while building your app.

If you’re a beginner, we hope you find THT easy to learn and that it helps you develop good habits from the start. The concepts in THT should make it easier to learn other programming languages as well.


Syntax Highlighting 

NoteWhen editing .tht files, we recommend setting your code editor to use JavaScript syntax highlighting, since the two languages are very similar.

We will link to THT-specific configurations in the future. If you create one for your editor, let us know!

A Very Simple Program 

Let’s start with a one-line program.

print('Hello World!');

As you can probably guess, it prints this to the browser:

Hello World!

How It Works

Let’s look at each part:

1) print is the command, or function.

print('Hello World!');

2) The text, or string, is surrounded by single quote marks. (The quotes are not printed.)

// ✖ NO
print(Hello World!);

// ✔ YES
print('Hello World!');
      ^            ^

3) Our string is passed into the print function by surrounding it with parentheses.

// ✖ NO
print 'Hello World!';

// ✔ YES
print('Hello World!');
     ^              ^

4) Every statement ends in a semicolon, just like a period at the end of a sentence.

// ✖ NO
print('Hello World!')

// ✔ YES
print('Hello World!');

JargonIn the correct terminology, we’d say we are calling the 'print' function, with the argument 'Hello World!'.


The print function is a quick way to check your code as it runs. It’s mainly for you, as the developer, to experiment and debug.

If you try to print a data type other than text, it will be displayed in a readable format.

To send HTML output to the browser, you will use the Response module, as described in How to Create a Basic Web App.

Format Checker 

In the process of getting your program to run, it’s easy to end up with code that is a bit messy. It happens to everyone, whether they are new or experienced.

Messy code can be frustrating and stressful to work with, because it is harder to read and creates places where bugs can hide.

To help you write clean code, THT includes a Format Checker. It provides instant feedback about how to format your code so that it’s easier to understand and work with.

Spacing is especially important!


// ✖ NO

// ✔ YES  Cleaner spacing
lineWidth = (10 + 5) ~ 'px';

Read More: Format Checker


A comment is a line starting with //.

Comments are not executed as part of the program. A comment can appear on a line by itself, or at the end of a code line.

// A standalone comment.
// Here is another line.

let a = 1;  // Or next to a line of code.

How to Use Comments

Comments are useful for a few things:

Explaining code. Explain parts of the program to help any future reader (including you!) modify it later.

// Apply the Zuckerdorf Friendship Formula to determine how
// close this friend is to the current user.
let friendLevel = (numFriendsInCommon * 1.2345) + 42;

Disabling code. Temporarily remove lines of code while debugging. (Be careful not to clutter your files with too much unused code.)

// showWidgets(widgets);

TODO's. Record “To Do” reminders or other notes for the future.

// TODO: add in the rest of the seven dwarves
let dwarves = ['Sleepy', 'Sneezy', 'Doc'];

Multi-line Comments

Surrounding text with /* and */ creates a multi-line comment block.

    This is a

The Right Balance

TipComments are useful, but are in some ways a necessary evil, because they can sometimes distract from the actual code.

Instead of writing long comments, try to make the code itself more self-explanatory, by using clearer variable names and organizing your code into smaller, simpler functions.

Rule of Thumb: Comments should explain the “why” of the code. The code itself already tells you the “what”.