Live data from Hacker News

Show HN: Tetris Implemented in ClojureScript

djblue.github.io

21–26 of 26 posts

Re: Show HN: Tetris Implemented in ClojureScript

#21
post #7

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 {:I {:color "#1197dd" :dim [4 1] :zero [1 0] 0 [[-1 +0] [+0 +0] [+1 +0] [+2 +0]] 1 [[+1 -1] [+1 +0] [+1 +…

I don't really see it. A similar approach in any imperative or functional language would read pretty much exactly the same.

Except that with static types, you'd gain a lot of clarity, efficiency, and future maintenance, one of the downfalls of Lisp.

Re: Show HN: Tetris Implemented in ClojureScript

#22
post #17
post #15

Here's my tetris copy: http://wolandbros.com/tetris/ Both the game and the source are much more minimal, it's very easy to customise the rules. You can see the source here: https://github.com/gunn/tetris/blob/master/src/store.js

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 :)

Thank you too! It's fun seeing the different ways we implemented the same things, even pieces and rotation.

pure-store is a library I made for very simple but efficient state management. The entire source is this file: https://github.com/gunn/pure-store/blob/master/src/index.ts

Re: Show HN: Tetris Implemented in ClojureScript

#24
post #7

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 {:I {:color "#1197dd" :dim [4 1] :zero [1 0] 0 [[-1 +0] [+0 +0] [+1 +0] [+2 +0]] 1 [[+1 -1] [+1 +0] [+1 +…

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.

Re: Show HN: Tetris Implemented in ClojureScript

#26
post #15

Here's my tetris copy: http://wolandbros.com/tetris/ Both the game and the source are much more minimal, it's very easy to customise the rules. You can see the source here: https://github.com/gunn/tetris/blob/master/src/store.js

Here's a shorter cljs version [1], as a bonus it cross-compiles to the JVM and Js reusing the core logic.

[1] https://github.com/yogthos/clj-tetris/blob/master/src/tetris...

Post reply on HN