The Last Hacker

A few weeks ago someone posted a link to Richard Stallman’s Speech at the 2002 International Lisp Conference. It’s an interesting read that, among other things, recounts the story told in the Epilogue to Steven Levy’s Hackers about RMS single handedly (and independently) duplicating every improvement and bug fix made by Symbolics and then giving them to LMI. This was to avenge what he felt was Symbolics and Russ Noftsker‘s betrayal of the MIT AI Lab and Hacker Culture. It was fun, after almost 25 years, to read that story again.

Also interesting is Stallman’s history of early Emacs. Most of us have probably heard a lot of that story before but it’s nice to hear a cohesive history by someone who was there. The original Emacs didn’t have a Lisp interpreter in it, but rather was built on top of the TECO command language. It was Dan Weinreb who first implemented Emacs on top of Lisp. Later, James Gosling wrote an Emacs that had low level functionality written in C and the higher level routines written in a Lisp-like language called mocklisp. Eventually RMS wrote the first of the modern GNU Emacs.

If, like me, you’re fascinated by the history of our (hacker) culture and you haven’t read this story before, it’s definitely worth a few minutes of your time. And, of course, if you haven’t read Hackers you should immediately do so. It’s a wonderful story of our history starting from the time of the Tech Model Railroad Club at MIT and ending in 1983 with the story that RMS relates in his talk at the 2002 ILC.

Posted in General | Leave a comment

Scrolling Emacs by Line

The other day, I stumbled across this post over at Anything goes about scrolling up and down by line in Emacs. The poster gives two simple functions and some key bindings to scroll a window up or down a line. In the comments, Jürgen notes that 【Ctrl+v】 and 【Meta+v】 are already bound to scrolling the window and that you can scroll by line instead of page by giving a prefix argument. Thus, to scroll down one line you would type 【Ctrl+u 1 Ctrl+v】 or even easier 【Ctrl+1+v1.

This is often convenient when you’re editing and want to see a few lines above the top of the window or below the bottom of the window. I used to do that by using 【Meta+r】 to move the point to the top/center/bottom of the window and then move the point up or down to scroll a line or two. That worked OK, I suppose, until I started using paredit, which rebinds 【Meta+r】 to paredit-raise-sexp. That made using 【Meta+r】 to scroll useless when editing Lisp or Scheme files so I would generally scroll up or down a page to see those hidden lines.

Adding a prefix to 【Ctrl+v】 and 【Meta+v】 to scroll by line is one of those things I’m sure I learned in the past but had forgotten. I’m glad to be reminded because it’s surprising how often the need to do so comes up.

Footnotes:

1 If you’re on a Mac and are using Spaces, you may have to change the Spaces preferences to use 【⌘ Cmd+num】 instead of 【Ctrl+num】 to switch to a specific space. That’s because OS X will intercept the 【Ctrl+num】 and Emacs won’t see it.

Posted in General | Tagged | 3 Comments

The Common Lisp Loop Macro

I don’t like the CL Loop macro. I’m not alone on that; Paul Graham isn’t a fan either. On the other hand, Peter Seibel has a more positive view of them. That two accomplished and intelligent Lispers can disagree on the matter indicates that neither view is right or wrong, merely a matter of taste.

My two main objections to them are

  1. It’s not lisp
    If I wanted to write in TCL or AppleScript or something, then I’d write in that language instead of Lisp. I really like Lisp s-expressions and see no reason to go out of my way to avoid them.
  2. There’s no real specification
    The loop facility is almost always documented by examples. As Graham says, its specification, to the extent that it has one, is the implementation. All this means that they are hard to understand and apply to situations that aren’t one of the patterns covered by the examples.

Loop partisans often claim that writing iteration is more concise with the loop macro and this is sometimes true (although I would argue that the code is less clear) but not always. Here’s a case in point. We’re offered some loop macro code that checks if any Emacs buffer file name contains the word projects. This was intended to replace a long and complicated function that the poster had seen on another blog. When I first saw this, lots of different ways to do it in normal Lisp popped into my head and this post was originally going to be about how we could write a function to make this check in regular Lisp and still be just as concise.

