### Archive

Archive for the ‘Programming’ 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:

## 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:

## Mountain Lion Upgrade: Developer Tools

After upgrading to Mountain Lion, the following all seemed to be broken:

• MacPorts… Issuing a selfupdate command produced:
checking whether the C compiler works... no configure: error: in '/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/base': configure: error: C compiler cannot create executables
• make…
command not found
• cmake…
error: There is no SDK with the name or path '/Developer/SDKs/MacOSX10.8.sdk'

The solution to these problems were fairly simple:

A few minutes later, I was back in business compiling the Pharo Smalltalk VM!

Categories: Tags:

## Getting gcc 4.2 to work with Xcode 4.2

Apparently, gcc 4.2 is no longer installed with Xcode (as of Xcode 4.2). Unfortunately, older projects may need to be compiled with gcc. There is some scattered information online about how to get gcc 4.2 with Xcode 4.2, but they seem complex and error-prone (e.g. install Xcode 4.1, then upgrade to 4.2).

UPDATE: Here are some situations you might find yourself in:

• Upgrading from Snow Leopard to Lion – it seems that gcc et al will be moved to a different location. See here for a fix.
• Upgrading to Xcode 4.2 – gcc 4.2 should still be on your machine; you just have to tell Xcode 4.2 to list it as an option (in which case, skip to step #2 below)
• Installing Xcode 4.2 with no previous version – no gcc 4.2 at all; follow instructions below.

Here’s an easy way to get gcc 4.2 working [1]:
1) Install gcc 4.2. via Mac Ports:

sudo port install apple-gcc42

2) Tweak Xcode so that gcc 4.2 appears as a compiler option, by editing the Xcode 4.2 GCC 4.2.xcspec file to get gcc 4.2 to show in the list of compiler options:

• Open the xcspec file for editing:
sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec"
• Change lines 41 and 42 from this:

ShowInCompilerSelectionPopup = NO;
IsNoLongerSupported = YES;

To This:

ShowInCompilerSelectionPopup = YES;
IsNoLongerSupported = NO;

•  Link the gcc 4.2 binary to the location that Xcode expects
sudo ln -s /opt/local/bin/gcc-apple-4.2 /Developer/usr/bin/gcc-4.2 sudo ln -s /opt/local/bin/g++-apple-4.2 /Developer/usr/bin/g++-4.2

Categories: 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.

* I am not pushing Smalltalk. In fact, I can’t wait until someone invents something better (hint, cough; VPRI).

Categories: Tags:

## Cocoa Smalltalk App

For a while, I’ve been thinking about using MacRuby for native UIs and multiple windows in Pharo on the Mac. I uploaded a proof of concept to https://github.com/seandenigris/PharoMacRubyTest . It has a simple Cocoa UI that uses http to get a value (the current time) from a running Pharo image and displays it in a text field. See the discussion on the Pharo mailing list.

Categories: Tags:

## MacRuby outlets don’t appear in Interface Builder (fixed)

Xcode 4.1 had a bug where IB did not recognize outlets in MacRuby classes. It is corrected in Xcode 4.2. However, if you upgrade to 4.2, you must then reinstall MacRuby for MacRuby outlets to start working again.

Categories: Tags:

## vi Bindings Rock

This is just a small example, but multiply it by the number of text editing and command line operations you do in a lifetime.

After executing the following on the command line:

HandBrakeCLI -e x264 -q 20 -f mp4 -m --main-feature -i /Volumes/DVD_01 -o /path/to/DVD_01.mp4

I needed to do the same for DVD_02.

With vi bindings, I pressed [Esc], [Shift]+[f], [1], [r], [2], [;], [.], and the command was transformed into:

HandBrakeCLI -e x264 -q 20 -f mp4 -m --main-feature -i /Volumes/DVD_02 -o /path/to/DVD_02.mp4

Woot! How else would you do this? Copy and paste into a text editor? Hold down the back arrow………………..? The investment in learning vi pays off in countless small ways over a lifetime of programming.

Categories: Programming Tags:

## Smalltalk Simple Image-based Persistence

In an enlightening blog post, Ramon Leon explains that most applications are designed for small businesses with small amounts of data. Therefore most applications will never have to scale (i.e. become the next Twitter), so a relational database is overkill. However, persisting by simply saving the image is slow and error-prone.

Based on these ideas, he suggests a simple (one class) framework which saves only your model. The idea is to use it as long as you can get away with, which may be forever.

I packaged the code from the post, added a few tests, and put it on SqueakSource as SimplePersistence.

It’s really easy to give your application persistence (see SPFileDatabase’s class comment). The three steps are:

1. Subclass SPFileDatabase
2. On the class-sode of the subclass, implement
• #repositories – returns a collection of objects to be saved
• #restoreRepositories: – gets passed back the collection.

That’s it! Now, whenever you want to save, call class>>saveRepository or class>>takeSnapshot (background save).

Categories: Tags:

## Love poor technology for simple tasks

##### I Have a Dream

If I had my way, I would never leave my Smalltalk image.

It’s not just the Smalltalk language (although I do enjoy the Zen-like minimal syntax, and keyword arguments flow off the keyboard like conversational speech). The real gold is the live, open environment, and control over everything in my system, almost down to the metal.

##### Reality Sets In (but it’s not so bad this time)

Yet sometimes, for a quick and dirty throwaway script, a tool symbolizing poor design is perfect.

For example, I wanted to change the artist info of a batch of tracks in iTunes. In less? time than it would have taken me to google a solution, I had whipped up an AppleScript (yes, ouch) in AppleScript Editor (double ouch):

tell application "iTunes" set wrongName to "" set rightName to "" set track_list to tracks of playlist "Music" of source "Library" whose artist is wrongName repeat with t in track_list set artist of t to rightName end repeat end tell

Yes, I could have used rb-appscript to script from Ruby, which I usually do. But, AE gave me easy access to iTunes’ scripting dictionary, a nice little “Run” button, and an output pane. For this tiny script, I was done before I started to suffocate from being outside the oxygen of my live, open Smalltalk image.

So, thank you Apple, for creating the infuriating AppleScript language, to be written with the puny AppleScript Editor, and for not even making many of your own applications scriptable ([cough] Preview.app) even while evangelizing scriptability to Mac devs in your docs. Today, I was grateful for it all. Editing info on hundreds of tracks was much quicker than writing this post about it

Categories: Tags:
\n