a glob of nerdishness

May 30, 2007

Microsoft Surface takes a step forward

written by natevw @ 2:16 pm

First, there were Jeff Han’s demos. Then the iPhone. Then the rumors. Now, Microsoft’s contribution to the party has surfaced, and it’s called: Surface. Welcome to the social.

The demo videos on both Microsoft’s site and Popular Mechanic’s Microsoft Surface video and article leave one a little ho-hum at first — it’s strange how pushing pictures around with two fingers already looks normal. The interactions shown are surprisingly minimalistic for the most part, which is a bit odd for Redmond. Yet the technology goes beyond multi-touch. Cameras and phones can be used in a whole new way. In the demos, pictures are copied off a camera without any wires, wizards, or self-congratulatory popups about “New Device Found, click me to resume your work”! Just physically plop your device onto the screen, and start dragging things in and out of the device itself.

That is an intuitive simplicity that Apple cannot afford to ignore. Of course, Microsoft’s device is starting life as a posh vending machine, and by the time Windows Vista Superb Plus Zurface Edition comes out the user interactions might start taking on their familiar Microsoft-style tackiness. Yet how long until users are ready to ditch the WIMP style interfaces of the past decades for a new upstart’s design? Where could a company take ripening technologies like multitouch screens, wireless peripherals, hypermedia influenced semantics and a touch of Raskin-esque zooming if they weren’t chained down by last year’s model?

Update: Walt Mossberg asks Steve and Bill similar questions throughout his interview, especially addressed in Part 5 of 7.

May 25, 2007

Apache-less SVN: Subversion between two Macs via SSH

written by natevw @ 6:55 pm

My first Mac, an original G4 mini, hasn’t seen much use since my new iMac arrived last summer. Hoping to start “spare-time” developing again, and now addicted to version control through work, I made it my goal one afternoon to get Subversion running between the old and the new. Eventually I’d like to expand this beyond source code to a home directory or even a .Mac backend, depending on what Leopard ends up offering.

Apple has an article on compiling a full SVN stack on OS X for use with Xcode. This looked a little bit more painful than I was aiming for, for some reason involving hand-patching Apache 2.0 and plenty of configuration. That route is spelled out nicely (1), but I wanted something even simpler.

Enter Martin Ott and his ready-made Subversion installer packages. Here’s how you can set up your own low-carb Subversion system, hopefully in less than 30 minutes.

Install SVN

Download the SVN package and install it on both your server and your client machines. It will ask you for your password, and then install several binary utilities in /usr/local/bin. This does not include any Apache modules but it does include a standalone daemon named ’svnserve’. This means no WebDAV access, but you can easily use svnserve with ssh to access your data securely across a network.

Configure paths

Unfortunately, programs in /usr/local/bin aren’t easily used by default. The next step is to get the utilities into your Terminal path. On your client machine, just add export PATH=$PATH:/usr/local/bin to your ~/.bash_profile file. For access via SSH to work, the server needs that same line but added the machine-wide /etc/bashrc configuration instead of your user’s profile. For this, you will need administrator privileges, something like sudo pico /etc/bashrc should do the trick. (Alternatively, you could cd /usr/bin/; sudo ln -s /usr/local/bin/svnserve to avoid editing bash’s global configuration. In this case, also configure your user account on the server just as you did the client, because in the next step we use another utility via that path.)

Make a repository

The repository is where all your past and present data will be stored on the server, accessed via the SVN tools. Pick a spot where you don’t mind an extra folder sitting around, and execute on the server machine: svnadmin create ~/repository. Feel free to change the path, as given it will make a new “repository” directory in your home folder and fill it with files. These internal files should generally not be used directly, we’ll test the SVN commands in the next step.

Accessing the repository

Make sure you have “Remote Login” enabled in System Preferences > Sharing on the server machine. If not, enable it, and you should be ready to go back to the client machine. “Check out” your new (empty) repository with this command: svn checkout svn+ssh://your-machine-name.local/Users/yourname/repository new_local_folder. After giving your ssh password a few times, you should find “new_local_folder” copied into the current path.

Beyond…

If you’re not familiar with SVN commands themselves, the maintainers provide a top-notch Subversion Book that is both tutorial and reference. Also by now, you’re probably sick of typing your ssh password. You can improve this by using authorized keys and ssh-agent. The previously linked Apple article finishes with a section titled “Xcode and Subversion”, though there might be an incompatibility between Xcode and the latest SVN software. Let me know how it goes if you make it that far, or get stuck along the way!


  1. Unlike the error messages from Fink trying to update a previous Apache2/SVN install. I gave Fink the ‘rm -rf /sw’ treatment, and now I feel better.

May 23, 2007

Xcode Regular Expression replacement

written by natevw @ 7:55 pm

Thanks to “Search and Replace in Xcode” at Noodlesoft’s blog, I learned how to use RegEx grouping in Xcode’s Search and Replace. In short: \1 instead of $1. Now I can convert the wiki-formatted tables of Kyōiku kanji into a Quisition flash card pack.

May 19, 2007

Scratch

written by natevw @ 1:38 pm

Scratch, designed at MIT, has been making a splash in major news outlets lately. The Scratch project is basically Xcode meets YouTube for games. Sounds strange, but it’s a combination of a desktop-based integrated development environment and a community-based game sharing site. In order to pull this off, the designers developed a programming language that succeeds at being both simple and powerful.

When I saw the headline in the middle on BBC News, I was instantly suspicious:

Scratch front page BBC News

