6 ms·
Flappy Bird implemented in TypeScript types
- pc86 3y agoOT: great domain name
- sunnybythesea 3y agoNot related to this post, but man his other project https://aussieplusplus.vercel.app/ https://aussieplusplus.vercel.app/ is hilarious and ingenious :)
- joshmanders 3y ago> You can break out of a loop by saying MATE FUCK THIS: That gave me a hearty chuckle because usually when I write `break` in a for loop, I say in my head the same thing.
- _the_inflator 3y agoGot a rule to filter for certain cuss words. At certain times my code it heavily loaded with them, not because the code is bad, but I lack motivation and this is a fun way of dealing with it. Private repos only.
- streakfix 3y agoIt's a whole category of programming languages. Search for lolcode and cheflang.
- steve_adams_86 3y agoHa, I love it. Cheers, c***! This reminds me of a post the other day about doing more useless things. This is the epitome of that in my mind.
- diggan 3y agoFlappy Bird Implemented in TypeScript Types + a custom VM implemented in Zig + a compiler written in Rust Regardless, really cool project.
- deleted 3y ago[deleted]
- coding123 3y agoMy mind melted 5 minutes into reading that.
- deleted 3y ago[deleted]
- ryandvm 3y agoProps to the implementor for sure, but I dunno, if a specification is supposed to solve a problem in a very limited niche, but can actually do something like this, I feel like the spec is actually _too_ flexible. I feel the same way about "Quake implemented in CSS" demos. Like, very cool, but you actually should not be able to do that...
- jonahx 3y agoI believe in both cases the Turing completeness is accidental, and in the case of CSS a security concern. (In the case of TS, see https://github.com/microsoft/TypeScript/issues/14833 https://github.com/microsoft/TypeScript/issues/14833) If anyone has more historical evidence that this is so for CSS, reactions from original authors, etc, or further evidence in the case of TS, I'd be curious to see it.
- Dylan16807 3y agoSecurity concern how? Also CSS can't iterate so it's just at the level of arithmetic.
- Kinrany 3y agoAny sufficiently advanced type system necessarily becomes Turing complete because type systems generalize to full compile time programming
- IshKebab 3y agoThere isn't really any advantage of artificially limiting the power of type systems. Yes you shouldn't implement Flappy Bird in a type system... but just don't do that. This is obviously for fun.
- jlfsdlkj 3y agoIf you ever wrote any JS pre-typescript and then switched to typescript, I do not think you would call the problem "very limited niche."
- nicoburns 3y agoIf you think about it, then it makes quite a lot of sense that a type system aiming to describe the behaviour of a dynamically typed language would end up being this powerful.
- furyofantares 3y agoExtremely cool. I'd say you wrote a game engine in Zig and Rust, which allows you to write games entirely in the TypeScript type system, and you wrote Flappy Bird in that engine.
- quickthrower2 3y agoYes… and that makes it more impressive than just running this one game. It opens up type driven development to anyone who can do typescript.
- gumballindie 3y agoNone of which, of course, is relevant to the product’s success. You can write in basic if you wish. All that matters is market fit.
- shepherdjerred 3y agoIf you want to understand how things like this are implemented in type systems, I'd highly recommend Type-Level TypeScript [0]. I have no affiliation aside from having gone through the course and thoroughly enjoyed it. TypeScript has such a rich type system that lets you do some crazy things, many of which allow you to have a _very_ ergonomic dev UX while maintaining compile time type safety. [0]: https://type-level-typescript.com/ https://type-level-typescript.com/
- zarathustreal 3y agoA better (free) resource for this is the excellent blog post [0] by the creator of ts-toolbelt [1]. [0]: https://medium.com/free-code-camp/typescript-curry-ramda-types-f747e99744ab https://medium.com/free-code-camp/typescript-curry-ramda-typ... [1]: https://github.com/millsp/ts-toolbelt https://github.com/millsp/ts-toolbelt
- bsimpson 3y agoThanks! I bought it based on your recommendation, and I'm happy I did. It reminds me of Josh Comeau's articles, but for advanced TypeScript.
- DoughnutHole 3y agoI guess we’re going to have to coin Atwood’s Second Law > Any application that can be written in JavaScript, will eventually be written in TypeScript types
- theogravity 3y agoThat's crazy, not only did he implement the game with types, but also created a VM to run the type code in.
- lolinder 3y agoI was actually slightly disappointed that that's how it was accomplished—it's unsurprising to me that someone could write a VM to give runtime meaning to TS types, I find the programs that abuse `tsc` itself to be more interesting.
- revskill 3y agoI think the point of author is proving Golang type system is weak.
- mega_dean 3y agoHere's a similar article that I read recently about using Ocaml's type system to implement a sudoku solver: https://ocamlpro.com/blog/2017_04_01_ezsudoku/ https://ocamlpro.com/blog/2017_04_01_ezsudoku/ The author defines types to represent a valid sudoku board, and then uses the obscure syntax `-> .` to tell the compiler that a pattern should be unreachable. There is no compiler error when he compiles an unsolvable input. But when there is a solution, the compiler provides it: ``` Error: This match case could not be refuted. Here is an example of a value that would reach it: Grid (A, B, C, D, C, D, A, B, B, A, D, C, D, C, B, A) ```
- zogrodea 3y agoThat's actually pretty amazing. Thank you for the link.
- deleted 3y ago[deleted]
- ericls 3y agowhat's a rundown
- throwaway4aday 3y agowhen will the madness end!
- stnderror 3y agoI don’t get it. The game is not implemented in TypeScript types, right? It uses them to represent the code and has a custom interpreter for it. They could have done exactly the same in JSON instead. Or using arrays like in LISP. Cool project tho, but it is a very misleading explanation. Or did I miss something?
- deleted 3y ago[deleted]
- destroy-2A 3y agoI had fun finishing the game by flying over the top of all the obstacles ;)
- jokethrowaway 3y agoNice, declarative programming at its finest. It reminds me of why I like Haskell, in particular the last exercise on this page: http://learnyouahaskell.com/starting-out#im-a-list-comprehension http://learnyouahaskell.com/starting-out#im-a-list-comprehen... In which you solve a problem declaratively by leveraging Haskell laziness.
- lightlyused 3y agoThis feels like OOP and java all over again. Can someone get me off the edge and tell my why this is different?