22 comments

[ 4.5 ms ] story [ 32.7 ms ] thread
(comment deleted)
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.

That approach is called literate programming. http://en.m.wikipedia.org/wiki/Literate_programming
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
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.

Best documented little project ever.
This is a great little game and the documentation is amazing.
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!

The elegance of the block descriptions made me blush, haha. Very nice.
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

This gives "self-documenting code" a whole new meaning. ;b
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.

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

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.

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").

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