6 ms·
Termtris: A Game Like Tetris in Ten Functions
- deleted 12y ago[deleted]
- adamesque 12y agoWhoa! Love the idea of a hybrid lua/markdown file; I didn't realize that the readme for the Github project WAS the source code till I noticed it was just a symlink to the .lua file. Very cool.
- elviejo 12y agoThat approach is called literate programming. http://en.m.wikipedia.org/wiki/Literate_programming http://en.m.wikipedia.org/wiki/Literate_programming
- theoh 12y agoThis is an obvious point, but the slightly ostentatious uses of the term "literate" by Knuth is not, apparently, a dig at the kind of "coding bums" (Dijkstra's words) who liked to use APL. There is a literate APL system out there, and Knuth seems to see APL in a different light from Dijkstra, as a specification language. http://tex.loria.fr/litte/knuth-interview http://tex.loria.fr/litte/knuth-interview
- dllthomas 12y agoHe said he chose "literate" because he wanted those who didn't like it to be advocating "illiterate programming". The common use of the term these days (source interspersed with documentation, serving as both) leaves out one significant aspect of WEB, where you could do quite a bit of rearranging the file layout (with slightly-buffed-up C style macros, basically) so that the communicative structure dominated. Reading through the papers on it was interesting; I've not actually put together a project in it.
- sebnukem2 12y agoBest documented little project ever.
- nebyoolae 12y agoThis is a great little game and the documentation is amazing.
- cpayne 12y agoAs a Microsoft developer who has never looked at a terminal before, I find these projects amazing. The OP wrote a tertis clone in terminal - clever / cool THEN its well documented! THEN its in one file - wtf? Well done!
- tylerneylon 12y agoThank you!
- dmritard96 12y agoThe elegance of the block descriptions made me blush, haha. Very nice.
- advocaat23 12y agoPretty nice. Writing a tetris clone targeting terminals is a fun endeavor and the easiest way to produce some moving graphics (besides Conway's Game of Life). It's also interesting to ignore curses and read and write plain bytes to the terminal and see what happens. I learned lots of nifty details about terminals there and you find pages like this: http://www.ibb.net/~anne/keyboard/keyboard.html http://www.ibb.net/~anne/keyboard/keyboard.html
- chrisweekly 12y agoThis gives "self-documenting code" a whole new meaning. ;b
- kazinator 12y agoOriginal Tetris for Terminals: 1989! http://www.miketaylor.org.uk/tech/tt/ http://www.miketaylor.org.uk/tech/tt/ Not done in 10 functions though! C on Unix. However, IOCCC entry in the same year: http://homepages.cwi.nl/~tromp/tetris.html http://homepages.cwi.nl/~tromp/tetris.html
- jewel 12y agoThe more flexibility a language gives you in the order you place your code, the better it is for literate programming. If you haven't seen it yet, check out the source code to coffeescript. Here is the source file: https://github.com/jashkenas/coffeescript/blob/master/src/grammar.coffee https://github.com/jashkenas/coffeescript/blob/master/src/gr... Here is a nicely rendered version of the same file: http://coffeescript.org/documentation/docs/grammar.html http://coffeescript.org/documentation/docs/grammar.html Also see literate coffeescript, a mode that seamlessly integrates markdown. I'd give up vim for a environment that lets me embed images, embed SVG diagrams, use those SVG diagrams at compile time to generate code, etc.
- kazinator 12y agoIt's a nice sentiment there in your last sentence, but good luck with your git repo, merging parallel changes from multiple developers to your compilable SVG diagrams. :)
- Crito 12y agoI really like this experimental racket language: http://docs.racket-lang.org/unstable/2d.html http://docs.racket-lang.org/unstable/2d.html I think that done correctly, this sort of concept has a lot of potential. Editor support is pretty necessary though, since without it editing that code would mess with your ascii-art formatting.
- taeric 12y agoSo, I am definitely a fan of literate programming. I'm not sure I am a fan of what I will call the polyglot method, though. Specifically, I don't think I fully grok/agree with the utility of having a single file that is both a markdown file and a lua file through commenting. In the end, it means you are still greatly limited to the ordering semantics of the main language. Which is not to say some folk won't do an amazing job writing a program. They clearly will. However, I think the macro approach of CWEB (or noweb, even) still has a lot of mileage that is overlooked nowdays.
- mhd 12y agoTotally agree, what we often see nowadays is still interesting, but mostly a "rich text comment" style. The two main factors for this are that such preprocessors are easier to write than weave/tangle systems, and that many people feel that in a modern idiom this isn't needed anyway. Shorter functions, no need for pre-declared variables, function hoisting, less global state... Not that this is totally wrong, working around the limitations of Pascal/C is one reason for the way Knuth's literate programming style was developed. The way I see it, the more simpler style is pretty good for a well-documented program that needs to be maintained, less so for a narrative that is a bit less focused, documenting the way something was initially written ("Let's add another field to our wibble_wobble structure to make wonk-gibbling work properly").
- liadmat 12y agoCool project. It reminded me of the "Tetris in 140 bytes" project, worth a look: https://gist.github.com/aemkei/1672254 https://gist.github.com/aemkei/1672254
- sungeuns 12y agoWow, the document is awesome and code is really understandable though I haven't used lua before. It's pretty nice work! thanks for sharing :)
- dimitar 12y agoTetris implementation for emacs: http://home.pipeline.com/~hbaker1/emacs/tetris.el http://home.pipeline.com/~hbaker1/emacs/tetris.el
- lalunia 12y agoLike the example ~300 line tetris implementation for tinygame: https://github.com/nmillerns/tinygame https://github.com/nmillerns/tinygame Except that uses raw prints and termios in python instead of curses