The picture was an instant reminder of Lego Programming hype. (Interesting aside: if you google lego block programming, the BBC article takes second place to that very post!) The article itself is less sensational, toning the headline down to “Free tool offers ‘easy’ coding” and revealing that it is actually a desktop application that allows creation of games.

Trying it out

Feeling that this had all been attempted before, I didn’t think much more of it until I got a note from Hannah, who had also seen the article: “Would this help me understand you?” I guess it’s worth a shot! She downloaded it, and together we figured out how to get the thing started. The cryptic “Open” dialog box was a bit rough, but after we figured out we needed to select the Scratch.image file, she was on her way.

As I watched her learn the “language”, I became impressed with its enlightened design. Scripts are indeed built from graphical pieces, but the process is much more powerful than a mindless succession of commands and much less tacky than drawing flowchart lines. The user can nest commands into control structures and insert test questions into conditionals. Like an open-ended puzzle, the shapes and colors of these “building blocks” give subtle clues as to what pieces may be missing.

Impressive simplifications

Programming in Scratch is a completely interactive affair. The user can attach a number of independent scripts to graphical sprites. Each script is started by one of many available triggers. These triggers are always active, despite the presence of a green flag (just another trigger option) and a stop sign (just an emergency kill switch) in the interface. The interactivity goes deep — there isn’t even an “initial stage”. What the user drags around with the mouse and what gets moved via a script are on equal footing. This is a daring move, forcing the explicit scene initialization in some cases, but greatly simplifying the user model. This is just one of many well-executed simplifications. Variables are also made accessible to beginners, being visible by default and having at most two scope options.

As mentioned before, scripts are attached directly to sprites, meaning that in lieu of a master “puppeteer” script, the sprites are essentially autonomous. All scripts run concurrently upon being triggered. This is the coolest simplification, and also means parallelization becomes an integral part of this beginner’s programming language! Concurrency is heavy wizardry when tacked into many programming models, but is very intuitive in the context of sprite objects. The cat has ideas and the mouse has its own. While shared variables can be used to communicate between scripts (and are an easy concept for beginners), there is also a global message broadcast system. Scripts can broadcast messages, asynchronously or synchronously, which are received by all scripts that are triggered by that particular message.

Wide audience

Scratch doesn’t just encourage algorithmic thinking with the usual control structure and variable concepts. It also teaches important parallelizing patterns that “real” programmers typically encounter only in still-esoteric languages. Scratch can help my wife understand my field, and I hope it can be effective for younger learners. (With hardly any clues from me, Hannah made a reasonably involved Island Rescue game after only two other experiments.) The publicity is justified. What came as further surprise is that it can inspire my programming patterns and design strategies too! Well done, MIT!

May 12, 2007

Subtle bugs stink

written by natevw @ 7:20 am

Consider the following piece of code, to process hex color strings:
sscanf(text, “#%2x%2x%2x%2x”, &rgbcolor.r, &rgbcolor.g, &rgbcolor.b, &rgbcolor.a);

Looks pretty standard, eh? Well, that piece of code cost a day’s work. I was getting segmentation faults in std::list’s iterator post-increment. The iterator had no clear reason to be invalid, although the debugger did show bad values (0×0 or 0xbf000000 for the _M_node internal pointer it was trying to dereference). I copied my project, and hacked it down to a smaller main code path. Strangely enough, the presence the constructor for an otherwise unused class was the shibboleth that determined whether my code crashed or not. Suspecting a compiler bug (how pride resists being wounded!), I tried all manner of settings (optimization, static vs. dynamic linking) before I finally went back to said constructor. Lo and behold, when the constructor called a code path that involved the sscanf above, std::list exploded. When not, it was fine. What on earth?

Well kids, this is why C-style formatters are considered harmful. Sure I had four %x’s and four variables, but “%x”es expect ‘int’ and my variables happened to be ‘char’s underneath a typedef. So the problem was not in std::list, not in the derived class, not in my main code and not even directly in the constructor that clued me in.

Using C++ stringstreams can be a pain, but so is debugging things like this. I wonder if that’s why C++ often gets a bum rap.

May 8, 2007

Rotating cylinder lift

written by natevw @ 9:17 pm

Did you know a rotating cylinder can generate lift? It’s not very efficient, but it has been used to propel a ship across the Atlantic. I learned this strange bit of trivia through an electrical engineering friend who is now a broadcast radio technician. Spending time climbing to the tips of tall radio towers on a regular basis, I guess any source of lift is just cause for excitement.

Lift of a Rotating Cylinder on a NASA education page has the real skinny, but from what I gather (and correct me if I’m wrong) the cylinder needs to be moving “into the wind”, relatively speaking. The key is that the moving surface of the cylinder tends to drag some air along with it. If the bottom is moving against the oncoming stream, it will be slowing the air below while the top stream is helped along. Slower on the bottom, faster up top? Mix in a little Bernoulli and it’s up and away!

A better plan for spam? [academic version]

written by natevw @ 11:36 am

I was going to also publish an even lengthier version of the “A better plan for spam?” article I wrote up. It tried harder to defend all it’s points, and to make sense to a wider audience.

However, after reading the nerd version, my wife said it made a whole lot more sense than did the windier “academic version”. I guess I’d make a better Dijkstra than Dooyeweerd. Fair enough! Since publishing the ‘nerd’ version, I’ve gotten some insightful comments — thanks and keep them coming as long as you’d like! Meanwhile, this is not the blog of schoolishness and the end of this post is right here ->.