### Archive

Archive for the ‘Smalltalk’ Category

## Programmers: You Probably Don’t Know What a Computer Is

When car buffs debate the relative merits of say a Ferrari vs. a Lamborghini, they obviously discuss the most salient features — like which mine the iron ore in the chassis came from, the gauge of the wires connecting the interior lighting, and the polymerization reactions used to make the plastic parts.

Not!

The folly of the above argument is so obvious because we are intimately familiar with the purpose of a luxury race car — to perform well on the road (and looking cool doesn’t hurt either!). In the context of the purpose of the machine, the importance of those implementation details fades into the background.

And yet, this dramatic irony repeats ad infinitum as one of the programming world’s favorite pastimes… Debating Smalltalk. Why did it never become widely popular? How “pure” is the language? Is it still relevant?

Smalltalk is weighed against languages like Ruby, Java, C.

But sit down. Are you sitting? Are you sure? Don’t hate me on reddit if you fall over and hurt yourself after reading the next part…

Programming languages are the wires connecting the interior lighting, but Smalltalk is the car.

That’s right — the car — the computer itself. Smalltalk is a 1980 answer to what a computer could be. Namely, a world of living objects, simulating the user’s mental model, which each provide the full power of the computer itself.

Okay, okay. So the car is a 1980 Ferrari. It’s aging. But here’s the thing — for the most part, the programming world stopped building cars after that. They keep putting cooler, faster, smaller parts (i.e. programming languages) into the same pre-1980 Yugo — the computer in which isolated applications cut the user off from the full power of the computer, which are themselves boxed in by the operating system, of which Dan Ingalls famously remarked:

An operating system is a collection of things that don’t fit into a language. There shouldn’t be one.

While we take this “operating system plus applications” paradigm for granted, it’s not a particularly powerful idea. As Alan Kay would say, it’s “reinventing the flat tire”. And, it doesn’t have to be this way. Let me take you on a little journey. But first…

Disclaimer: The point of all this is not how great Smalltalk is, or why you should use it. The point is to answer Dr. Kay’s challenge to “obsolete the damn thing” [1], to pick up where Smalltalk left off — creating a uniform, dynamic, fun system that “provide[s] computer support for the creative spirit in everyone” [2], instead of smearing more cool icing on top of the “operating system plus applications” mud pie, the impenetrable layers of which have grown well beyond the possibility of human understanding.

The following is an introduction I wrote to some Smalltalk GSoC students…

Congratulations on finding Smalltalk. I doubt you have any idea how important this could be for you.

You may not realize it, but you have opened a portal to some of the greatest minds in the history of our industry. In the beginning, for many of our heroes — Doug Engelbart, Alan Kay, Seymour Papert — computing was about the possibility of evolving the general level of human thought for the benefit of mankind. Effective critical thinking is vital to modern life e.g. the proper functioning of democratic governments. Yet traditional media have been ineffective at improving our thought on a large scale. Today, we’re mostly glorified “caveman with briefcases”, reacting to the same human universals as our distant ancestors — Fantasies, Stories, Superstition, Religion/Magic, Vendetta.

#### So what does this have to do with computing?!

I’m glad you asked In 1972, Alan Kay envisioned a “dynamic medium for creative thought” which he called a Dynabook [2]. It was an answer to the problem described above — a computer to support and guide minds to the level required to overcome our uglier instincts, and replace them with our highest ideas, like Equal Rights, Democracy, Slow Deep Thinking, Legal System over Vendetta, Theory of Harmony — ideas which do not take seed on their own, but must be actively nurtured.

#### So what does this have to do with programming?!

I’m glad you asked that, too Smalltalk is interim[3] Dynabook software! You have in your hands, not a programming language, but a live, dynamic, turtles-all-the-way-down environment designed to provide “support for the creative spirit in everyone”.

More practically, Smalltalk is a programming tool that allows productivity unimaginable in most systems. And, if you put in enough time and effort to actually think in it, it will help you program better in any language you use. But, I think it would be a great waste if you left Smalltalk “a better programmer”, when the questions before you are:

• What really matters?
• How can computers fulfill on that?
• How can I, as a programmer, contribute to that?

#### Ideas for research

