Playing mp3s in Squeak Smalltalk

December 13th, 2010 No comments

Squeak’s VM has an mp3 plugin, but there doesn’t seem to be any access from the image. So I dug into OpenSophie (version 1 of which was based on Squeak) and yanked out some code.

You can now play mp3 files in Squeak and Pharo!


  1. Just load the SophiePort package from
  2. Then try:
    song := StreamingMP3Sound onFileNamed: '/path/to/yourFavorite.mp3'.
    song play.
    "song pause."


  • It works in Squeak 4.1 and Pharo 1.1.1 on Mac OS 10.6.5
  • I am unclear about the license – Sophie has one license, the code itself seems to be SqueakL. Do your own investigation.
  • There were checks like the following that had to be removed for Pharo 1.1.1: “WeakArray isFinalizationSupported ifFalse:[^anObject]“. I’m not sure of the implications of removing them
Categories: Pharo, Smalltalk, Squeak Tags:

Debugger Driven Development

December 4th, 2010 4 comments

An amazing feature of Smalltalk is that you can create methods right from the debugger.  This fits nicely with “write the code you wish you had.”

  • First, you write a test calling whatever methods you want (even if they don’t exist)
  • When you run the test, a debugger pops up with a create button

  • Like magic, with a push of that button, a method skeleton appears in which you fill the implementation

Field Report

Now this is where things get creepy…  It’s after midnight, and I just want to finish one last thing.  You see, I’ve been implementing a very basic Cucumber-like framework for acceptance tests in Squeak, and there’s just one thing left to do.  I’ve got helper methods that turn given/then/when descriptions into methods that define the steps, like this:

As you can see, #given: transforms the description string into a camel case method name.

All I had left to do was handle the case where the method didn’t exist yet.  In cucumber, templates are passed to the command line to be pasted into the step definition file.  Oh, I’ve got it, the transcript is like command line output, I’ll paste it there!  Let me just see what this debugger is about…

When I took a closer look, I started laughing and couldn’t stop…

Smalltalk handed me a magic Cucumber-step-definition-template-generator!  I checked one more item on my todo list and clicked the magic button.

String-pasting Adventure in Squeak Smalltalk

November 29th, 2010 2 comments

Pasting a string into Squeak is just like pasting a string anywhere else… unless it has quotes in it… or is really long. Then, you’re screwed… but only in a this-is-Smalltalk-and-I’ll-be-able-to-wiggle-my-way-out-in-a-few-moments sort of way.

UPDATE: check the comments after this post for two quicker methods.

In the case of quotation marks in the string, Squeak thinks that the string ends at the first one, because they are not doubled:

In this trivial example, we could just put in the extra two quotes, but if the string was longer, a simple solution is to paste the text into a TextMorph and get its contents:

You can see that the quotes around template.NamlServlet have been doubled.

Long strings

However, if you try to do this with a very long string (like an HTML page source), when you ask for the contents, it will be prematurely cut off (note ‘…etc…’ below):

What’s going on here?  Well, if we browse Object’s ‘printing’ protocol (our hint to look in Object is that all objects can be printed in the tools), we find that printString actually calls printStringLimitedTo:

But fear not, the the method comment refers us to the perfectly named Object>>fullPrintString, which does just the right thing.  You can even copy the correctly-escaped string right onto the clipboard:

n.b. if you ‘PrintIt’ the above statement, you will still get a truncated string, because the system will call regular printString on the result of fullPrintString.

Categories: Smalltalk, Squeak Tags:

Squeak Smalltalk: Error recovery in a live open system

November 24th, 2010 3 comments

Vestigial Panic

Photo by star5112@flickr

I accidentally changed the subclass of a morph that was open in the world – oops.  My screen began filling with dozens of error windows.  Right around this time, I started thinking about quitting and rebooting.  And then I remembered… this isn’t Windows!  I can recover from this – and probably quickly.  So I brought up halos on the hosed morph, clicked the delete halo, pressed the user-interrupt shortcut (Cmd-. on Mac) and went for a glass of water – okay, it was wine – stop judging.

Room to Breath

When I got back, I had a debugger open on the event loop, so I knew that the pain had stopped getting worse.  Now I just had to figure out what to do about all those error windows.

Photo by mliu92@flickr

Like a trained seal, my first move was to press the close button on each one.  This got old after the first two, and I remembered I was using Smalltalk.

Brief Digression

After years of being institutionalized by Windows… and Mac (yes fanboys, it’s only slightly better than Windows, and can’t begin to touch what Engelbart and Kay were doing in the 1960′s and 1970′s), I constantly forget that I’m working in a live, open system, and do idiotic, inefficient things like hitting the close button on 50 error windows.  Like the movie Momento, where he wakes up every day and doesn’t remember who he is or what he’s supposed to be doing…

Smalltalk Nirvana

Back to my senses, I took 10 seconds to write a snippet that closed all the windows:

