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

Common Questions

Q: Why another programming language? And why PHP?

THT was inspired by the numerous compile-to-JavaScript languages (e.g. CoffeeScript, TypeScript, Elm) that were designed to fix problems in JS and provide a alternative interface for developers to work with.

This led me to wonder why there wasn’t yet a similar compile-to-PHP language, given how ubiquitous PHP is, and how many issues it has. I eventually decided to try to create one of my own.

Compiling to PHP meant I could build on the good parts — like the simple request model and fast Apache integration — and focus on providing a better developer experience.

It’s also a chance to explore what a web-centric programming language could look like.

Q: Why the JavaScript syntax?

There are a lot of interesting language design possibilities, but in the end, I wanted THT to feel familiar to most web developers.

Nearly all web developers need to know JavaScript at some point, and the C family of languages is still the mainstream syntax for writing code.

The goal was not to design the perfect language aesthetically, but to create one that I wish existed as another convenient tool.

Q: Why include a web framework?

PHP itself was originally a language + framework. That’s why, for example, templating is the default output mode and things like session support are built-in.

Somewhere along the line, it stopped exploring these web development features, leaving them to framework creators.

In my opinion, we now have enough knowledge about which web framework features are essential, that some of them can be included in the standard library.

Q: Isn’t PHP insecure?

PHP isn’t necessarily less secure than other languages, but there are valid reasons why it has earned that reputation.

The biggest that come to mind:

THT covers the majority of PHP's security issues by default. It even goes further than many other languages, because it is designed to work in the hostile environment of the web.

Wherever possible, best practices are built in so that all programmers (novice or expert) can benefit.

Q: Is THT a compiler or transpiler?

It is a transpiler, which is a kind of compiler. “Transpile” and “compile” are used interchangeably in the docs.

The transpilation step takes place at request time and is cached, so it’s a transparent process. As a developer, you can just edit and refresh.

The definition of a transpiler:

A source-to-source compiler, transcompiler or transpiler is a type of compiler that takes the source code of a program written in one programming language as its input and produces the equivalent source code in another programming language.

A source-to-source compiler translates between programming languages that operate at approximately the same level of abstraction, while a traditional compiler translates from a higher level programming language to a lower level programming language.

Q: Why did you design (feature) in way that I don’t agree with?

There are tradeoffs in every decision.

I try to use my experience as both a designer and a developer to find a good balance between ease-of-use, familiarity, and security.

Sometimes I decide in favor of things that I don’t personally like, if it means sticking with a convention that everyone else is familiar with.

Sometimes two competing options might have equal merit, and it just comes down to making a call one way or the other.

I apologize in advance for the parts you don’t like. Unfortunately, it’s impossible to please everyone.

However, I'm a pretty reasonable person. If there are good, well-articulated reasons to change something, I'm willing to listen. I am especially open to recommendations that come with a working patch.

Q: What is the correct way to write 'THT'?

Formally, it is “THT” — in all caps.

In code, and in file extensions, it is lowercase “tht”.

Uppercase “THT” is preferred in casual writing, with the assumption that it’s easier for both humans and search engines to distinguish it from a common typo for “th(a)t”.

Q: Is there a convention for THT-related project names?

We would recommend anything starting with “T-” or “Th-”.

You should probably avoid using the full “THT” in project names, to avoid confusion.

Q: What are you adding next?

Please see the Roadmap.