DrScheme: Insert Lambda Template Keybinding

DrScheme provides a very versatile keybinding system. Out of the box you get bindings that make it very easy to navigate and even refactor your code. One keybinding, insert-lambda-template, works by surrounding the selected code with a lambda function. By default, insert-lambda-template uses the lowercase lambda symbol λ rather than the word lambda. As DrScheme encodes its files in utf-8 it has got no problems with this (in fact DrScheme has shortcuts for inserting most other Greek characters), but if you use other tools to edit or process your source code you may find that they (quite disappointingly) choke on it. For that reason, I wanted to modify the keybinding so that it would use the world lambda rather than the symbol. There are two ways to go about doing this.
The first involves modifying the source code of DrScheme itself. This sounds harder than it is as it doesn’t even involve downloading the source code. When you install DrScheme, it includes a number of source files used to customize itself. If you wanted, you could look up this keybinding, change it, and re-run the setup program. I don’t like this approach, though, since it forces the user to re-build part of the program. That leaves us with the second alternative, a custom keybinding.
A custom keybinding is easy to implement and add. To write it, I copied the definition of insert-lambda-template and changed the lambda symbol to the word lambda. Next, I went through DrScheme’s Edit->Keybindings menu to select Add User-defined Keybinding. That is all it takes.
My keybinding file can be downloaded here.

DrSync: Automatically synchronize file changes in DrScheme v370 and above

DrSync is a plugin that saves your files on frame deactivation and reverts them on frame activation. This tool is of particular interest to folks who run external programs like version control or build related tools on files which they are editing inside of DrScheme.
Continue reading “DrSync: Automatically synchronize file changes in DrScheme v370 and above”

Static and Dynamic in Programming Languages

References to static and dynamic programming language features often come up on discussion boards; and are often made in an inconsistent if not confusing manner. It seems that dynamic and static refer both to name binding and type checking. I wanted a clarification; the following is my take on what I learned based on reading a TSPL along with Wikipedia articles on Name binding and Type systems.
Name binding refers to the abstraction provided by programming languages by which we associate a “name” in the code with an “object” in the execution environment. In statically bound languages, the binding can not change, so it can be made before the program runs. In dynamically bound languages, the binding can change or in other words is not yet known, so it can not be made before the program is executed.
Type checking refers the process by which the language runtime applies its type rules. In statically typed languages, this process occurs before the program is executed. In dynamically typed languages, this process occurs while the program is executed.
The fun thing to do now, of course, is to determine how name binding and type checking occur in your current language of choice, and then figure why they do so in that manner!

Sometimes the first 80 percent is "good enough"

There is a joke among programmers: when the project manager asks how complete is the project, and you’ve finally reached the “%80 complete” mark, you tell him the good news because now you all know how long it will take to finish the 2nd %80 of the project! Sometimes this is just how efforts evolve; and it its not just limited to work efforts.
For the past month of so I’ve been practicing a beautiful song called “Over the Hills and Far away” (aka OTHAFA) by Led Zeppelin.
It has been a challenge for me. The practice-duration/song-duration ratio of OTHAFA’s has been a high. Learning it has almost been like work project: you get an idea of what needs to happen, start digging in, and eventually figure out what *really* needs to happen!
Ultimately, it took me about a month or so to learn all of the parts of the song (aka the first %80), and based on what I can see it will take another month to be able play it well enough to perform it (aka the second %80). Don’t get me the wrong, the first %80 means I play the parts correctly and it sounds nice. There are just all of the details that really take it from sounding “good” to “great”. It has been frustrating, though; as I started studying the 2nd %80 my progress slowed and it was a little bit disheartening. I soldiered on, but man…
Talking to my guitar teacher about it really helped me put things in perspective. He explained that the goal of learning the song was to learn all of the guitar playing techniques in OTHAFA that I would end up using in %80 of all of the other songs that I would end up learning. In other words, he had a clearly defined pedagogical approach to my course of study, mastering the 2nd %80 was more like a bonus, or an optional goal that I could pursue if I so desired. Wow, I had no idea; I felt a lot better after hearing that.
My take away from all of this is what when it comes to learning, it is really up to you to decide whether or not *now* is the right time to pursue that 2nd %80 of whatever you are learning. Perhaps even more important is using enough discretion to determine whether or not you are actually moving into that 2nd %80, or you are simply moving outside your comfort zone because *that* can feel even more difficult that the latter!
Whatever the case, keep on learning, whatever you can, and have fun doing it!

Bubba Zanetti on "the it factor" in programming

When it comes to identifying “the it factor” in programmers, everyone has an opinion. Paul Graham attributes it to good taste. Bertrand Meyer attributes it to doing things with class. Neither of them, though, of even come close to revealing the truth of it as Bubba Zanetti, the preeminent philosopher of the wasteland, did when he identified style as “the it factor” in programming.
His seminal contribution to answering this age-old question came to him in a fit of inspiration following a conversation he had with another programmer. In reply to said programmer, who had just explained that he would never learn Lisp solely for the fact that he hates parentheses, Bubba Zanetti suggested that:

You just don’t have the style, do you, chicken shit?

Bubba Zanetti clad in helmet on his bike
Addendum: When questioned as to why many of today’s programmers lack the so-called “it factor”, Bubba Zanetti suggested that:

Perhaps it was a result of anxiety.

Grants OLPC XO Mind-Share Experiment

The OLPC project’s vision is to “provide children around the world with new opportunities to explore, experiment and express themselves.” To help further their goal, the OLPC folks gave us the opportunity to purchase one laptop for ourselves while at the same time purchasing one for a child. Over the past month I’ve read, talked, and blogged about the XO, played and tinkered on the XO, programmed, hacked, and surfed the web on the XO. It has been a lot of fun, but more importantly, it has changed how I think.
OLPC is pitched as a learning project, but it is so much more than that. When you learn, you change; you make opinions and get ideas and live your life differently. It is a personal growth project. You will collaborate, exchange ideas, and make decisions. You will develop your own philosophy, hear others, and be a better person for it. Whatever path you take on this journey will lead you to the same destination: knowledge.
If you weren’t able to, didn’t want to, or maybe even didn’t know about the XO before today, it is not too late to spend some time getting to know more about both the OLPC project and the wonderful little machine that is part of it. If you are interested, please read on.
Continue reading “Grants OLPC XO Mind-Share Experiment”

Scheme Lisp on the OLPC XO

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.
Usage Notes

  • 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)!

Addendum 03/22/08:

  • 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.

Addendum 05/29/08:
Made a big correction in the order of the preference buttons, also updated the reference to the script which reflects the change.

Code Generation and DSLs in Scheme

Over the years, I have heard some pretty outrageous and tantalizing claims made about the programming language Lisp. For example, “It will change you, forever.” and “You write code that writes code.”. Sadly, no further explanation is ever provided. Perhaps it is impossible to capture the essence of that to which these statements allude? This air of mystery around Lisp is both a blessing and a curse. Some folks will find this aura repugnant; others magical. For me, it was the latter. I wanted in on the secret!
Continue reading “Code Generation and DSLs in Scheme”