Live data from Hacker News

Show HN: Conway's Game of Life in TypeScript's type system

github.com

21–30 of 48 posts

Re: Show HN: Conway's Game of Life in TypeScript's type system

#22
post #13

Sometimes I think I don't understand TypeScript's type system and then I see something like this and I realize I know even less than I thought

Any sufficiently capable type system will make it possible to implement a form of functional programming. These advanced type systems are essentially a form of pre-compile time scripting to assert certain guarantees about user defined types. It's the same mechanism that makes C++ templates turing complete.

In the case of TypeScript, most of the magic and crazy hacks are dependent on Template Literal Types [0], which is what allows inference based on arbitrary strings. Once you have that abstraction, you can just keep adding complexity to it.

[0] https://www.typescriptlang.org/docs/handbook/2/template-lite...

Re: Show HN: Conway's Game of Life in TypeScript's type system

#23

Love it! Reminds me of the hilarious "Typing the technical interview" [1] and "Typescripting the technical interview" [2], a couple of my favorite blog posts of all time. [0] https://aphyr.com/posts/342-typing-the-technical-interview [1] https://www.richard-towers.com/2023/03/11/typescripting-the-...

I think you have an off-by-one error there!

Re: Show HN: Conway's Game of Life in TypeScript's type system

#24
post #13

Sometimes I think I don't understand TypeScript's type system and then I see something like this and I realize I know even less than I thought

Any sufficiently capable type system will make it possible to implement a form of functional programming. These advanced type systems are essentially a form of pre-compile time scripting to assert certain guarantees about user defined types. It's the same mechanism that makes C++ templates turing complete.

Any sufficiently advanced type system is indistinguishable from Prolog.

Re: Show HN: Conway's Game of Life in TypeScript's type system

#26
post #15

I'm really confused, is it what TS is supposed to looks like?

It's just a demonstration of how to encode the transition rules for Conway's game of life as a set of types, aka logical constraints. TypeScript's type system has unification, same as in Prolog, and since Prolog is basically Turing complete so is TypeScript's type system.

Re: Show HN: Conway's Game of Life in TypeScript's type system

#28
post #23

Love it! Reminds me of the hilarious "Typing the technical interview" [1] and "Typescripting the technical interview" [2], a couple of my favorite blog posts of all time. [0] https://aphyr.com/posts/342-typing-the-technical-interview [1] https://www.richard-towers.com/2023/03/11/typescripting-the-...

I think you have an off-by-one error there!

Just a ui bug, the presentation layer doesn’t match the data layer

Re: Show HN: Conway's Game of Life in TypeScript's type system

#29

Earlier quoted context omitted.

Any sufficiently capable type system will make it possible to implement a form of functional programming. These advanced type systems are essentially a form of pre-compile time scripting to assert certain guarantees about user defined types. It's the same mechanism that makes C++ templates turing complete.

Any sufficiently advanced type system is indistinguishable from Prolog.

Note to readers: if the author’s username doesn’t make it obvious, it’s funny because is true.

If feeling adventurous, read e.g. https://lpn.swi-prolog.org/lpnpage.php?pagetype=html&pageid=...

Post reply on HN