Version: v0.7.1 - Beta.  We welcome contributors & feedback.

Welcome to THT


THT is like a shiny, cleaned up version of PHP from the future.

Some core parts are still the same, like $ variables, curly braces {}, and a primary focus on web development.

However, every part of THT was thoughtfully re-designed from the bottom up, with the goal of providing better safety and usability.

What does that mean? Here are some examples:

Some of these changes might seem a bit strict at first, especially if they are different from what you are used to.

However, try to think of them as guard rails on a twisty mountain road. They are there to keep you moving forward safely, not to cage you in.

If you’re new to programming, this will help you learn good coding habits very quickly. These habits will be useful in other languages, as well.


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 of the code above.

print is the command, or function.

print('Hello World!')

Everything inside the parentheses () is sent to the print function.

print('Hello World!')

We are sending it a string of text, which is surrounded by single quote marks '. (The quotes are not printed.)

print('Hello World!')
      ^            ^---- single quotes


The print function is a quick way to check your code as it runs.

Your print messages will appear in an overlay on your page.

You can print just about any kind of data, and THT will display it in a human-readable format.

print('Hello THT!')

Line Endings 

In PHP, a semicolon ; is used to mark the end of statements.

THT is different. It uses one statement per line.

               ^---- No semicolon ;

This approach reduces reduces visual noise and eliminates common “missing semicolon” errors.

Line Wrapping

If you need to extend a statement beyond one line, start the next line with an operator, or wrap the expression in parens (...).

// Operators on the next line
$price = $basePrice
    + $taxes
    - $discount

// Or with parens
$price = $basePrice + (
     $taxes - $discount

Format Checker 

In the process of getting our code to work correctly, we often overlook small inconsistencies in our code (e.g. how names are spelled, how it is indented, etc.).

However, these small mistakes can build up over time, making your code more difficult to read and even creating places where bugs can hide. (When it gets really bad, we call this “spaghetti code”.)

To help keep your code clean and consistent, THT automatically runs your code through a Format Checker, which will tell you right away if anything needs to be fixed.

Spacing is especially important!


// ✕ NO

// ✓ YES  Cleaner spacing
$lineWidth = (10 + 5) ~ 'px'