views:

274

answers:

3

I saw Michael Sparks's very interesting dissection of Peter Norvig's Spell Checker at the SO DevDays in London and it got me wondering if anyone has attempted to implement this piece of code in another language, say Perl or maybe C++?

+6  A: 

There's a list of implementations in other languages at the end of the article, including one in Perl.

silentbicycle
That's Perl 6, which probably isn't what most people mean by "is it available in Perl?"
Telemachus
Ooh, didn't see that, obviously. (-: But as Telemachus mentioned I be interested to see it in "real" Perl, a.k.a. Perl 5 atm.
Rob Wells
Them's the fightin' words... :)
DVK
+5  A: 

I did this presentation at the Boston DevDays, and I'm kind of disappointed how people focus on the number of lines of code. For example, the C# implementation has a low line count also, but I can't see the algorithm at all for all the noise words in the code.

The point I was emphasizing in the presentation was Python's noise-free nature that let me express an algorithm without a lot of throat-clearing and compiler-consoling.

I understand that people will disagree on that point, though, and that there's a bit of "no accounting for taste" involved here.

Ned Batchelder
@Ned, that is such a relevant point for me. The comparatively clutter free nature of Python vs. the essential "background noise" that must be present for so many other languages, e.g. braces and other artifacts of "compiler-consoling" as you put it. BTW Nice term! (-:
Rob Wells
Oops. Forgot to say in that comment that that was one of the points that Michael made early on in his presentation. The lack of clutter in the code and the way you could easily see what was going on from an algorithmic perspective. I think he said that it was one of the reasons that made him switch from Perl to Python iirc.
Rob Wells
The longest line in the Python implementation is 85 characters (incl 4 spaces of indentation), while the longest of the C# implementation is 243 (incl 8 spaces of indendation). Would the C# implementation be accepted as production code?
kaizer.se
@kaizer.se - That's why lines of code is such a misleading metric. The byte size of source (optionally gzipped), while still far from perfect, will compensate for major discrepancies in line length.
silentbicycle
+1  A: 

Uh, I did it as an exercise. Had to use hashes instead of them nifty dict objects; yep, it is a little cumbersome, but not that much.

Leonardo Herrera