Rate This Content
Also by this Author

This article describes a collection of new programming frameworks that are part of "Longhorn," the upcoming version of Windows. "Indigo," the code name for this framework, provides rich support for service-oriented design that is complementary to traditional object-oriented approaches. Indigo marries the best features of .NET Remoting, ASMX, and .NET Enterprise Services into a unified programming and administration model. Indigo's deep support for standard protocols, including HTTP, XML, and SOAP, makes it easier to integrate applications and ...

Read more!

Windows Workflow Foundation allows you to write workflow-based programs in terms of domain-specific activities that are implemented in CLR-based programming languages such as C# and Visual Basic. Here Don Box and Dharma Shukla get you started.

Don Box and Dharma Shukla

MSDN Magazine January 2006

...

Read more!

Don Box

MSDN Magazine May 2001

...

Read more!

The Simple Object Access Protocol (SOAP) facilitates interoperability among a wide range of programs and platforms, making existing applications accessible to a broader range of users. SOAP combines the proven Web technology of HTTP with the flexibility and extensibility of XML. This article takes you on a comprehensive tour of Object RPC technology to help you understand the foundations of SOAP and the ways it overcomes many of the limitations of existing technologies, including DCOM and CORBA. This is followed by a detailed treatment of the ...

Read more!

Don Box

MSDN Magazine December 2000

...

Read more!

Popular Articles

James Avery does it again with his popular list of developer tools. This time he covers the best Visual Studio add-ins available today that you can download for free.

James Avery

MSDN Magazine December 2005

...

Read more!

A Sidebar gadget is a powerful little too that's surprisingly easy to create. Get in on the fun with Donavon West.

Donavon West

MSDN Magazine August 2007

...

Read more!

The MVP pattern helps you separate your logic and keep your UI layer free of clutter. This month learn how.

Jean-Paul Boodhoo

MSDN Magazine August 2006

...

Read more!

Jeff Prosise explains when it's better to use UpdatePanel and when it's better to use asynchronous calls to WebMethods or page methods instead.

Jeff Prosise

MSDN Magazine June 2007

...

Read more!

Here we present techniques for programmatic and declarative data binding and display with Windows Presentation Foundation.

Josh Smith

MSDN Magazine July 2008

...

Read more!

{ End Bracket }
Scheme Is Love
Don Box


For the past few years, it has become fashionable to embrace a dynamic language such as Perl, PHP, Python, or Ruby. While I'll admit to having a short but pleasurable tryst with Ruby, I believe I have found true love in the dialect of Lisp called Scheme.
In writing Scheme programs, I've learned a lot about coding, design, architecture, and aesthetics. On this front, Eric S. Raymond got it right in his essay, "How to Become a Hacker":
Lisp is worth learning for a different reason—the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.
Everyone gets something different from their travels with Lisp. Here's what I saw along the way.
Small is beautiful. Scheme is a great example of a micro-kernel design style. Scheme defines a very small number of base mechanisms as part of the core language/runtime specification. For example, Scheme defines only one conditional in its base: the if special form. The if form works like the ? : operator from C/C++/C#:
(if abc "yes" "no")
This is equivalent to the following C expression:
abc ? "yes" : "no"
But Scheme and the C languages depart at this point. C defines a number of logical operators (&&, ||, !) and control flow statements (if, if/else, while, do/while) as language primitives. In contrast, Scheme defines all of these constructs as either procedures or macros. Does Scheme have the moral equivalent of C's basic conditionals and control constructs? Absolutely. What's interesting about Scheme is that these are all defined purely in terms of Scheme.
Lambda is more powerful than you think. Scheme programs are defined largely in terms of the lambda special form. Scheme lambdas are used to define functions. What's noteworthy about lambda is that functions are values just like integers are values. For example, the following Scheme code
(define s (lambda (y) (+ y 1)))
defines a new variable named s whose value is the function that calculates the successor of its argument. Here's the equivalent C#:
Converter<int,int> s = delegate(int y){ return y + 1; };
In both C# and Scheme, lambdas form lexical closures that capture the in-scope variables that are used by the newly defined function.Consider this C# code:
Converter<int,int> MakeAccumulator() {
  int total = 0;
  return delegate (int y) { return total += y; };
}
What I love about this approach versus defining a class is that I didn't need to go through the standard 20 questions one typically asks themselves when writing a new class. No class versus struct, interface versus abstract base, or other analysis was necessary. Instead I wrote a program that did what I wanted it to do. Period.
The difference between code and data is highly overrated. One thing all Lisp dialects have in common is that they build on a very simple mechanism (lists) that are used to build composite data structures. For example, the following Scheme expression
(list 1 2 3 4 5)
results in a five-element list containing the integers 1 through 5. In this case, list is a variable that is bound to a lambda that constructs a list out of its arguments.
In Lisp dialects, expressions themselves can be viewed as lists. Consider this simple Scheme expression:
(+ 1 2 3 4 5)
When evaluated, this expression results in the number 15. To turn off evaluation and keep this expression as plain, uninterpreted data, you can use the quote special form like this
(quote (+ 1 2 3 4 5))
which is longhand for:
'(+ 1 2 3 4 5)
Both of these expressions result in a six-element list, which begins with the symbol + followed by the integers 1 through 5. The ability to treat code as data allows me to apply general query and data manipulation techniques to my programs. To go back to the world of interpretation, I can ask the system to evaluate a data structure as if it is a legal Scheme expression like this:
(eval '(+ 1 2 3 4 5) (scheme-report-environment 5))
This melding of code and data is central to all dialects of Lisp, and is fundamental to the way Microsoft is integrating multiple expression languages (most notably SQL) in future versions of the Microsoft® .NET Framework.

Don Box is an architect on the Indigo project at Microsoft, working on next-generation Web service protocols and plumbing. His latest book is Essential .NET Volume 1: The Common Language Runtime (Addison-Wesley, 2002).

Page view tracker