Monday, May 28, 2007

Concurrent Programming

This is my reply to a question posted to slashdot: "Is Parallel Programming Just Too Hard?"

The problem with parallel programming is we don't have the right set of primitives. Right now the primitives are threads, mutexes, semaphores, shared memory and queues. This is the machine language of concurrency - it's too primitive to effective write lots of code by anyone who isn't a genius.

What we need is more advanced primitives. Here are my 2 or 3 top likely suspects:

  • Concurrent Sequential Programs - CSP. This is the programming model behind Erlang - one of the most successful concurrent programming languages available. Writing large, concurrent, robust apps is as simple as 'hello world' in Erlang. There is a whole new way of thinking that is pretty much mind bending. However, it is that new methodology that is key to the concurrency and robustness of the end applications. Be warned, it's functional!

  • Highly optimizing functional languages (HOFL) - These are in the proto-phase, and there isn't much available, but I think this will be the key to extremely high performance parallel apps. Erlang is nice, but not high performance computing, but HOFLs won't be as safe as Erlang. You get one or the other. The basic concept is most computation in high performance systems is bound up in various loops. A loop is a 'noop' from a semantic point of view. To get efficient highly parallel systems Cray uses loop annotations and special compilers to get more information about loops. In a functional language (such as Haskell) you would use map/fold functions or list comprehensions. Both of which convey more semantic meaning to the compiler. The compiler can auto-parallelize a functional-map where each individual map-computation is not dependent on any other.

  • Map-reduce - the paper is elegant and really cool. It seems like this is a half way model between C++ and HOFLs that might tide people over.

In the end, the problem is the abstractions. People will consider threads and mutexes as dangerous and unnecessary as we consider manual memory allocation today.

Friday, May 18, 2007

So you are a screen user

So you are a screen user on linux but your workstation is a Mac. You probably run into the backspace problem constantly. Specifically you ssh to your Linux box, the backspace works, but once you attach to screen now you get all sorts of problems. One solution is to

stty erase ^?
but backspace doesn't work for screen commands.

The real problem is there is a mismatch between OS X terminal and the TERM string it sets for itself. There are two solutions. Solution #1 is to do this when you login:
export TERM=xterm
The other solution is to do these commands on your Linux box:

cd ~
mkdir -p .terminfo/x
cd .terminfo/x

The problem is the xterm-color by default on Linux mismatches backspace codes with what Terminal does on OS X. You might think that using the "delete key sends backspace" option in Terminal window settings might do the trick, but sadly no.

Thursday, May 10, 2007

Guitar Hero

I've owned Guitar Hero and Guitar Hero 2 since last November. At first when I got the game, I was at a "medium" level. I've been practicing at the "hard" level recently. I realized that I have broken through to a new plateau. I realized this when I noticed that I had played nearly every song in hard mode in both games.

I have figured out the elements of this skill. There seems to be two extra abilities. The first is being able to move my fingers really fast. When those notes are zipping down so quickly you really need to be able to reposition fast. Secondly the ability to handle all 5 fret buttons with 4 fingers without looking.

For example if you're doing a reverse crescendo, you hit the orange fret with the pinky, then blue fret with the ring, yellow fret with the middle, and the red fret with the last index finger. Now you're out of fingers, so slide the index finger to the green fret and you're done. This siding action is the essential ingredient to handling 5 fret buttons with 4 fingers.

I'm not exactly sure how I developed these skills, other than only playing hard songs. I guess practice really does make perfect (almost, soon).

I wouldn't say that playing Guitar Hero is similar to playing the actual guitar - I don't play the actual guitar, but I had some experiences recently that leads me to believe there is some transferable skills. Here in Seattle we have the Experience Music Project, which has a cool permanent exhibit called the Sound Lab. The lab has a bunch of instruments in a computer guided tutorial setup. A few years ago I did the guitar tutorial, I remember it being cool but I didn't get much out of it then. I recently went back and tried it again, and the intro tutorial seemed distinctly easier than last time.

I figure this is because I had practice at maintaining a rhythm with my right hand and moving my left hand quickly. While I don't actually know chords or any guitar specific real skills, I definitely think the base skill helps somewhat. Of course without actually learning the guitar, I guess I'll never know.

Wednesday, May 02, 2007

Fountain pen aesthetic

I enjoy the idea of a fountain pen aesthetic. To go along with the mechanical watch obsession, is a minor fountain pen obsession. To date I own two fountain pens, my original, which is a Waterman steel nib. But my crown jewel is my Namiki retractable fountain pen - as far as I know the only retractable fountain pen model in existence. I love my Namiki because it has an extra-extra fine nib which is generally hard to find in fountain pens. Additionally it was relatively inexpensive yet still has a gold nib. The difference between the gold and steel is difficult to understate. Combined with my indelible ink, I have a pen that is acceptable for all writing, including checks and mail.

I think pens, especially fountain pens, represent the ultimate single-object characterization of what it means to be human. Humans excel at abstract thought, fine motor control, aesthetics and communication. All of these manifest themselves in the fountain pen. I threw aesthetics in there to justify a fountain pen over a regular pen, mostly because I really dislike the idea of a disposable culture. There is a certain craftsmanship and history to fountain pens, ideas that generally don't have an equal elsewhere in the animal world.

So often newer computer users forget about the power of the pen and paper. The free-form unconstrained and rapid creation really rivals all other mediums for idea creation. If I wanted to insert a diagram of a pen, it would be fairly difficult in this blog. However if I was writing it on paper, I could do nearly anything I wanted, drawing skills aside. The closest computer equivalent would be the tablet PC, but I can't really deal with a PC right now.

Besides which, paper makes an excellent archival medium. In 100 years will people be pouring over the electronic correspondence of the greats of our time? Given how much data people carry on their personal computers, it might be, but it doesn't have quite the same ring to it as reading the personal correspondence of Albert Einstein. Or reading the notebooks of Da Vinci. So my personal stand is to attempt to create paper-based notebooks of ideas and thoughts. So far I'm not really successful, mostly because my notebook hides in my bag, but perhaps I just need another one for my desk as well?

Tuesday, May 01, 2007

Quoting The Seattle Stranger:

"The atelier system - of extended apprenticeships in the studios of master artists - is an old European tradition, spanning back to the Renaissance and up[.]"

This is in reference to an art school in Seattle.

The MIT AI Lab was a computer science form of this structure. With the demise of such places, including the NCSA Supercomputing Center, how do we train master programmers? It seems that we are currently relying on luck.