Live data from Hacker News

TypeScript types can run DOOM [video]

youtube.com

371–380 of 391 posts

Re: TypeScript types can run DOOM [video]

#371
post #118

Can someone help direct me toward an understanding of what it means for something to be "run in/by TypeScript types"? A short explanation or link to a resource would really be helpful. :)

It might be helpful to look at something like Typescript Tic Tac Toe in the type system [1]. You can comment out individual lines in the GameLoop type, and then hover over `____________DISPLAY___________` to see the current game state. Illegal moves will result in type errors.

Running Doom in the type system effectively means a lot more types have been generated (effectively a C to typescript-type compiler was created if I understood this correctly), then the game was started with no inputs entered. Theoretically if the author had infinite time and compute resources, the history of control inputs up to a certain point in play could be put in a tuple, and the type system would generate the state of the game given the code and the moves which the user had input so far. This state would include what's on the screen, but also internal state variables controlling things like where the enemies were moving, whether projectiles are in air, their direction, collision detection, etc.

[1]: https://tsplay.dev/wE95vw

Re: TypeScript types can run DOOM [video]

#372
post #113

Earlier quoted context omitted.

There are valid use cases for any (such as type constraints). Playground with example here: https://tinyurl.com/5ahs366a

Seems to also work without any: type Values > = T[keyof T]

Note, the type `PropertyKey` is shorthand for `string | number | symbol` in Typescript

Re: TypeScript types can run DOOM [video]

#373

Earlier quoted context omitted.

Yes, but think of how much joy it brings to so many people.

Think of how much joy it would bring to people if the author would work on a piece of software which would be consistently useful beyond the one-time novelty. Of course, it's a matter of proportion - I'm not saying that only things of utility and no "fun" stuff need ever be produced; but this is a rather extreme case.

Probably less.

Re: TypeScript types can run DOOM [video]

#374

Earlier quoted context omitted.

it was done on an 13900k system with 128gb ram. I bet the performance would be very different on other systems. and by my calculations the next frame would only take like maybe an hour or so to render. so that means that actually, hilariously, if anyone wanted to really dig in and make the engine faster - which I suspect it can be done by multiple orders of magnitude, truly - then actually I'd say 30fps types-only-do…

Fascinating. Just for fun, comparable compute (by cpumarks) to your 13900k for 30 fps would be 39,600+ 96-core AMD EPYC 9655Ps. Bravo on the project success!

you know what's funny, I also have a threadripper rig (which is my main development rig) and it ran _slower_ than on the 13900k. Like. by a lot. and while that surprised me at first, it's makes a lot of sense because this is Node.js in the end (i.e. the TypeScript typechecker runs within Node.js) and that means it's single threaded. So single-threaded perf is all that matters.

Re: TypeScript types can run DOOM [video]

#375
post #362
post #337

Earlier quoted context omitted.

Is that really the big question? Why is it necessary to find another dimension along which to diminish the author?

I'm not diminishing them, I am in awe of their work, I'm just pointing out that sometimes people (including myself) focus on esoteric projects that might have some learning opportunities, but don't directly solve a real problem (and might just be psychological mechanisms).

hi! author here! it's taken me many years to be able to self reflect enough to produce these next few words, but the answer is I have learned about myself that I perform better under pressure. I'm more consistent, reliable, and make better decisions when it's go-time. so I guess the answer to your question _should_ be yes.

although.. I've noticed I have other flaws that have burned me many times in responding to incidents. Oh well. The one I've been working on for years is "when the system is down, check the status page of the upstream provider first because it might not be your fault". I always assume it's my fault for way longer than I should.

Re: TypeScript types can run DOOM [video]

#376

Earlier quoted context omitted.

Python keeps the types at runtime, that's why no TypeScript framework will have a developer experience anywhere near something like FastAPI.

It's doable if you really want to: https://docs.nestjs.com/openapi/cli-plugin#overview (Also doable without a compiler step, but since it's TS one more compiler step isn't the end of the world: https://docs.nestjs.com/techniques/validation#auto-validatio... )

I do use this. It's not as seamless as using FastAPI. Also not as type-safe as FastAPI.

You can simply type a class variable as an int while the validation decorator works on a completely different type. It's an illusion of type safety.

Re: TypeScript types can run DOOM [video]

#377

Earlier quoted context omitted.

Python keeps the types at runtime, that's why no TypeScript framework will have a developer experience anywhere near something like FastAPI.

First party runtime types would be nice, but zod has become pretty much the standard answer for projects that need it. Not complicated.

Tell me how to have automatic documentation and validation like FastAPI using anything in Node.js and I will use it immediately.

Note: NestJS isn't it.

Re: TypeScript types can run DOOM [video]

#378

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.

Re: TypeScript types can run DOOM [video]

#379

Earlier quoted context omitted.

"the only thing they fear is you" but the incredible, honest, humble, hard hard-working, Mick Gordon.

Oh haha well now I feel dumb. Of course it is! The high pitched sounds are similar to the Batman Beyond intro. I can hear the djenty riffs better now though. Sick video!

thanks!

Re: TypeScript types can run DOOM [video]

#380
post #366

Earlier quoted context omitted.

People have to be comfortable to be as creative as the OP comment, so while I agree in principle, I think it's going to be harder than you imagine to build amazing things when you're living below the poverty line. The anxiety and mental anguish alone could cripple a person, even someone that isn't in the worst situations.

hi! author here! it's a pipedream, I know, but it's a hope/goal of mine to, in the next video (the "why did you do this" video) to give some fuel/motivation to people that might be feeling like you describe. do you have any advice for me for what I can say in the upcoming video to someone that might not be as comfortable, as you say. I really do have a grasp for how hard what you're talking about is, and I've tried o…

I have no advice because I’m still kinda in the bad place but I think it just takes one thing you can focus on that you enjoy and sometimes you can slowly dig out of the hole. I’ve started woodworking and the joy I get finishing a project has helped to push me forward. Just talk from the heart and you’ll make a good video I’m sure.

Good luck, your project is very impressive and I hope you are able to continue to make cool stuff!

Post reply on HN