[1] The Computer Revolution Hasn’t Happened Yet
[2] Design Principles Behind Smalltalk
[3] The Dynabook is a Platonic ideal, as so any implementation is just a step along the way in an infinite game

Reprinted on medium.com

Categories: Tags:

## Web Development: Reinventing the Flat Tire

The Dynabook is the holy grail of computing. It is the platonic ideal of a computer, whose purpose is “to provide computer support for the creative spirit in everyone” (Design Principles Behind Smalltalk). Yeah! I want my creative spirit unleashed Are you with me?!

##### But how do we get there?

We attack from both sides at once:

• Education – have computing be as natural as pencil and paper from a young age. And we mean individual creation, not the dependent-consumer model of the iPad, where you can do only what other developers implement, and Apple approves. While the iPad looks like the illustrations from the original Dynabook paper, it is actually the Anti-Dynabook. Much like places in the U.S. that have kept the original Native American names after stealing the land, it adopts the form while betraying the meaning
• Distillation – if we’re going to invent the future, we need to understand where we are now. Unfortunately, if you wrote the code of the average computing system (i.e. the OS plus and office suite) in books, they would stack the height of the Empire State Building. People (especially old people) feel stupid because they don’t understand computers. I feel compassion for them, but still have to chuckle and say, “don’t worry, neither do the developers at [Microsoft/Apple/Ubuntu]“. If Leonardo Da Vinci were a Microsoft engineer, he would not be able to understand how windows works. Computing in its present form is beyond human potential to understand!

This post will briefly look at the second point, distillation, as it applies to web development.

##### Why Simplicity Matters

We each have a limited amount of mental RAM, or working memory, with which to create. Less is available, the more complex and indirect our technology stack is…

See we’re here already. It’s assumed that you need to have a “stack” – WAMP, LAMP – an operating system, a database, programming language layered on top, often with a run-compile cycle, probably with tools (e.g. the compiler) written in another language, often glorified text editors as IDEs.

We must reduce the cognitive burden of the technology so that there is enough mental RAM left over to create.

##### The Vision

If you go back to the original intentions of Morphic from the Self world, the vision was:

1. Find – physically, visually, find an object (notice, it’s not “find a class”) that looks like/behaves like I want
2. Copy – again physically, visually, directly, by clicking the original object and dragging the copy away
3. Tweak – the object directly, not in desiccated file form in a text editor, until it does what I want it to do.
##### The Reality

This is totally lost in even the best web workflow:

1. Find - say a Bootstrap template
2. Copy – find all the necessary HTML and CSS files, which might take a bit of investigation into where they all live
3. Tweak – If it didn’t seem too bad yet, this is where the wheels really fall off. Edit the raw HTML and CSS files, then if you’re really trendy, click refresh on the browser window you have open parallel to your coding window and see things refresh. WTH?! Where did the objects go? You just cut your extremely limited mental RAM at least in half by working with your objects (forms, buttons, links) in the equivalent of web assembly language, and repeatedly switching contexts.
##### “Not As Bad” Is the New Better

You say, “I’m tired of programming in assembly in a text editor! Viva la Revolution! Instead of settling for a language piled on top of the manure heap, I’m going to use a live, dynamic environment like Amber or Seaside“. Well kudos! If the Dynabook was our ideal of 100% efficiency and most web technologies are 10%, you’re now at 30%, so you can whip the heck out of your competition.

But, and just indulge me here for a second, what if we’re not satisfied with being the one-eyed man in the land of the blind? What if we were interested in going beyond what’s better exploring what’s possible?

Even writing HTML with a nice DSL in Amber or Seaside, is a non-WYSIWYG run-compile-like cycle. It’s more like programming with punch cards than the live, direct universe hinted at by Self, Sketchpad, Squeak/Pharo, and Croquet.

##### Hints at What’s Possible

Ivan Sutherland had WYSIWYG (among other things, like constraint solvers) down with Sketchpad in 1963.

Morphic was another powerful attempt. In a Morphic system, if my code editor doesn’t work the way I want, I can drill down into it – without leaving my uniform dynamic environment of live objects – and make it so (theoretically, this is becoming less true with e.g. Spec, which hides the live objects under layers of hopefully-cross-ui-platform-compatibility *).

