News for hackers. Stuff that matters.
Re:Termtris: A Game Like Tetris in Ten Functions by adamesque on Thursday October 09, 2014 @04:42PM (#8434933)
Whoa! 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.

Re:Termtris: A Game Like Tetris in Ten Functions by elviejo on Thursday October 09, 2014 @05:06PM (#8435025)
That approach is called literate programming. http://en.m.wikipedia.org/wiki/Literate_programming
Re:Termtris: A Game Like Tetris in Ten Functions by theoh on Thursday October 09, 2014 @09:06PM (#8435777)
This 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
Re:Termtris: A Game Like Tetris in Ten Functions by dllthomas on Friday October 10, 2014 @01:06AM (#8436339)
He 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.

Re:Termtris: A Game Like Tetris in Ten Functions by jewel on Thursday October 09, 2014 @07:26PM (#8435521)
The 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/gr...

Here is a nicely rendered version of the same file: 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.

Re:Termtris: A Game Like Tetris in Ten Functions by kazinator on Thursday October 09, 2014 @07:53PM (#8435581)
It'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. :)
Re:Termtris: A Game Like Tetris in Ten Functions by Crito on Thursday October 09, 2014 @08:07PM (#8435616)
I really like this experimental racket language: 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.

Re:Termtris: A Game Like Tetris in Ten Functions by taeric on Thursday October 09, 2014 @09:51PM (#8435860)
So, 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.

Re:Termtris: A Game Like Tetris in Ten Functions by mhd on Friday October 10, 2014 @06:37AM (#8437061)
Totally 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").

Re:Termtris: A Game Like Tetris in Ten Functions by cpayne on Thursday October 09, 2014 @06:28PM (#8435344)
As 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!

Re:Termtris: A Game Like Tetris in Ten Functions by tylerneylon on Thursday October 09, 2014 @06:38PM (#8435382)
Thank you!
Re:Termtris: A Game Like Tetris in Ten Functions by advocaat23 on Thursday October 09, 2014 @07:18PM (#8435493)
Pretty 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

Re:Termtris: A Game Like Tetris in Ten Functions by kazinator on Thursday October 09, 2014 @07:22PM (#8435508)
Original Tetris for Terminals: 1989!

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

Re:Termtris: A Game Like Tetris in Ten Functions by sebnukem2 on Thursday October 09, 2014 @05:15PM (#8435050)
Best documented little project ever.
Re:Termtris: A Game Like Tetris in Ten Functions by lalunia on Friday October 10, 2014 @09:20AM (#8437503)
Like the example ~300 line tetris implementation for tinygame: https://github.com/nmillerns/tinygame Except that uses raw prints and termios in python instead of curses
Re:Termtris: A Game Like Tetris in Ten Functions by liadmat on Thursday October 09, 2014 @09:57PM (#8435873)
Cool project. It reminded me of the "Tetris in 140 bytes" project, worth a look: https://gist.github.com/aemkei/1672254
Re:Termtris: A Game Like Tetris in Ten Functions by dimitar on Friday October 10, 2014 @02:01AM (#8436441)
Tetris implementation for emacs: http://home.pipeline.com/~hbaker1/emacs/tetris.el
Re:Termtris: A Game Like Tetris in Ten Functions by nebyoolae on Thursday October 09, 2014 @06:02PM (#8435246)
This is a great little game and the documentation is amazing.
Re:Termtris: A Game Like Tetris in Ten Functions by sungeuns on Friday October 10, 2014 @12:00AM (#8436203)
Wow, the document is awesome and code is really understandable though I haven't used lua before. It's pretty nice work! thanks for sharing :)
Re:Termtris: A Game Like Tetris in Ten Functions by dmritard96 on Thursday October 09, 2014 @06:46PM (#8435406)
The elegance of the block descriptions made me blush, haha. Very nice.
Re:Termtris: A Game Like Tetris in Ten Functions by chrisweekly on Thursday October 09, 2014 @07:19PM (#8435499)
This gives "self-documenting code" a whole new meaning. ;b