But then I followed the link back to the original post and saw this elegant solution in the comments

(some (apply-partially 'string-match "projects") (mapcar 'buffer-name (buffer-list)))

That truly is a thing of beauty1. The iteration is implicit in the some function and the apply-partially makes a lambda construct unnecessary.

The some function is standard in CL but not in Scheme. Because it is handy and often just what you need, I thought I’d implement it in Scheme and add it to my standard library.

;; Return #t if pred? is true for at least one
;; member of seq, #f otherwise.
(define some
  (lambda (pred? seq)
    (cond
     ((null? seq) #f)
     ((pred? (car seq)) #t)
     (else (some pred? (cdr seq))))))

As you can see, it’s trivial to implement.

The apply-partially function is more interesting. It’s like

(f a1 a2 ... an)

except the first few arguments are fixed. What happens is that

(apply-partially f a1 a2 ... ak)

returns a new function that accepts the remaining (non-fixed) arguments and then applies f to all the arguments. Thus,

(apply-partially 'string-match "projects")

returns a function that checks if its argument contains the word projects.

Strangely enough, it’s harder to explain than to implement:

;; Make a new function that applies f to
;; the x arguments and its input
(define apply-partially
  (lambda (f . x)
    (lambda y
      (apply f (append x y)))))

Footnotes:

1 The original poster points out that the above code checks the buffer’s name not the name of the file associated with the buffer. The commenter responds with another version, which is a bit more complicated but still elegant and much nicer than the loop solution.

Posted in Programming | Tagged , | Leave a comment

Still More Password Analysis

Three more bloggers have weighed in with an analysis of the 62,000 passwords that LulzSec released recently. These three analyses take a look at the structure of the passwords and have some interesting details that I hadn’t seen before.

Aviv Ben-Yosef and Rafe Kettler take a look at the complexity of the passwords. As you might expect, the results are not encouraging, although the average length is 7.63, which is higher than I would have thought. Here are some startling results from Kettler

  • 43.108% of the passwords were all lower case
  • 19.536% of the passwords were all numeric
  • 36.914% of the passwords had some mixture of lower case, uppercase, numbers, and symbols (although not necessarily all of those types)

Over at R-bloggers, Colin Gillespie takes a slightly deeper look. He considers those passwords that would not fall to a simple dictionary attack and investigates their structure. It’s fairly intuitive that some characters will be used more than others and he drills down on that. Among other things, he discovered that

  • 20 characters (out of 78) cover 25% of the passwords
  • 27 characters cover 50% of the passwords
  • 31 characters cover 80% of the passwords

As Gillespie dryly remarks, if you’re trying to crack passwords, it’s clear that brute force is not the way to go. We users can also take away a lesson from this. If you want passwords that are hard to crack, it might be worthwhile using the less popular characters.

There are lots of other interesting results in these posts so if you’re interested in this sort of thing you should take a look.

Posted in General | Tagged | Leave a comment

Reeder

I follow a large number of technical blogs (emacs-fu, research!rsc, Abstract Heresies, …) and aggregators (Planet Scheme, Planet Lisp, Hacker News, …) that I read everyday and in some cases several times a day. Most of the blogs are not updated daily so an RSS reader is essential for keeping track of new entries. For years, I’ve just used Safari for this and that worked well but I have three devices (an iMac, a MacBook Pro, and an iPad) that I use regularly.

There are two problems with that:

  • Keeping in sync
    This is especially a problem with the aggregators. If I read some stories on, say, my MacBook and then move to the iMac, I’d like to have those stories that I’ve read on my laptop be marked as such on my iMac. Safari almost does this but it’s not quite accurate enough. Sometimes the two lists will be considerably out of sync.
  • Safari’s RSS on the iPad
    It’s terrible. You can’t sort the same ways that you can on the Macs and it does not appear to sync with the other non-iOS devices.

Recently Reeder, an excellent iOS RSS reader became available for the Mac as well. It’s a Google Reader client so the synchronization happens automatically and seamlessly. Almost all the reviews of Reeder on the App Store rated it excellent with only a few dissatisfied users. It seemed like a good solution for both problems, so I downloaded the iPad and Mac versions and moved all my subscriptions over to Google Reader.

I’ve been using Reeder for a couple days now and I’m quite pleased with it. There are keyboard shortcuts that make stepping through the posts very easy and it makes excellent use of the gesture capabilities of my Magic Trackpad. My only complaints so far are that there’s no way to export to Evernote and I’d like to be able to bookmark some of the entries in Safari. There are a lot of complaints about not being able to export to Evernote so I expect that that feature will be added soon. I don’t know if anyone else wishes they could bookmark stories so that may never be added. There’s a fairly easy workaround to both of those problems: you can press 【B】 and open the story in your browser so that you can export it to Evernote or bookmark it from there. That’s a little clumsy but only a little.

All-in-all I’m happy I changed to using Reeder. It’s making my browsing much more enjoyable, especially on the iPad. The only downside that I can see is that I’ve surrendered my reading list to Google. Of course, they already know pretty much everything I do on the Web so there wasn’t a lot to surrender.

Update: Dr. Elliot Jaffe says I shouldn’t worry about Google.
Update 2: IOS → iOS

Posted in General | 1 Comment

Mac OS X Modifier Key Symbols

When I first started using Macs, one of the things most confusing to me were the symbols that OS X uses on the menus to indicate the keyboard short cuts:

http://irreal.org/blog/wp-content/uploads/2011/06/wpid-menu.png

Eventually, I learned what these symbols meant

Symbol key
Command/Apple
Option
Delete
Shift
^ Control

The ⇧ is obvious and the ^ is the usual symbol for the control key; the ⌫ is almost as obvious as the first two. The ⌥ key is the hardest one to figure out until you look it up in a unicode chart and discover that its name is “OPTION KEY.” So that symbol makes sense once you learn its name.

The ⌘ wasn’t difficult at all because it’s printed right on the command key but when you look up its name you find “PLACE OF INTEREST.” Huh? What does that have to do with command or Apple or anything else? I just put it down to one of the mysteries of the universe until I saw this post by Andy Hertzfeld over at Folklore.org. In it, Hertzfeld explains how that symbol came to be chosen for the command key. It’s an amusing story and I won’t spoil it for you by giving it away—head over to Folklore to see for yourself.

Posted in General | Tagged | Leave a comment

Drawing Keyboard Keys

Those of you who followed my recommendation and took at look at Xah Lee’s Increase Productivity Using Function Keys post, may have noticed some neat CSS magic that he uses when writing about keyboard keys. For example, he says that to switch apps on the Mac you use the 【⌘ Cmd+Tab】 key sequence. I like that a lot and decided to try it out on my own. As it turns out, it’s pretty simple to do and Org-mode makes it easy to enter them into a post with a macro.

If you look at the HTML for this post, you will see that the keys above are rendered as

<span class="key">⌘ Cmd</span>+<span class="key">Tab</span>

so to draw a key we merely enclose it in <span class="key"> </span> tags. We can implement that easily with an Org-mode macro:

#+MACRO: key @<span class="key">$1@</span>

and then call the macro for each key we want to draw. For example, the source code for the line with the keys is:

…use the 【{‍{{key(⌘ Cmd)}}}+{‍{{key(Tab)}}}】 key sequence. I like that a lot and…

That leaves only the CSS. Here’s what I’m using:

.key {
        border:solid 1px #989898;
        background-color: #F4F4F4;
        padding-left: .25ex;
        padding-right: .25ex;
        font-family: monospace;
}

You can experiment with the colors and spacing to get something that looks pleasing to you if you don’t like my scheme.

The only downside to this for me is that I have add the CSS directly to my site’s CSS file rather than include it in the post itself. That’s the proper thing to do, of course, but every time I upgrade WordPress they overwrite the template file with my extra CSS and I have to reapply it. Of course, it’s entirely likely that there’s some way to make a permanent addition but I haven’t found it yet.

Posted in Blogging | Leave a comment

Increased Productivity With Function Keys

Xah Lee has a self-confessed obsession with keyboards. He’s particularly interested in their ergonomics and features that can enhance productivity. Not everyone agrees with his take on these things but his views are thoughtful and often useful. In a recent post he addresses ways in which the underused function keys can help increase productivity.

For example, Lee points out that most of us spend the majority of our time in 3 or 4 applications: editor, browser, mail, say. He recommends dedicating some function keys that will switch directly to these apps. The normal way of doing this is with ALT-TAB or CMD-TAB but this requires multiple keystrokes and that you look to see which app you switched to and perhaps TAB some more to get to the right one. By assigning a function key, only a single keystroke is required.

Lee has more suggestions for how to enhance productivity with function keys and also discusses how to assign them under Windows and Mac OS X. It’s an interesting post and if you care about keyboard shortcuts that can speed things up, you should head on over and take a look.

Posted in General | Leave a comment

Lisp in a Production Environment

Over at the Symbo1ics Blog, Robert Smith has a nice post on the myth that Lisp is inappropriate in a production environment. He says that, like many others, he believed that while Lisp is flexible and expressive it would not be good in a production environment. He give the usual reasons for having believed this:

  • Too many programming paradigms are supported (functional, imperative, object oriented, …) and so the large teams you find in production environments would have programmers using different paradigms resulting in confusion and incomprehensible code.
  • Everyone would create their own macros, again leading to confusion and incomprehensible code.
  • The semantics and flow of the code would not be uniform enough.

In short, the power and flexibility of Lisp would lead to the disintegration of programmer discipline.

But then he took a new job that used Lisp exclusively and had a code base of several hundred thousand lines of code. He found to his delight that understanding the code, while a challenge at times, was no harder than in any other similar environment with a different language. This despite the fact that many of the original developers were no longer at the company.

Head on over to the post and read how Smith found all the reasons that Lisp wouldn’t work in a production environment to be false. Then bookmark the post for the next time someone tries to explain how “Lisp is all well and good but it’s completely impractical in the read world.” It will give you something to point at besides ITA.

Posted in Programming | Tagged | Leave a comment

The Greatest Hack of All Time

I just saw a reference to one of my favorite papers on computer security. It’s Ken Thompson’s Turing Award Lecture, Reflections on Trusting Trust. In it he describes what the Jargon File calls a truly moby hack: the insertion of an invisible back door in Unix.

If you haven’t read this you should do so without delay. It’s short and will astound you. The even shorter version is that Thompson added code to the C compiler to recognize when the Unix login function was being compiled and insert additional code that would accept a special password in addition to the user’s normal password. That’s the back door but there’s nothing very exciting or clever about it. The clever part is that he also added code so that the C compiler would recognize when it was compiling itself and insert the code to add the back door. Finally he recompiled the compiler, removed the two additions from the source and recompiled the compiler again.

At this point, the compiler would insert the back door whenever the login function was compiled and if the compiler itself was compiled it would insert the two pieces of code into the new compiler. However, if you looked at the source code for the compiler there was no indication of what was happening in the binary.

The modified compiler was distributed to the Unix Support Group and although Thompson says that it was never deployed outside the Labs, there is a story that BBN somehow ended up with a copy. I recall, but can not find the reference, that the support group eventually discovered that the compiler had been hacked by looking at the assembly code.

Again, if you haven’t read Thompson’s paper I urge you to. Of course, after you do, you will never trust any piece of software again.

Posted in General | Tagged | Leave a comment