Here’s a good example of my initial excitement about Morphic. One of my first favorite examples of using Pharo was that creating a new repository in the Monticello Browser (a version control GUI tool) always started with IIRC the image (current) directory, and I have a folder under which all my local repos live. I brought up halos on the “new repository” button, then on the Settings browser, connected the two together, and submitted the fix in a few minutes with 0 context switches… and I was hooked on Smalltalk.

Of course, Smalltalk is just a step on the path toward the Dynabook, albeit the top step to date! To really blow your mind, check out VPRI’s work to build a complete computing system in 20,000 lines of code – about the size of a good novel! Here’s the original NSF proposal and the last published annual status report (still waiting on the final one)

* One of the funny (or sad) thing is that people keep developing UI Builders for Morphic – that’s what Morphic is. The question isn’t how to layer tool-centric crap on top, but how to directly play with the Morphs themselves (remember flaps?) until you have what you want, and then reify that. It wouldn’t be so hard (at least for geometry and layout) to implement “aMorphThatIBuiltViaDirectManipulation reifyAs: #MyCoolMorphSubclass”.

##### The Challenge

How do we interact with a cool Bootstrap login form as I did with the Browser above – directly, as a live object? How do we dig in to the web, find the live objects, and bend them to our vision, without leaving our live, dynamic, open, turtles-all-the-way-down system? I would love to live in that world.

Categories: Tags:

## Code Club: The Dynabook Vision Alive and Well

March 13th, 2013 1 comment

This video reminds me of those great stories about kids at PARC… They are using Scratch to teach children how to use their Dynabooks

From the teachers (Alan Kay has obviously developed a mind control device):

“We’d like the outcome of Code Club to be a whole generation that understands… how to make [computers] do what they want, so they can create their own tools and their own games”

“I really wanted to get the kids… learning how to make things work, [rather] than just being consumers”

From a student:

“It’s really good for learning… before we were just… moving around, but… now we know how to make proper games”

“Our mission… to give every child in the UK the chance to learn to code.

It is our aim to have a Code Club in 25% of primary schools in the UK by the end of 2014″

Categories: Tags:

#### Why

The most frequent use case I have is for pending bug fixes. Imagine this… you find a bug in Pharo that you need fixed to progress on your project, so you fix it. Now, you’ll need the fix to be present anywhere your project is loaded, so what do you do while waiting for the fix to be integrated? You’re obviously not about to manually file in changesets when you have a powerful tool like Metacello! And anyway, you don’t want to have to edit the scripts for your continuous integration server.

#### How

I’ve found two ways I like to handle this scenario. I’ll show the (slightly) easier one first.

##### Method #1 – #customProjectAttributes

This is the method to use for Monticello packages

###### 1. Make sure your configuration has #customProjectAttributes

Depending on the version of Metacello that was used to create your ConfigurationOfMyProject, you may have to add this method (which is easy enough).

