390 comments

[ 3.1 ms ] story [ 133 ms ] thread
(comment deleted)
To be clear, it's running in TypeScript types only -- not JavaScript. Absolutely insane
Nothing will ever top this for typescript types. This is the pinnacle. An entire virtual machine and system memory with garbage collector in types.

Turing Completeness is one level, but being able to run Doom is the real test of whether a programming environment is complete and robust. Absolutely stunning to see TypeScript's type system get there.

Well we haven't implemented a web browser capable of running javascript in the typescript type system yet.

Quick, someone tell this author it's not possible.

Doom is Turing complete (https://calabi-yau.space/blog/doom.html), so it's just a matter of building the appropriate map.
That's not really relevant. Turing complete languages are used to build Doom and Pong, but one is more impressive than the other.
Pong was (originally) built using transistor-transistor logic on a circuit board. AFAIK it did not involve any software at all.
(author here) _yes I realize how ridiculous what I'm about to say is considering the project I just shared_ but I actually strongly disagree, haahah. there's this thing I learned of called "the turing tarpit". my position is that just because something could theoretically be done with infinite time and infinite resources, doesn't mean you can even approach the throne of doing it for real in a human lifetime.

And if I'm just totally wrong on this, then you have your answer on why I never gave up on this project. I never once, ever, at any point, lost hope that it wouldn't work (HOW COULD IT?!).... right up until the very instant when I couldn't deny it anymore and it was on the screen in front of me.

Of course you're right, and I should have put quotes around "just". It would be amusing to calculate how long it would take to render the Google home page via Doom via TypeScript; I'd guess much longer than the age of the universe.
Off topic, but as an obsessive debugger and experimenter with ADHD and someone who hates telling people lies about what can and can't be done your motivation speaks to my soul. But my usual rabbit holes last just few hours up to few days. And even those that go far (that avoided all obstacles) end up right before implementing the last step, when it becomes obvious to me that this thing can be done. Congrats on the sheer stamina.

I might use lesson you provided in my future to actually achieve something. I just need to doubt the feasibility of even the last step.

(comment deleted)
> And if I'm just totally wrong on this, then you have your answer on why I never gave up on this project. I never once, ever, at any point, lost hope that it wouldn't work (HOW COULD IT?!).... right up until the very instant when I couldn't deny it anymore and it was on the screen in front of me.

Has this experience changed your way of thinking at all? It sounds like the thing people thought was possible actually was possible, and that Turing completeness really did mean what people thought it did.

I hope this doesn't come off wrong like but honestly - but the outcome on this project doesn't change my view one bit. it didn't make me dig in my heels either, but I strongly doubt it's possible in a human lifetime to do this with at least some of the other languages that have type systems that are considered Turing complete.
(comment deleted)
It looks like they built a WASM runtime in the TS type system. Implement some more OS calls and you should be able to get a browser running. And then WASM on WASM on TS types. Lol
Not unless someone ports typescript to typescript types. That would be some next-level self-hosting haha
The first compiler that can play it on real time will be deemed the pinnacle for TS compilers.
If there's one top story HN deserves today, it has to be this. Absolutely insane and incredibly inspirational.
My literal LOL of the month. Love the types scale graphics/animation. :mind-blown:
Blew my mind! Dimitri talks about it in the video but I love the mention of how this project came to be[0]:

> This engine was built to service a project that aimed to demonstrate why Doom can't run in TypeScript types. Well. The funny thing is.. It can.

[0]: https://github.com/MichiganTypeScript/typescript-types-only-...

What was the argument for why it couldn't?
Because we lack an infinite tape and infinite time, not everything that is Turing complete can run DOOM
Or more specifically, everything that is Turing complete can run DOOM, but most languages are only Turing complete under certain assumptions which are not met in practice
> not everything that is Turing complete can run DOOM

Beware with such blanket statements, you might inspire someone to do 18-hour days for a year to prove you wrong.

Not having infinite tape is true for all computers though. And probably also not infinite time as well.
He tried and tried and tried to find one and accidentally proved instead that it could.
I got to watch Dimitri posting internal updates about his progress on this, and it has been utterly mindblowing. This is genuinely one of the most amazing things I've ever seen done with code. Absolutely legendary feat! (And also an incredible amount of persistence.)
(comment deleted)
Brilliant. The TS type system is a true marvel of modern software engineering. Its a shame that it hasn't just been developed into a proper fully fledged runtime at this point. Something like Deno is the closest we'll get it seems.
It is not a mark of quality, quite the opposite.
hi! author here! selfishly, it'd be really useful to me if you could take a moment to elaborate on your thinking here. it's not an altogether-too-too-uncommon viewpoint and I'd like to understand it if you have a chance.
(comment deleted)
This shouldn’t be possible.. Typescript devs have lost their collective minds and I’m totally here for it.

Edit : TS not front end

I didn't ask them outright, but I sorta think the TypeScript team might agree with you on this point! haha. At least we can all agree it's not an intended use-case, to play Doom.
Try to fit that in a context window! Absolutely amazing.
(author here) that was one of the 1st-week "ok, but THAT'S surely a good reason this can't work..." until I dug in and (to my great surprise) found a way.
A WASM runtime in TypeScript types is impressive in its own right, but I think I can dimly see how it could work with a lot of effort. https://github.com/MichiganTypeScript/typescript-types-only-...

What I don't understand is how this thing does keyboard input.

At 3:42, the video simply says, "And, yes, there's a way to do keyboard input," without elaborating on how. What sorcery is that? There must be something outside the type system translating keyboard input into TypeScript types…??

If I had to guess, it's a file with an array of keys pressed (or unpressed) at some time interval (say 0.1 seconds). Then a VS code extension can append to the array every 0.1 second along with any key-press states at that time. The compiler updates the game state whenever this array gets updated.

However, I'm guessing this is why we see a demo of pong and not doom. Doom probably just can't keep up with this.

No idea if I'm remotely on the right track here though.

If I heard him correctly he stated that it takes A LOT to just render a single frame. It's not playable. It can run DOOM, but you can't actually play it.
"A lot" is an understatement, rendering the screen at ~320p took 12 days.
(author here) pause on that screen and look at the code displayed on the right (as well as the note at the bottom!) the way to do keyboard inputs is basically exactly what people do for tool assisted speedrunners. Some people at this point in the message just went "oh cool!" and others went "you liar! that's not the same thing!". There was SO MUCH to say in 7 minutes in a short video like that, but rest assured, I'll go into depth on that in the next videos. The pong stuff that's shown is real (only the animating part was the creative liberty) and it's in the open source codebase.
Incredibly good video editing, unbridled insantiy, cheers!
conservatively 200 hours dropped into that 7 minute video - so you can imagine how happy I am to hear people are enjoying it!
Not only is Dimitri an amazing engineer - he's also great at building community and event/video production. Michigan Typescript meetups and videos have a level of polish that goes over and above
In the YouTube comments he stated nonetheless that he still bombed big tech interviews, specifically the technical portion, probably because of some ridiculous LeetCode problem he did not memorize beforehand. It just goes to show how these procedures do not effectively determine who is actually a good engineer or programmer. If this guy can't land a job while achieving this, then something is not quite right with the interview process.
hi! yep! this definitely happened. I do mention it in the next "why" video, but it's good feedback to know this is interesting to people because I could say a bit more about what those rejections were like - specifically the one where I failed the technical screening.

I'm actually really excited to share that part of the story because I hope it can be a small thing in the back of people's mind to help them if it happens to them. It can happen to anyone. Interviews are SUCH a lossy process and most engineers I know don't have any training on how to do interviews at all - yet we just assume they know how to evaluate people's skillsets.

What you've accomplished demonstrates a very important skill you have, persistence. Kudos and don't give up.

About those rejections, did they effect your confidence in yourself and your skills? How did they make you feel?

I was crushed and embarrassed. Yep. Not even gonna lie.

I used to work on Insomnia at Kong, which is literally a frontend for cURL. But some of the questions I couldn't answer were like "how do you get headers with cURL". I DON'T FRIGGIN KNOW. THAT'S WHY I WORKED ON A GUI FOR CURL. I CAN'T STAND USING THE CLI. lol. But to them, it was a question they were supposed to ask, and I got it wrong. Same story for questions about the git CLI DX (I'm a GitKraken fanatic lol), and more like that.

I would rate my confidence overall as being quite low. Well. I donno how to explain what I'm trying to say. It's not that it's low or high, it's that I don't factor it in a lot in what I decide to do. Where I've noticed some people dip their toe in, I find it easy to just cannon-ball into the frozen lake without needing a lot of justification. That's what I meant in the video about "close-enough-manship". I'm a sort of personality that spends a lot of time just failing miserably over and over again in the least efficient way possible until I get what I'm looking for - and I usually quickly move on before I learn what I could have done better, lol. I've been told that my comfort in the face of non-stop-failures is what confidence is, but I donno if that sounds right.

Getting a job these days is really tough on the psyche.

You have coding skills. Some marketing and video production skills. Self discipline and persistence. The time to spend 18hr days on a project. Why look for employment? Start your own business.
are you some kind of fortune teller!? haha. so that's so funny you say that because that, too, is a big part of the story. actually I was gearing up to do exactly that - but everything blew up in my face and this Doom project was, in many ways, my way of picking up the pieces from the rubble.

there's another reason, which is that I really get a lot of energy from working with other people. it makes me really happy. and right now especially I really love the people I work with. I learned this lesson the hard way in my stint contracting - because the inter-personal relationships are very different when you're there one day and gone the next (as a contractor).

Those interviews select for the type of person that believe it is worthwhile to dump tons of time into studying minutia to succeed at those types of interviews.

The purpose of a system is what it does, after all.

OTOH he points out that he learnt an enormous amount during this project specifically, so probably much more employable now.
You're making an excellent case for using AI during the interview. If you can actually code and do the work, you're hurting no one by using tools to get past these arbitrary barriers during the live interview. The system is clearly flawed when someone demonstrably skilled gets rejected over trivia.

I actually created a tool to help myself get through the live interviews, specifically by listening to the questions and giving me real time answers to things I couldn't recall under that kind of pressure. It's not about not knowing the material, it's about the ridiculous expectation to perform perfectly on demand.

imagine how amazing it would be if every major browser tomorrow suddenly dropped support for JS entirely and said that they only run typescript now. It will be a hard but absolutely mind blowing transition
(comment deleted)
What would be the point? Why waste time parsing and ignoring types? Types are for static analysis during comp time, they have nothing to do with the runtime and they don't provide "type hints" to the runtime about types, and code isn't optimized based on static typing analysis. Or should the browser do that? In that case which version of TypeScript? And by version I actually mean which tsconfig? Sorry for being picky but can't image why we would want something like that. If all we wanted was a compiled runtime like flash/actionscript was then I wonder why we killed flash
it would get rid of babel immediately and the billions of hours of transpile time spent across the planet by people converting ts into js. You ll be able to run ts natively without transpilation across every major browser
I think that would be a big loss for TypeScript and a very unfortunate thing for the whole ecosystem.
At this point the easiest way to know if a system is Turing complete is to check if someone has ported DOOM to it haha

Very impressive!

Only if the church-turing-carmack thesis holds, which I personally doubt
HN Pedantism never fails to elicit a chuckle from me
Alternatively if The Romero Hypothesis is proven to map the distribution of Mancubus numbers ... >_<
If it holds does that confirm that I’m his bitch?
Most people would agree that Mengelberg‘s 1984 paper clearly answers that question … of course, we all know that his language is famously hard to parse!
Doom compiled to just 177 TB (terabytes) of TypeScript types. Amazing on many levels.
For the first frame...
I think that 177 TB is for the whole shebang, it's just that it took 12 days to render the first frame.
both this and parent comment are right! once you have the first frame, it's probably just a few hundred more megabytes to get the second one - although I won't be the one to find out! 1 is enough for for me!
This must be the quintessential example of a Turing tarpit.

In TypeScript types, everything is possible, but nothing of interest is easy.

Amazingly inefficient. But I would not be able to reproduce this feat so hats off.
I mean it’s a very efficient implementation of the inefficiency.
I know the following comment is discouraged from hackernews but these are extenuating circumstances:

Yoooo WTAF

Bad Apple time!
Bad Apple would probably be trivial considering the work he did.
I hope he learned something useful while doing it and it seems like he did, because, although regarding all the comments here I'll likely be alone in my assessment, I just see a massive waste of time & effort? He described it as "a brutal year-long journey of 18 hour days" and he didn't bootstrap a company, he wrote Doom in Typescript types...?! The "epic" doom music underlying his story just makes it seem even more comical to me.

Maybe it's just me, don't want to crash the party. Carry on

(comment deleted)
I guess you have to ask yourself, what truely gives value in life? The answer is that value is subjective, and this person is wasting his time no less or more than you or I.
You could say the same about art. Artists put lots of time and effort into creating unuseful things to inspire others. Just like here!
> don't want to crash the party

> I just see a massive waste of time & effort

Kinda seems like you do wanna "crash the party". I disagree that this is a "waste of time" of course, the value I see here is manyfold:

1. Learning how to do self-directed learning, managing time, etc

2. Learning, at an expert level, about dozens of complicated (not to mention in-demand) CS subdomains

3. Doing something that nobody has attempted, and few people could realistically accomplish

4. Having fun on the journey of taking a ridiculous idea from conception through to a truly functional implementation

5. Sharing something you've built with the world

It is, of course, not everyone's cup of tea, but if someone wants to spend a not insignificant fraction of their life building something unique (and beautiful, in its own way) and sharing it with the world, to the detriment of quite literally nobody else, I support them in their adventure.

It is just you, I think.

Recreating the WASM runtime makes you learn a crap ton of useful stuff no matter what you use as your host compiler. In this case, the host being the typescript compiler happens to also add a wow-factor.

It's just you. It's extremely impressive. He likely set himself up for life with this + learned an unbelievable amount. And this is, in and of itself, a business. He has merch, a conference, a social media presence, etc.
It's just you. I would rather hang out with this guy than anyone who has ever started a company.
Uh, I think he learned what _universe level scale_ really means.
This reads to me like "After running the marathon he just went from point A to Point B, and that effort could have been better spent elsewhere"