Q: Why another programming language? And why PHP?
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.
There are a lot of interesting language design possibilities, but in the end, I wanted THT to feel familiar to most web developers.
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:
- Features that are easier to exploit due to their extreme convenience (e.g. mixing together request data, using file operations on URLs).
- High popularity with less experienced programmers, who have not yet learned security best practices.
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 agree with, 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.
Uppercase THT is preferred in casual writing, assuming it’s easier for people and search engines to distinguish it from a common typo for “th(a)t”.
In code, and in file extensions, it is lowercase “tht”.
Q: Is there a convention for THT-related project names?
The following themes are a good place to start:
- Anything starting with the letter “T” or “Th”
Or because the visual identity of THT is inspired by the artist Mondrian:
- Visual arts and artist names
We recommend against using the full “THT” in project names, to avoid confusion.
Q: What are you adding next?
Please see the Roadmap.