One of the most tantalizing features that folks hear about Scheme is the eval function. While in reality, when it comes to meta-programming most modern Scheme distributions have evolved other mechanisms to do so, eval is still a big draw. The biggest shock most folks have when it comes to Scheme, though, is that you can only evaluate expressions in the top level environment. If eval holds your interest long enough, for perhaps any number of different different reasons, you will eventually reach the point where you want to do use it to evaluate code that you didn’t write (my inspiration came in the form of the Dolphin Smalltalk tutorial task where you write network chat clients that can send code to each other for execution). Whatever *your* inspiration was, though, you will also reach the point where you realize that you don’t necessarily want arbitrary code to be executed in the environment in which you are running your program; you don’t want folks sending
(exit) for example, that can be pretty irritating. One way to work around this issue to to evaluate your code in a sandbox.
Here are three ways to do it with PLT Scheme: DynamicEvalCustomNamespace, DynamicUntrustedEval, and Sandboxed Evaluation.
Here is a link directly to the Schematics PLT package which provides “a library of useful procedures on namespaces”.
Have you ever heard of TinyScheme?
TinyScheme is a lightweight Scheme interpreter that implements as large a subset of R5RS as was possible without getting very large and complicated. It is meant to be used as an embedded scripting interpreter for other programs.
You may or may have not heard about the programming language Forth, but if you have heard about it, you are very likely to have heard about it from some very happy, passionate Forth developers!
The best advocacy/introduction/tutorial I’ve ever read about Forth is located in the beginning of source code for this Forth interpreter!
After reading this, it is hard not to get excited about the programming language Forth.
Email discussion lists and comp.lang.scheme are an excellent to start.
Another option is #scheme on IRC at Freenode; there is nothing like speaking to another human being about Scheme.
When you talk with folks; you learn faster and have a lot more fun. When you are really digging into a concept, the kind soul who answers your question at just the right moment can make the difference between learning the concept now, or in a few days. Not to say that learning is a race; it is just so much fun that I think everyone loves to learn the next thing!
An aside; I’ve found that my mastery of topics, and in particular the lack thereof, is revealed much more quickly to me when I open my mouth! I won’t miss a chance to do so!
Peter Norvig posted this article explaining how implement an “industrial-strength spell corrector like Google’s” in only 21 lines of Python!
This article is a pretty fun read, especially for folks looking for fun problems to solve in their programming language of choice (or hopefully in the new language that they are currently learning). Be sure to check out the implementations that folks provided in other languages.
MIT Scheme is a fine Scheme distribution. Their editor, Edwin, however, has always been sort of a mystery to me. I can’t find anyone that uses it, documentation that “speaks to me”, or even a user guide on how to get the most out of it. Aaron Hsu, psychically detecting another Schemer in need, recorded an introduction to Edwin that provides a nice peek into some of its features.
How powerful is a programming language in which you do not utilize mutation?
Apparently very powerful. So much, in fact, that it was used to build the first prototype of the Fortress programming language.
Prediction for 2008, a new functional programming motto will emerge:
“Purely functional data structures: Strong enough to build a fortress!”
There is a widespread belief among most Java programmers that while syntactic extension is indeed valuable, its introduction to Java would result in, among other things, human sacrifice, dogs and cats living together – in other words: mass hysteria. What I meant by “most programmers” is really just one Java programmer, Gilad Bracha.
Ostensibly Gilad is right on about this one. Macros will result in horribly unreadable code; but we all know that is not true. We have all seen unreadable code, in any number of languages that haven’t got macros, and even in Java (sorry Gilad). Macros in Java would ultimately expand into Java, which every Java programmer could read; so the idea that Java programmers couldn’t read the code is pretty far-fetched (not to say that folks wouldn’t use macros to generate unreadable code, which is entirely possible). Gilad knows this, though; he is a programmer, so I don’t really buy his marketing mumbo-jumbo on this one. So I wonder, what exactly his point is. It probably isn’t even fair to try and grok his point from the little excerpt provided in the link, but here goes anyway.
His point is that Java follows the approach of providing a lot of specialized constructs rather than a few general constructs on which to build new features; so macros would not a good fit (for comparison and contrast see “Programming languages should be designed not by piling feature on top of feature…”).
Simple. Succinct. Consistent. All the signs of someone who knows how to make a decision. Thanks Gilad!
Ethan Herdrick is giving a presentation on Running a startup on Scheme next week. It sounds pretty interesting as he will be comparing PLT with Kawa Scheme, in addition to the fact that he is running a startup on Scheme.
Out of the box, the OLPC XO comes loaded to the gills with Python, but sadly, no Lisp!
To remedy that situation I enlisted the help of the kind folks on the PLT discussion list to help me write a script to build the PLT DrScheme (Lisp) development environment for the XO.
This script is responsible for preparing the PLT application suite for the OLPC XO laptop computer. The script creates a typical binary, *not* a Sugar application (that is going to take a little more work!). You can download the application itself here, along with the md5 checksum, and the build log. A Flickr photoset is available here.
If you do try it out, please be sure to read the usage notes below, and let me know if anything needs to be added to them. All of the documentation is pre-installed, so once you’ve downloaded it, extracted the archive, and executed ‘drscheme’ (or ‘mzscheme’ if you want command line Lisp) in the bin dir, you should be ready to roll.
Thanks to all of the hard work by both the PLT and OLPC folks, lives will be changed.
- The apps run quickly. The slowest part is, of course, the disk I/O.
- Slideshow works very well; it looks great and runs fast, turning the XO into a wonderful little “personal” presentation machine.
- Out of the box, there is one setting in Edit->Preferences->Editing->General that is left unchecked: Open files in separate tabs (not separate windows). Left unchecked, opening a file will occur in a new window, and creating a new file will occur in the same editor. Check this feature. It will prevent multiple instances of DrScheme, conserving resources, and perhaps equally as important, it will make DrScheme more fun to use. “Reuse existing frames when opening new files” should not be checked!
- Help desk works wonderfully with one caveat. When you are running Sugar and you switch between applications, more than one “unknown app circle” will show up in the “Donut”, each one corresponding to a DrScheme window. When you try to return to the help desk, you will find that you are always returned to the DrScheme IDE window. In order to get back to the help desk window, return to the DrScheme IDE window and then use alt+tab to switch to the help desk.
- In this build of DrScheme, the IDE will resize to accomodate long file names. Although the XO screen has a very high resolution, it is very small, and large fonts are used to accomodate this. As a result, when file names longer than 16 characters are loaded, the IDE will expand off of the right side of the screen. This behavior will not be present in the newer version of DrScheme.
- The Preferences window buttons “Revert to Defaults”, and “Cancel”, and “Ok” are not visible, appearing just below the bottom bound of the screen. The mouse cursor *can* click these, and in fact when you do click them, you can see the buttons are depressed. “Revert” is on the far left, and then “Cancel”, and finally “Ok” is on the far right, appearing in that order. This is order is different than how it appears on Windows (Revert, Ok, Cancel)!
- Updated the build script (now tag 004) comments with note about what settings to check in DrScheme, updated the usage notes to reflect this fact
- Someone asked “By the way, is there a reason that just typing yum install plt-scheme wouldn’t work?”. That is a good question. PLT builds against OpenGL. The XO does not have hardware acceleration. Consequently there are two ways to run PLT on the XO: install Mesa for software-based OpenGL emulation or build PLT without OpenGL support. I chose the latter, without testing the former.
- In case you are interested in building PLT for the XO using Microsoft Virtual PC, I’ve added my setup notes.
Made a big correction in the order of the preference buttons, also updated the reference to the script which reflects the change.