MichiganTypeScript is a proof-of-concept project demonstrating a WebAssembly runtime implemented entirely within TypeScript's type system. It doesn't actually execute WebAssembly code, but instead uses advanced type-level programming techniques to simulate its execution. By representing WebAssembly instructions and memory as types, and leveraging TypeScript's type inference and checking capabilities, the project can statically verify the behavior of a given WebAssembly program. This effectively transforms TypeScript's type checker into an interpreter, showcasing the power and flexibility of its type system, albeit in a non-practical, purely theoretical manner.
This YouTube video demonstrates running a playable version of DOOM within a TypeScript type definition. By cleverly exploiting the TypeScript compiler's type system, particularly recursive types and conditional type inference, the creator encodes the game's logic and data, including map layout, enemy behavior, and rendering. The "game" runs entirely within the type checker, with output rendered as a string that visually represents the game state. This showcases the surprising computational power and complexity achievable within TypeScript's type system, though it's obviously not a practical way to develop games. Instead, it serves as a fascinating exploration of the boundaries of what can be accomplished with type-level programming.
HN users were generally impressed with the technical feat of running DOOM in a TypeScript type. Several pointed out the absurdity and impracticality of the project, with one user calling it "peak type abuse." Discussion touched on the Turing completeness of TypeScript's type system, its potential misuse, and the implications for performance. Some wondered about practical applications, while others simply appreciated it as a clever demonstration of the language's capabilities. A few users questioned the definition of "running" in this context, arguing that it was more of a simulation than actual execution. There was some debate about the video's explanation clarity and a call for a blog post with a more thorough breakdown.
Summary of Comments ( 5 )
https://news.ycombinator.com/item?id=43185174
Hacker News users discussed the cleverness of using TypeScript's type system for computation, with several expressing fascination and calling it "amazing" or "brilliant." Some debated the practical applications, acknowledging its limitations while appreciating it as a demonstration of the type system's power. Concerns were raised about debugging complexity and the impracticality for larger programs. Others drew parallels to other Turing-complete type systems and pondered the potential for generating optimized WASM code from such TypeScript code. A few commenters pointed out the project's connection to the "ts-sql" project and speculated about leveraging similar techniques for compile-time query validation and optimization. Several users also highlighted the educational value of the project, showcasing the unexpected capabilities of TypeScript's type system.
The Hacker News post titled "MichiganTypeScript: A WebAssembly runtime implemented in TypeScript types" sparked a discussion with several interesting comments.
Many users expressed fascination and amusement at the project, highlighting the ingenuity and absurdity of implementing a Wasm runtime purely within TypeScript's type system. Some saw it as a clever demonstration of the power and flexibility of TypeScript's type system, pushing its boundaries beyond what might be considered practical. Others viewed it more as a playful experiment or a form of esoteric programming.
One commenter questioned the practical implications of the project, wondering about its potential use cases beyond being a proof of concept. This sparked a small thread discussing the potential for verifying Wasm modules at compile time or exploring new possibilities in type-level computation. However, the general consensus seemed to be that the project's primary value lies in its demonstration of the theoretical possibilities, rather than immediate practical applications.
Several users pointed out the similarities to other projects that explore the computational capabilities of type systems, particularly within languages like Idris and Haskell. This highlighted the connection between TypeScript's advanced type features and the concepts found in dependently-typed languages.
There was also some discussion regarding the performance and scalability of such an approach. Some commenters expressed skepticism about the feasibility of using this for real-world Wasm execution, anticipating potential performance bottlenecks.
A few users highlighted the educational value of the project, suggesting that it could be a useful tool for learning about both TypeScript's type system and the inner workings of Wasm.
Finally, some comments simply expressed amazement and appreciation for the creativity and technical skill demonstrated by the project's creators. Phrases like "mind-blowing," "absolutely bonkers," and "amazingly pointless" were used to capture the general sentiment of bewildered admiration.