This is super condensed but still very readable if you know Reagent and Hiccup.
It's interesting to compare this to a lot of tetris clones written in TypeScript. There are a few that take enormous pleasure in defining a type hierarchy and what not.
Contrasting that to the very compact representation of tetrominos
Thanks! I really enjoyed the data modeling aspect of this project. I also ended up modeling the board as a mapping of [row, column] -> color which might be different from the traditional 2D array representation.
Why pick Typescript instead of Javascript as a comparison? there's really not that much difference in your example if plain javascript objects/arrays/functions was used.
Clojure has better and more map handling functions in the std lib for sure, but I find that with the help of some libs you can write lots of Javascript in a Clojury way without too much hassle.
Typescript is becoming a popular alternative to JS and is often being chosen to correct the perceived shortcomings of JS.
Just like ClojureScript, which is often chosen to correct the perceived shortcomings of JS ;)
I picked on needless complexity due to top-down design not on static typing per se.
Here's a good video highlighting the difference of approach.
Well worth watching. Applies to how many Java architects would design a solution. I see the same kind of top-down approach happening in the Typescript area as well.
Yes, and Clojure exists in opposition to static types. There is always core/typed, but Rich Hickey does not like static types and Clojure was not intended to be written in that way. These days, with languages like TypeScript on the rise, static types are more fashionable than ever whereas Clojure appears to not be having the same momentum. While I like my static types very much, it never hurts to try to understand both perspectives and what they offer. To sell Clojure these days, you first have to sell dynamic types.
to create obfuscated and undocumented code? That's known already.
The goal actually is this: being able to write descriptive and understandable code for others and oneself.
Come back to the code a year later and is it still understandable? Lot's of cute character-level operators and fancy control flow is maybe not the way to go.
A few years ago some friends and I wrote a tetris clone to celebrate the 30th anniversary of tetris and learn ClojureScript in the process. Really fun group project.
Sweet! Thanks for sharing. I see you're using pure-store to manage your game state. My implementation also uses a redux pattern for state management :)
I really appreciated that it followed that convention because I was used to it. Also remembering 2 buttons (rotate and hold) makes it harder IMO. Being able to use up for rotate means I can just keep my finger hovered over the hold button. Then again I'm not much of a keyboard gamer.
It's interesting to compare this to a lot of tetris clones written in TypeScript. There are a few that take enormous pleasure in defining a type hierarchy and what not.
Contrasting that to the very compact representation of tetrominos
and the very cute rotate function: gives you a good idea what a Lisp is about.