Concurrency with ChanL

Stephen Goss over at the zero bit stream has a great post on concurrency in Common Lisp using ChanL. ChanL is a Common Lisp library that implements the Newsqueak concurrency paradigm. Newsqueak was developed by Rob Pike and is described in this Google talk and a series of papers including Bell Labs Computing Science Technical Report No. 143. These, in turn, were inspired by C.A.R. Hoare’s Communicating Sequential Processes.

I first watched Pike’s talk a couple of years ago and was so impressed that I downloaded the papers and source code for the Newsqueak interpreter. In the end, I never did much with it because it meant learning another language with limited application to the sorts of problems I was working on. ChanL is a win for me because it leverages a language I already know. Best of all, it’s available through Quicklisp so installation is trivial.

Goss gives a simple example of ChanL’s use in his post. He builds a quick application that downloads a list of 4 Web pages in the same time that it takes to download one. Pike’s talk gives several more examples of using the CSP paradigm to solve a variety of problems. The talk, like all of Pike’s offering, is excellent and well worth your time. If you haven’t seen it, I recommend you spend an hour on it even if your aren’t a Lisper or interested in CSP.

Update:

give → gives

Posted in Programming | Tagged | Leave a comment

How I Know I’m a Curmudgeon

I agree with every one of these 20 controversial programming opinions.

Aside:

Does anyone else find it astounding that “vetted” interviewees could not write code to calculate the area of a circle in any language? Or is astounding too weak a word?

Afterward:

There has been a bit of pushback to the original list of 20 controversial programming opinions. Many commentors and posters felt that they weren’t really that controversial. James Hague and Bill the Lizard have published their own lists. I mostly agree with Hague and with about 25% of Bill’s list.

Update: options → opinions

Posted in Programming | 1 Comment

PPTP and MS-CHAP

Just in case there’s anyone left out there who’s still using PPTP as a VPN solution, H-Online has an article warning about serious security problems with PPTP when used with MS-CHAP. Even Microsoft is warning users about the issue. It’s really scandalous that this software is still being used. PPTP and MS-CHAP (even MS-CHAPv2) have long been known to be vulnerable to reasonably easy attacks. MS-CHAP is particularly vulnerable because it uses DES, which has a key size of only 56 bits—much too small by modern standards—that renders it susceptible to brute force attacks. Now CloudCracker offers to crack any PPTP/MS-CHAP connection within 24 hours for $200. It does this by using a specially built server with 48 FPGAs to brute force the entire 256 element keyspace.

If you’re still using PPTP, stop it. Immediately.

Posted in General | Tagged | Leave a comment

Emacs and Bignums

Nic Ferrier has a great post on using bignums with Emacs Lisp. Elisp, of course, does not support bignums but Ferrier has a trick: use the Elisp interface to calc, which does support bignums, to make the necessary calculations.

Ferrier was working on a project that required him to interface with MongoDB. In particular, he had to deal with a datetime field, which is a 64 bit integer. Elisp’s integers are only 29 bits so special sorcery was required. After some research on #emacs, Ferrier solved the problem by using calc-eval. Be sure to follow the link and read about the details. It’s a great solution and shows how it is possible to make bignum calculations from Elisp.

Posted in Programming | Tagged | Leave a comment

Five Lessons From Being Hacked

Every since having Irreal suffer a malware exploit, I’ve been on the lookout for articles that will help me avoid another successful attack. I’ve already posted about several of these and today’s post is another. Since these posts have become a sort of series, I am introducing a new tag, Malware, to label them. As soon as I can get to it, I will revisit the previous posts in the series and add the tag to them as well. That way, anyone else unfortunate enough to suffer a similar attack will have a resource to help them recover and prevent reoccurrences.

Today’s article is from Christian Grobmeier’s blog. Grobmeier recently had his site exploited and shut down by his hosting provider. Like me, he eventually got his site cleaned up and back on-line. His post is about the 5 lessons he learned from the ordeal. One of those lessons—perhaps the most important one—is the same lesson that I learned: keep your blogging software up to date. Related to that is to use static web pages. I got that same advice from some of my wise commenters but have so far resisted it because I love org2blog and the workflow that it enables. Stubborn but foolish, I know.

