Clang Plays Tetris -- Tetris As a C++ Template Metaprogram
New submitter mjvzb writes: Ever wish compiling was more fun? Well, I recently implemented Tetris as a C++ template metaprogram (code at Github). The game is played by recompiling its source, taking player input by compiler flag. The runtime program is only needed to print the game screen to the console and save the game state across compiler runs.
Implementing Tetris in templates is not as horrific as you may imagine, and I've put together a post covering the details. Once you get over the syntax, C++ metaprogramming is just like functional programming.
Implementing Tetris in templates is not as horrific as you may imagine, and I've put together a post covering the details. Once you get over the syntax, C++ metaprogramming is just like functional programming.
Once you get over the syntax, C++ metaprogramming is just like functional programming.
No, the syntax is the entire thing wrong with C++ metaprogramming. It clearly wasn't designed for things like this. To clear up any doubt about the syntax, check out this file. In addition the inscrutable error messages (although those have improved over the past decade). If anyone likes template metaprogramming, I suggest they just use LISP.
That said, this project is really cool. Nice hack mattbierner.
"First they came for the slanderers and i said nothing."
This is the most terrifying and ridiculous thing I've seen in my entire life.
Americans have spent more than a trillion hours watching reality TV. That is far more terrifying and ridiculous than someone playing with a Turing-complete compiler meta-language.