Saturday, May 19, 2007

The Journey from Lambda to Unlambda

While scrounging around the Net looking at functional programming languages I came across Unlambda. The name by itself piqued my interest so I though I'd go have a look-see.

Here follows the troubled tale of the journey from Lambda to Unlambda ...
Nature of the Beast
It was created by David Madore and is a minimal functional programming language that was specifically built to make programming in it obtuse (or as the author's site refers to it as: "... fun and challenging"). It is based on combinatory logic but omits the lambda abstraction forcing you to rely on K and S combinators.

Beside hailing itself as a functional language it also succeeds in being an obfuscated programming language through severely restricting the set of allowed operations in the language and making it generally alien to programmers from more conventional languages.

It strictly only manipulates functions. A function is the only function parameter that you can pass in to a function and a function is the only construct that can be returned from a function. It relies heavily on its built-in k and s functions (K and S combinators) to get anything done.

The source is built to be intentionally incomprehensible for a human making it next to impossible to deduce what the intention of the program is by simply reading the source.

You are welcome to create your own functions, but be warned, you cannot name or save the custom function(s) because Unlambda does not have support for variables. Besides dispelling variables from its cloth you will also notice the lack of built-in support for data structures or code constructs (e.g. loops, conditionals, etc.). You are however welcome to build your own code constructs.

As an illustration, here is a loop that prints “Hello, world!” repeatedly, followed by an incrementing number of asterisks (an explanation of this severely limited subset of alphabet soup can be found here):

```s``sii`ki
``s``s`ks
``s``s`ks``s`k`s`kr
``s`k`si``s`k`s`k
`d````````````.H.e.l.l.o.,. .w.o.r.l.d.!
k
k
`k``s``s`ksk`k.*

Unlambda is the little functional language that could however and in the face of all its consciously implemented obscurity it still manages to be Turing-complete.

Sure, but can it speak?
Here's the Unlambda equivalent for the trusty old "Hello world" we're used to:

`r```````````.H.e.l.l.o. .w.o.r.l.di

More examples, a tutorial and some HOWTOs can be found at David's site for Unlambda.

Secret Murmurings on Unlambda

  • “It's disgusting — it's revolting — we love it.” CyberTabloid

  • “Unlambda, the language in which every program is an IOUCC.” Encyclopædia Internetica

  • “The worst thing to befall us since Intercal.” Computer Languages Today

  • “The effect of reading an Unlambda program is like having your brains smashed out by a Lisp sexp wrapped around an ENIAC. You won't find anything like it west of Alpha Centauri.” The Hitch-Hacker's Guide to Programming



Epitaph
Unlambda is inevitably compared to Intercal, but unlike Intercal it has a kind of weird elegance; this is because Intercal gets in your way, but Unlambda simply fails to help you."

No comments:

About Me

My photo
I love solving real-world problems with code and systems (web apps, distributed systems and all the bits and pieces in-between).