Another excellent recommendation is to run a script everyday that checks for any changed files. That would certainly have alerted me early on to my exploit.

I’ll let you go over to Grobmeier’s site to see the other suggestions and flesh out the ones I’ve discussed. It’s a good post and worth a read if you have a site that you are maintaining on your own (that is, not something like Blogger where you don’t have to worry about security) even if you haven’t (yet) suffered an exploit. I recommend it.

Posted in General | Tagged | 1 Comment

Arguments against call/cc

Pascal Constanza has a post that points us to an article by Oleg Kiselyow that argues against the call/cc function. Regular readers know that I am an admirer of call/cc so I’m not sure I agree with the idea that call/cc is a bad thing. To be fair, the article doesn’t really say that. Rather, the article argues against the idea that call/cc should be a language primitive that is used to build other control operators.

That said, the article does make good points—especially about memory requirements—and is worth a read by any Scheme lover. I still think that call/cc is a useful and powerful construct but I’m inclined to agree that it probably shouldn’t be put forth as the basis for all other control constructs in Scheme.

Posted in Programming | Tagged | Leave a comment

Some Common Lisp Tip Tweets

Jean-Philippe Paradis over at HexstreamSoft has a very nice set of tweets on Common Lisp tips. For example, 【Meta+xslime-cheat-sheet opens a new frame with useful slime commands and their shortcuts. As Paradis remarks, this is virtually unknown—I sure didn’t know about it.

Another interesting tip uses the ldiff function to return the head sublist from member instead of the tail. Another thing I didn’t know. There’s a lot of good material in these tweets and well worth the time of any Lisper.

He also has some opinions that you may or may not agree with but, again, they’re interesting and he mostly gives his reasons for holding them. All and all a very nice resource.

Posted in Programming | Tagged | Leave a comment

Upgrading to Emacs 24.2

Just a quick note to announce that I just upgraded my Mac (OS X Lion) to Emacs 24.2 from source. The upgrade went without any problems so if you’re on a Mac, there’s no reason to wait.

From the top level Emacs source directory do

./configure --with-ns
make install
sudo mv nextstep/Emacs.app /Applications

and relaunch Emacs. That’s all there is to it.

Posted in General | Tagged | Leave a comment

Impatient Mode

You may have seen some of the posts about Chris Wellons’ Emacs HTTP Server, an HTTP server that operates from within Emacs. Now Brian Taylor has built on that to provide Impatient Mode, an Emacs package that renders an Emacs buffer to your browser on the fly.

Taylor’s post has a video showing Impatient Mode in action. If you’re into instant gratification, you might enjoy using Impatient Mode—it’s a nice application of Wellons’ Emacs HTTP server. It’s probably not going to change your life but it’s a neat hack and can certainly be useful in certain situations. Take a look at Taylor’s post to see if it might be useful to you.

Posted in Programming | Tagged | 1 Comment

The magic-mode-alist

Most Emacs users know how to associate a file type with a major mode by using the auto-mode-alist variable to associate a file extension with a major mode. I recently learned of another way thanks to Xah Lee who posted a note on associating files with a major mode.

It turns out that you can use the beginning of a file to associate it with a major mode in much the same way that the Unix file command determines the type of file from the first few bytes of the file. To do this you add a cons of a regular expression matching the beginning of the file and the major mode to invoke to the magic-mode-alist variable. Lee gives this example to invoke nxml-mode for html files:

(add-to-list 'magic-mode-alist '("<!DOCTYPE html .+DTD XHTML .+>" . nxml-mode))

Emacs checks the magic-mode-alist variable before checking auto-mode-alist so the beginning of file check takes precedence. You can also specify a function instead of the regex to deal with situations too complex for a regular expression.

Lee’s post has a nice summary of all the ways Emacs can associate a major mode with a file so you should give it a look.

Posted in General | Tagged | Leave a comment