Flappy Bird implemented in TypeScript types
zackoverflow.dev
zackoverflow.dev
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) ```
That gave me a hearty chuckle because usually when I write `break` in a for loop, I say in my head the same thing.
Private repos only.
This reminds me of a post the other day about doing more useless things. This is the epitome of that in my mind.
> Any application that can be written in JavaScript, will eventually be written in TypeScript types
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://medium.com/free-code-camp/typescript-curry-ramda-typ...
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.
I feel the same way about "Quake implemented in CSS" demos. Like, very cool, but you actually should not be able to do that...
(In the case of TS, see 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.
Also CSS can't iterate so it's just at the level of arithmetic.
Doesn't TS do exactly this? It doesn't seem like setting a cap on recursion depth would disqualify something from being Turing complete. Or am I misunderstanding your comment?
(Similar to how every Turing complete programming language today runs on something technically weaker than a Turing machine due to finite memory.)
[0] https://herringtondarkholme.github.io/2023/04/30/typescript-...
Iteration (loops) are typically represented as jump or branch instructions while recursion requires the creation of a new stack frame on the call stack.
That sounds like a reasonable resolution.
type MultiDimArray<T> = T[] | MultiDimArray<T>[];
type LinkedList<T> = {
value: T,
next: LinkedList<T> | null,
};
type Json = string | number | null | Json[] | { [k: string]: Json };JavaScript taxes interface complexity through increased cognitive load. Typescript frees developers from that tax and harms architecture in the process.
Funny how business gurus keep saying over and over that incentives are everything and yet when it comes to choosing developer tools for their businesses, they choose tools which promote terrible incentives, instead they choose "that which sounds good"... It's like communism. It sounds good in theory but it fails spectacularly at the incentive layer... It fails at the most important layer.
This isn't theoretical; the only reason TypeScript allows for such complex interfaces is precisely because JavaScript devs have created those interfaces, and TypeScript makes a best-effort to make as much JS code type-able as possible.
Edit: Additionally, it takes very little to define a specification that leads to emergent behavior. That’s not necessarily a bad thing. It’s been awhile, but all you need for a turing machine is a way to store and read memory, and move the tape (instruction pointer) if I remember right. If that’s correct, you can come up with an infinitely complex machine with 3 instructions (provided you have an infinite amount of tape).
(It's a double-edged sword because it lets the TypeScript compiler move much faster than any other I've seen, but the lack of standardization regularly causes unintended breaking changes, and developing a competing-but-compatible type checker is basically impossible.)
It reminds me of why I like Haskell, in particular the last exercise on this page: http://learnyouahaskell.com/starting-out#im-a-list-comprehen...
In which you solve a problem declaratively by leveraging Haskell laziness.
Regardless, really cool project.
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?