errorWindows := (World submorphs select: [ :m |
  (m respondsTo: #label) and:
    [ m label beginsWith: 'NonBooleanReceiver' ] ]).
errorWindows do: [ :e | e delete ]

And I was back in action.  Of course, this particular example probably only saved me 10 minutes, but multiply that by X times a day for a year and you get a glimpse of the power of Squeak Smalltalk – a live, open, beautiful system.

Categories: Mac, Smalltalk, Squeak Tags:

Doing surgery on Smalltalk Objects

October 19th, 2010 No comments

UPDATE: for class variable reflection, see the end

I had a class with an instance variable that required no accessors, like this:

Object subclass: #MyObject
instanceVariableNames: 'instVarWithoutAccessors'

The instance variable was initialized to hold an OrderedCollection, but after working with the object for a while, I decided that it should be a Dictionary.

Now comes the problem…  I had objects floating around that already contained a non-empty OrderedCollection.  I didn’t want to add otherwise-not-needed accessors.  Luckily, because of Smalltalk’s awesome reflection capabilities, it was a breeze to reach into these objects and surgically change them.  For each object, I just evaluated:

| temp oc |
oc := self instVarNamed: 'instVarWithoutAccessors'.
temp := Dictionary new.
oc do: [ :d | temp at: d name put: d ].
    instVarNamed: 'instVarWithoutAccessors'
    put: temp.

And a quick inspector showed that the objects now contained a Dictionary that contained all the elements contained in the original OrderedCollection (note that I changed the class/var names in the above text to simplify the explanation):

UPDATE: to get at a class variable via reflection, try:

 MyClass classPool at: #ClassVarName
Categories: Smalltalk Tags:

The Purpose of Education

October 8th, 2010 No comments

In a great presentation, Alan Kay reminds us that the purpose of education in a republic is to produce citizens who are capable of critical, rational thought.

I know no safe depository of the ultimate powers of society but the people themselves; and if we think them not enlightened enough to exercise their control with a wholesome discretion, the remedy is not to take it from them, but to inform their discretion by education.

Thomas Jefferson

Yet no one remembers this…

[Teachers, principles and school boards] think schooling is set up for vocational training or dealing with social problems.

Alan Kay

Categories: Education, Performance Tags:

Book Review: “The Engelbart Hypothesis: Dialogs with Douglas Engelbart”

October 7th, 2010 1 comment

Every human being should be familiar with Doug Engelbart’s work.

His mission is to raise human intelligence to match today’s problems, which are more complex and urgent than anything we’ve evolved to face, and are beyond the limits of our default abilities to solve.  This mission itself is urgent, because we have to do all this before we destabilize the global ecosystem, plunge into nuclear winter, or extinguish ourselves in any number of creative and possibly imminent ways.

Whether you are an Engelbart scholar, or are thinking, “Doug who?”, this book gives a great overall picture of the vision, as well as practical experiences of its application from prominent leaders.

Check it out at

p.s. there is also a free online version, but if you like it (as I do), make a donation to support this gift to humanity

Categories: Performance, Programming, Smalltalk Tags:

Review: A Mentoring Course on Smalltalk

October 2nd, 2010 2 comments


This is the best programming book I’ve ever read – and I’ve read them all – in C, C++, Ruby, and Smalltalk.


It’s definitely not a basic book – but it’s not complicated either (although it gets pretty deep).  In fact, while the code is all Smalltalk, it’s not about the language at all.  It could be called “Zen and the Art of Smalltalk”.  It gets at the heart of what it takes to go from an intention to create something, in a world we don’t really understand, to a successful outcome, that is simple, beautiful, efficient, and easily evolved.

Final Thoughts

I’m still gnawing on much of it (I just finished it a few days ago), but my viewpoint on programming has irreversibly shifted and, as Alan Kay says, “Point of view is worth 80 IQ points”. I think the programming world would be a better place if everyone read this book… I can’t believe I just gave a Reading Rainbow book report.  My life is complete.
Categories: Performance, Programming, Smalltalk Tags:

Unlocking Squeak Etoys

October 1st, 2010 No comments

I always forget how to turn on the developer tools in Etoys.  It is a simple preference set, but the name escapes me, so I’m writing it down.

  1. Bring up the halos on the world and select the ‘Menu’ halo
  2. Choose Preferences
  3. Under ‘scripting’, disable the ‘eToyFriendly’ Preference:

And you have full access to the developer tools…

Categories: Etoys Tags:

US Government Plays Rope-a-dope with Science

September 27th, 2010 No comments

The Boston Globe, in their article “How stop-and-go science funding puts the brakes on progress,” says “this chaotic funding environment” has “devastating implications.”

It reminded me of something Alan Kay said:

“90 percent of all good things that I can think of that have been done in computer science have been funded by [ARPA]. Chances that they would have been funded elsewhere are very low. The basic ARPA idea is that you find good people and you give them a lot of money and then you step back. If they don’t do good things in three years they get dropped – where ‘good’ is very much related to new or interesting.”

It’s unfortunate that government bureaucrats, who do not understand the consequences of their actions, are keeping us from all the benefits scientific progress brings.  Yet this quote, and the amazing things that came out of ARPA, point to how much can be done with a small amount of money (relative to total spending). Imagine the wave of innovation we could produce if we got a few of the purse-string holders on board :)

Categories: Programming, Smalltalk Tags:

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip