Concatenative Programming: An Overlooked Paradigm in Functional Programmng [pdf]
mitarbeiter.hs-heilbronn.de
mitarbeiter.hs-heilbronn.de
I've linked this many times before, but I'm reminded of "Thinking Forth"[1], an excellent discussion of application architecture. It specifically deals with the Forth programming language, but carries lessons that are applicable to almost any language. I think the reason it works so well is because you can easily demonstrate factoring with a very short piece of Forth. In a language like C or Java you would need comparatively more involved examples to demonstrate the same principles.
Perhaps it's not satisfied to be a position paper and the authors find themselves trying to show off novel research. I wish they'd resisted the temptation.
http://github.com/raganwald/homoiconic/blob/master/2008-11-1...
It was a cross between lisp and C (and a touch of REXX). Everything was a string, strings were manipulated and stuck back together and everything returned a value (or the empty string {}) even a 'for' and an 'if'.
A very simple example is this piece of code (that I hastily dug up) that would make a stripy table.
<!--begin stripey table-->
<table>
for(x in args)
{
<tr>
for(y in x)
{
if(stripey)
{
stripey=t
<td bgcolor="$dddddd"> y </td>
}
else
{
stripey=f
<td bgcolor="$ffffff"> y </td>
}
}
</tr>
}
</table>
<!--end stripey table-->
Which on first view probably looks unremarkable until you see the invisible concats in all the white space and that the curly brackets all denote strings, even after the fors and ifs.for instance:
x = for(y in {1 2 3 4 5 6 7 8 9 10}){y}
x
would return: 12345678910
Just thinking about it has made me dig out the old code and take a look at it again. It had super-simple built in MySQL integration, an MVC-alike system of actions, objects & 'envelopes'. It automatically cleaned all CGI in and CGI out. It even had it's own NoSQL style database!String concatenation was ideal for web programming (and a lot of other Unix tasks).
I'd love to return to it as it had a number of innovative features that I've yet to see in any other language (as well as a number I've seen appear since).
(I've also got $dddddd instead of #dddddd. Still valid, assuming there was a variable called dddddd).
Because it was a web language html entities, colors and tags were all valid code (and just returned strings).
5th
Enchilada
Factor
Forth
Joy
Onyx
PostScript
Raven
Staapl
See the left sidebar on this page:The implementation rocks, although the creator is now also sucked by the Google Vortex.