Thursday, March 08, 2012

Smalltalk First Impressions

For the past two weeks I have been experimenting with Smalltalk. I was having a conversation perhaps a month ago with a classmate, who was taking a programming languages survey, and she was mentioning smalltalk, and how weird it was. I tried to explain that it wasn't so foreign, but I may have been tainted by exposure to common lisp, so much of the dynamic nature of smalltalk seemed like a natural thing to expect from a programming system.

I started to look into squeak, and a little reading lead me to Pharo, which if you are an adult looking to write programs and learn smalltalk, offers a much cleaner UI, is compatible with the squeak vm, and has excellent development tools, and no toy like features which provide a funny first impression of Squeak.

It turns out much of what I thought I knew about smalltalk was either incomplete or just plain wrong, borrowing from things I remembered about Objective C from a furtive attempt to start using it years ago. I have been repeatedly blown away by the depth of the object metaphor in smalltalk. The inspector and explorer are leagues above the tools I had become used to (either gdb+emacs or slime+emacs). The additional scratchpads at the bottom of the inspector allowing modification of the object at runtime are well planned and very useful. The debugger at first glance looks like the slime debugger, a variety of restarts are available, a somewhat terse message regarding the offending condition, and a partial stack trace / message history are presented. But the immediate usability of the system comes in the ability to browse the offending code site, modify the code definitions, restart or proceed and fix on the spot the problem.

In two weeks, I worked through the "Pharo By Example" LightsOut program (which was Quinto in Squeak by Example), get a quick feel for SUnit and the test runner, where the tests are only a keystroke away, and can be automatically created, blindly find my way through a currency converter gui program (a la Learning Cocoa), and have created a small DFA simulator. The learning curve is a little steep, but having seen the example application, and learned the short syntax of the language (really fits on a single sheet of paper, possibly a 4x6 card), the remainder of programming seems to have been selecting the appropriate classes, browsing their sanely named selectors, putting the pieces together, and running the tests.

My DFA simulation took about 45 minutes to piece together in between classes one morning, and I am a complete novice in Smalltalk.

Things I don't understand, certainly include monticello/metacello, how to install software, which pieces are loadable but will break your system, and have certainly had my share of frozen images. I recommend to anyone starting to keep a pristine image, and if you ever start it, to immediately save your working copy as an alternate name. Monticello is very useful in packaging versioned bundles, and seems to beat fileOut handily.

The Pharo developers have a very active community, their mailing list is busy, the community is experimenting in several directions at once, and what's most important, the system is discoverable. The browsers and finders are beautiful, the debugger is amazing, the Morphic Hierarchy is easy to browse, and finding the right tool for the job is simply a matter of finding the right pieces to put together.

One thing I haven't discovered in Morphic is how to specify relative position of submorphs, so I simply give explicit locations in the bounds, and hope the user doesn't alter the initial size too much. VisualWorks' GUI Painter seems to have simple checkboxes to control this behavior (if you've used Interface Builder in XCode you will be familiar with Springies...), and perhaps it's present in Morphic as well.

I have to say a few nice things about Stephane Ducasse's well kept links to available books, and his personal efforts in pushing Pharo forward.

Sunday, February 26, 2012

Ongoing Elsevier Boycott

Several mathematicians recently started taking action to boycott all Elsevier journals, following comments by Mr Gower of Cambridge. This has been a large enough embarrassment for them, and has gained international news coverage (I read about it in the economist less than 10 days after seeing the initial statements on Gower's Weblog.)

Mr Gower adds a rebuttal to an open letter from Elsevier to the research community here.

Saturday, February 25, 2012

Inventing on Principle

Now I see what everyone was so excited about. Brett Victor - Inventing on Principle. is perhaps the most intriguing video I've seen in over a year. This is the future coming at you fast. It looks like dynamic languages are finally coming back to the future.

Thursday, February 02, 2012

A Simple Example

Occasionally, people make far fetched claims about the flexibility offered by lisp. Here is a simple example: editing the source code of a running program.

(defun foo () t) ;; foo returns true when called
(loop (when (not (foo)) (return))) ;; call foo repeatedly, until it is false.

This is of course a simple while true do nothing loop. But then we evaluate this little bit on the same system in a separate interaction session/slime buffer.

(defun foo () nil) ;; foo returns nil/false when called.

Amazingly, our loop exits, returns nil, and we are back in business. This is of course a contrived example, but not so far from the mark in expressing the simple idea that editing a program at runtime can yield a lot of power.

Saturday, January 07, 2012

Friday, January 06, 2012

Busy Week

We wanted to see "The Artist" on New Years Day, but the showing we planned on was sold out. Our second choice, "A Dangerous Method", left us with one hour of free time. The theater in Evanston has a Cost Plus next door, so we decided to while away the time in there. My wife found these very attractive blue leather chairs, and launched on a mission to replace our used Ikea chairs with the white slipcovers with these 'more adult' chairs. We placed a hold that day and borrowed a truck from someone who owed us a small favor for moving their things on New Years Eve. We were able to find a home for the other chairs with a friend the same day, and now we are back to a normal set of two chairs in the living room.


While at the friends apartment delivering chairs, I picked up her copy of "The Winter of Our Discontent" by Steinbeck and have since devoured it. I look forward to returning it with positive reviews.

Lately I've been reading through some of the published ACL2 'books' for inspiration. The system looks quite readable, and after wrestling for some time with Cyc, it's a pleasure to find something so aesthically pleasant. The modifications and extensions to the main CL functions are mostly removable from the axioms file, and implementing and testing some of the methods has been a relaxing pastime. Having the full source in /usr/share is a wonderful benefit to the curious. Anyone looking for hints on how to bootstrap lisp in lisp is encouraged to read through the beautifully documented acl2.lisp file, which sets up all packages and handles masking  out the existing language while preserving the system's symbols in another area.

School starts Monday. I picked up my bus pass and last book yesterday. I look forward to the interaction and stimulation that a group effort to understand some thorny subjects will bring.

I've recently started using github. Somehow, within 24 hours, a friend from school had found me and followed me. Amazing how quickly information spreads. Nothing I've put there is particularly interesting, but it's useful to think I can have an additional backup, and starting to use vc is enlightening. I think I hear sourceforge slowly collapsing.

Beth left town tonight for the weekend. That leaves me to indulge in stuffed green peppers and Sabado Gigante. I can't wait to watch el Chacal de la trompeta eliminate some more contestants.

Thursday, January 05, 2012

Branding

xkcd: Brand Identity

In an unrelated note, I added "No Logo" to my wishlist yesterday.