In ConfigurationOfMyProject>>project, if you see the following two statements:

 "Construct Metacello project" constructor := (Smalltalk at: #MetacelloVersionConstructor) on: self. project := constructor project.

Change them to the following:

 project := MetacelloMCProject new projectAttributes: self customProjectAttributes. constructor := (Smalltalk at: #MetacelloVersionConstructor) on: self project: project.
###### 2. Define your custom attributes

#customProjectAttributes will return a collection of symbols that will be added to the Metacello platform symbols e.g. #’squeak4.4′ or #’pharo2.0.x’. The following is for the bug fix example we discussed earlier. The general process is a) declare a condition that let’s you know the fix hasn’t been applied in this image (e.g. a class is not present or DNU a message), and if true, add an attribute declaring that (e.g. #’PharoIssue6300′, as below).

customProjectAttributes   | requiresPharoFix6300 requiresPharoFix6382 attributes | attributes := OrderedCollection new.   requiresPharoFix6300 := (Morph canUnderstand: #hasKeymapCategoryNamed:) not. requiresPharoFix6300 ifTrue: [ attributes add: #'PharoIssue6300' ].   ^ attributes.

With this method, they must be packaged with Monticello. See method #2 below if you have to use changesets or .st files

 spec for: #'PharoIssue6300' do: [ spec package: 'SLICE-Issue-6300-Detach-keymaping-shortcuts' with: [ spec repository: 'http://ss3.gemstone.com/ss/PharoInbox' ]. spec package: 'VimPharo' with: [ spec requires: #'SLICE-Issue-6300-Detach-keymaping-shortcuts' ] ].

This is the method to use for changesets or .st files

For example:

 spec for: #'common' do: [ spec blessing: #'baseline'. spec preLoadDoIt: #preLoad. ...

This method is going to look much like #customProjectAttributes in method #1. The main difference is, since Metacello can not handle file-ins, you will load the code right in this method instead of delegating, as in the following example:

preLoad   | shouldFixIssue7294 | shouldFixIssue7294 := (EventHandler canUnderstand: #keyStrokeRecipient) not. shouldFixIssue7294 ifTrue: [ '/path/to/issue7294.cs' asFileReference fileIn. ].

#### When

So when would you want to use method #2? For one, you may already have a changeset handy. But the other reason is time decay. In Pharo, for example, because of the rapid pace of development, the package you fixed may have another fix applied first. Now, loading your version may silently replace those changes (this is what happens in the MC browser, I assume Metcello works the same way). I’m actually still figuring out the tradeoffs here for myself. For now, I default to method #1 unless I have a specific reason for #2.

#### Summary

So there you have a simple pattern to conditionally load packages or code files in a Metacello configuration

Hope it helps!

Categories: Tags:

## Smalltalk: Extending the Kernel

#### Motivation

Many time I wish I could send a non-existent message to an object that’s part of the built-in Smalltalk library.

For example:

String>>surroundedByDoubleQuotes   ^ $" asString, self,$" asString.

#### Packaging

##### Simple Case: Project-specific Extensions

In Pharo, I can store this method in a package different from the one of the class in question. This is called an “extension method” and the implementation is currently a bit of a hack… You put the method in a protocol that starts with an asterisk followed by the package name. Thus, for the example above, if my project was packaged in MyPackage, I could package the method with it like this…

For methods that are project-specific, this is all we need (although hopefully now that Pharo is working on first-class packages, it would be great if we could have both a protocol and specify an extension). However, the method above really has nothing to do with a particular project. It seems generally useful; and indeed, I find myself using it over and over.

##### Generally Useful Extensions

In these cases, it doesn’t work to package the method with the project that uses it, because if more than one of these projects are loaded into the same image, one method will override the other, creating a mess in Monticello. So I’ve been experimenting with two approaches.

The naive way would be to package all such methods in one package, e.g. “PharoExtensions”. This is the first thing I tried, but I was a bit uncomfortable with the all-or-nothing idea – that I’d have to load every extension I’ve ever created to use just one.

The most flexible tack is to package each method individually. The method above could be in the “StringSurroundedByDoubleQuotes” package. This way, one could load the method without effecting any other parts of the system. However, a package is a bit heavy-weight for just one method.

##### A Compromise

The current idea I’ve been playing with is to mirror the existing package structure of Pharo. For the above, String lives in “Collections-Strings”, so I tack on a standard suffix, making it “Collections-StringsSpd”. Now, we can load extensions for only the packages we are using, without having a confusing mess of ClassNameMethodName packages.

Categories: Smalltalk Tags:

## Smalltalk Magic: The Simplest Notes Browser That Could Possibly Work

From problem to source browser in 2 minutes (it took much longer to write this post about it)!

UPDATE: InspectIt (sorry, first version said “DoIt”):

'/path/to/home/Library/Mail/V2/Mailboxes/Notes.mbox/' asFileReference allChildren select: [ :e | e extension = 'emlx' ] thenCollect: [ :e | e readStream contents ].

Categories: Tags:

## Pharo Smalltalk: An Acknowledgement

July 7th, 2012 1 comment

Mark Watson wrote a nice blog post about his appreciation for Pharo and its progress.

I was inspired to comment on my own experience of Pharo as we move toward 2.0:

Thanks for the shout, Mark! Given how much you’ve enjoyed Pharo so far, I think you’ll be really impressed after the 2.0 release – I’m sure it will be a game-changer.

Much of the work the past few years has been in improving Pharo under the hood, like the new compiler, class builder, vector graphics, keyboard shortcut framework, and countless cleanups. This has been coupled with great leaps in infrastructure, like the CI server testing many variants of Pharo and its VM on Mac, Window, and Linux with every commit.

Now, all these investments are starting to payoff for Pharo users:

• Continuous integration has given us the confidence to replace the uggggly File library with FileSystem, a beautiful object-oriented library which is a joy to work with.
• Nautilus, the new browser, has long-awaited features like a history and custom groups.
• I’ve been playing around today with Vim bindings for Pharo tools, made easy by Keymapping.
• Fuel is a new fast object serializer
• Fuel might soon allow near-instantaneous bootstrap times for Metacello, the new package-mananagement system, which is getting closer to RubyGems (plus tools) every day
• The Pharo Kernel is driving the system to become more modular

I feel that we are close to a tipping point where the system becomes so easy and fun for developers that we will see a self-perpetuating revolution in the IDE. For me, Vim bindings are something I’ve sorely missed since finding Smalltalk two years ago. It’s only now that I’ve seen in Pharo an opening to make that dream a reality…

Now, if we can just clean Morphic…

Categories: Pharo Tags:

## Squeak VM: Compiling for Xcode

When compiling the VM for Xcode, one has to switch back and forth from the image to the command line. To make things easier, here’s a little script that:

1. empties the build directory
2. generates the sources and cmake info
3. Configures with cmake
4. Opens the project in Xcode

Gofer it squeaksource: 'MetacelloRepository'; squeaksource: 'CommandShell'; package: 'ConfigurationOfOSProcess'; package: 'CommandShell-Piping'; load. (Smalltalk at: #ConfigurationOfOSProcess) load.

Then, execute this script (also available as a gist) whenever you want a fresh Xcode project:

PipeableOSProcess waitForCommand: '/usr/bin/osascript -e "tell application \"Xcode\" to quit"'.   buildDir := FileDirectory on: '/Developer/cogvm/cog/build/'. buildDir entries do: [:e | e name = 'vmVersionInfo.h' ifFalse: [ e isDirectory ifTrue: [ e asFileDirectory recursiveDelete ] ifFalse: [ e delete ] ] ].   StackCocoaIOSConfig new addExternalPlugins: #( FT2Plugin ); generateForDebug; generateSources; generate.   PipeableOSProcess waitForCommand: 'cd /Developer/cogvm/cog/build/; /opt/local/bin/cmake -G Xcode'. PipeableOSProcess waitForCommand: 'open /Developer/cogvm/cog/build/StackVM.xcodeproj'.
Categories: VM Tags:

## Programming Language Rankings

The Tiobe index is total rubbish. But it’s worse than useless. It’s actually harmful. As Tyler Cowen mentioned in his TED Talk, “Be suspicious of stories”, feeling like you know what’s going on is way worse than admitting you don’t have a clue:

The most dangerous people are those that have been taught some financial literacy

Undoubtedly, there are people out there choosing careers and technologies based on the information age’s “divining by chicken bones”.  Tiobe is based on search engine hits for goodness sake. In the uber-democratic-everyone’s-a-technical-blogger web, of what is “talking about a language” a good indicator? Here is a primary one: that the language and its tools are not sufficient to support development. In other words, the Niobe Index (i.e. search engine results) is inversely proportional to language quality, as seen below:

$I_{n} \approx \frac{1}{Q_{l}}$
Since the equation above is obviously scientific (because it seems “mathy” and nerdy), it must be true. Furthermore (another great smart-people word), if one believes in (yes, like Santa Claus) the Niobe index (which can only be believed because it superficially seems scientific), one must believe my equation, which creates a paradox (another great science-y term).

In a live, open, dynamic environment (like Smalltalk*), the programmer has at their fingertips most of the things they would otherwise be forced to search the internet for, which is succinctly described by Torsten Bergmann. Also, working in a low level language, like C++ (e.g. manual memory management), guarantees search engine love. I used to need a Safari Books membership just to make sure I didn’t shoot myself in the foot.