Wolfram|Alpha: Systematic knowledge, immediately computable.

Thursday, April 22, 2010

In the SCHEME of Things

One of the startups I was involved in (Ariba - one of the few survivors of the Internet bubble of 2000, and home to some of the most brilliant people I've had the pleasure of working with) utilized Scheme for the underlying configuration, display, data definition, and process control system. Scheme is one of the two languages widely used based on the lambda calculus, homoiconic with mind-altering features like first-class continuations. Think of it as a 'cleaned-up' Lisp-1.

A hugely powerful language, perhaps, along with Common Lisp, my favorite. It allowed us to be unbelievably agile in response to customer needs: While the competition would have to take engineers off of pressing projects to have them do quick-and-dirty coding to add some deal-breaking feature, more often than not the Ariba field tech giving a demo could add it on-the-fly. Blew the minds of prospective customers (not to mention keeping the competition wondering what kind of voodoo magic we had), and resulted in a hugely successful company.

I was reminded of the elegance and conciseness of the language from a blog post I recently read. The poster wanted to dump the logs of an IRC they frequented. Need to setup the underlying network, connections, open the log, display it. The code?

(require net/url)
(display-pure-port (get-pure-port (string-url "http://ccl.clozure.com/irc-logs/lisp/2009-12/lisp-2009.12.28.txt")))

From Lam Luu, a student and lover of the language, Quicksort for any data type, with a user supplied comparator:

(define (filter list get?)
(cond ((null? list) '())
((get? (car list)) (cons (car list) (filter (cdr list) get?)))
(else (filter (cdr list) get?))))

(define (qsort list compare)
(if (null? list)
'()
(let ((pivot (list-ref list (random (length list)))))
(append (qsort (filter list (lambda (x) (< (compare x pivot) 0))) compare) (filter list (lambda (x) (= (compare x pivot) 0))) (qsort (filter list (lambda (x) (> (compare x pivot) 0))) compare)))))

What a beautiful languge!

No comments:

Post a Comment