Oh, how quickly we forget. Or to put it another way, how stupid I am. Or to put it another way, what a fickle language whore I am.
Further to my recent joy regarding Haskell, Stephen Judd appeared from nowhere and reminded me that of course, Python also handles arbitrary-length integers “out of the box”. How the hell did I forget that?
In fact, he went one better and gave me a single line of Python for calculating 10,000 factorial, viz:
reduce(lambda x,y:x*y, range(1,10001))
Admittedly this is harder to grok than the Haskell version:
bigFac :: Integer -> Integer
| n == 0 = 1
| n > 0 = n * bigFac(n-1)
(at least, without knowing the semantics of reduce) – but it does also seem to run a bit quicker on my box.
Hurrah for Python!
Of course, this all just reminds me that I’m spending too much time lately thinking about theoretical computer science, and not enough time getting my hands dirty programming… :-/
Update 2007-01-26: Of course, the python version is not easier to grok than this alternative Haskell version:
Now that’s beautiful, as is the definition of product.
Stupid Security [risks] — chronicling the stupidity that passes for “stronger security” post-September 11.
Also: Internet attacks jump significantly this year.
… in the first six months of 2004 there were at least 1,237 newly discovered software vulnerabilities and almost 5,000 new Windows viruses and worms capable of compromising computer security. … Even more troubling was the sharp rise in the number of “bot,” or robot, networks, which comprise a large number of infected PCs that can then be used to distribute viruses, worms, spyware and spam to other computers. The survey notes that in the first half of 2004, the number of monitored botnets rose from fewer than 2,000 to more than 30,000. The botnets, which range in size from 2,000 to 400,000 “zombie” machines, are often “rented out” to commercial spammers who use them to distribute junk e-mail while concealing their identities.
Thought-provoking reading, by a Professor of History, which might give you some idea of what life is like in Iraq right now: What would America look like if it were in Iraq’s current situation? [null]
The population of the US is over 11 times that of Iraq, so a lot of statistics would have to be multiplied by that number. …
There are estimated to be some 25,000 guerrillas in Iraq engaged in concerted acts of violence. What if there were private armies totalling 275,000 men, armed with machine guns, assault rifles (legal again!), rocket-propelled grenades, and mortar launchers, hiding out in dangerous urban areas of cities all over the country? What if they completely controlled Seattle, Portland, San Francisco, Salt Lake City, Las Vegas, Denver and Omaha, such that local police and Federal troops could not go into those cities?
What if, during the past year, the Secretary of State (Aqilah Hashemi), the President (Izzedine Salim), and the Attorney General (Muhammad Baqir al-Hakim) had all been assassinated?
What if no one had electricity for much more than 10 hours a day, and often less? What if it went off at unpredictable times, causing factories to grind to a halt and air conditioning to fail in the middle of the summer in Houston and Miami? What if the Alaska pipeline were bombed and disabled at least monthly? What if unemployment hovered around 40%?
No answers, just a lot of rhetorical questions which, if you’ve got any imagination at all, paint a very depressing picture…
Why Haskell is cool (again). Over a year ago I was mucking around Haskell but didn’t get deeply into it. Today I picked it up again, and while playing around with tutorials did something which, in my geeky way, I find cool.
With four lines of code, and with no more knowledge than a beginner has, I was able to calculate 10000 factorial. (For my non-mathsy readers, that is, 10000 times 9999 times 9998 times 9997 … times 3 times 2 times 1).
This is a Very Big Number (it’s here if you don’t believe me), and until today I haven’t come across a programming language which can even represent/work with anything this large “out of the box”. I’m sure there are other languages which can – I just haven’t met them. It’s interesting.
It took about seven seconds to work it out. Nifty.
Good Things Lately:
I wish I was innumerate rather than illerate, so I had a chance of explaining to you why Jasper Fforde‘s The Eyre Affair is the most refreshing and amusing book I’ve read in a long long time. Set on a slightly alternate Earth in which literature occupies the place popular music does on our Earth, in which England and Russia have been fighting the Crimean War for 130 years, and in which our heroine (the delightful Thursday Next) strives to catch the second most wanted man alive, save her aunt from inside a Wordworth poem, fix the end of Jane Eyre (by journeying into the original manuscript), and remember to look after her pet dodo (an early model). It’s fantastic – if you’re a fan of Pratchett, Tom Holt, Robert Rankin, or hey, why not throw Douglas Adams in here too, I promise you’ll love it. It’s chock full of the kinds of suprising and fantastic twisted ideas that Pratchett used to have, back when he had new ideas. Much fun.
Seriously. Check out the author’s website to get a feel for what I’m on about. Look: toast!,
Also amazing: Solaris. No, not the operating system, no, not the George Clooney film, and no, not even the original film of which that was “merely” a (rather good apparently) remake. I’m talking about the book. It’s mind-blowing. A great example of sci-fi being used merely as a palette with which to paint Crazy Ideas.
And finally, Tim Booth‘s new album, Bone. I’m a big big James fan (Bash introduced me to them in our early days, and <hippy>some of their songs just seem to speak directly to my innermost heart</hippy>, which is kinda nice) so the album was eagerly anticipated, but I must say I really wasn’t sure about it for the first few listens… Musically very interesting (layers, suprises, development, yay), lyrically it sounded OK, but vocally it seemed perhaps a little, I dunno, just weak in comparison with his James work.
Sometimes when you buy a new album you love it immediately, and then it wears off and gets a bit dull after a while (Black Cherry by Goldfrapp springs to mind – I still like it, but I hardly listen to it now). Sometimes you dislike it immediately, and it grows into something you’ll love forever (Morning Light by Locust). Sometimes you dislike it immediately and it turns out you were right (Keep It Unreal by Mr Scruff).
Glad to say, I think Bone fits into the Morning Light category. Or as Dave Wyatt would say, “it’s a grower”. Unfortunately, I’m still illiterate and thus unable to properly articulate why I love it. Attempts: the music’s deep, layered, complex, and progressive, yet has a loose, underproduced feel to it; the lyrics are indeed classic Booth – why are we here, why is love hard, everything’s connected, abandon all hope, don’t abandon all hope, etc; the vocals have grown on me – they are different, and perhaps “thinner” than with James, but this new style fits the music just fine. Plus it’s good cycling music.
Tracks to download if you wanna get a feel: “Monkey God”, “Down To The Sea”, “Be Careful What You Say”.
Interviews: one, two. Sorry for the distraction, Bash…
Might as well hop on the meme train, as it’s a goodie… Show Tunes For Freedom! – fantastic. [null]
No sex please, we’re the Welsh Assembly.
An e-commerce website shortlisted for the Welsh leg of the 2004 national e-commerce awards, sponsored by DTI and InterForum, didn’t make it to the final round because its content proved too racy for the Welsh Assembly Government’s internet acceptable use policy.
The EDDIE Tool:
a system monitoring, security and performance analysis agent developed entirely in Python.
Looks nice: you can add extra rules which can arbitrary python expressions (and thus arbitrarily complex), and it does all the usual stuff you’d expect, such as SNMP. The author also suggests Pythonistas might find it interesting as…
an example of a threaded, multi-platform software package, providing easy access to system statistics and using Python’s power to offer a dynamic and programmable rules engine.
Well, I wouldn’t know about that sir.
Defective Yeti does it again. Oh Matthew, how I wish I could write like you…
Peekaboo Pole Dancing [Jo]:
the world’s first fantasy pole dancing game designed for use in the home!
It even comes with a pole.
The peekabo dance Pole is not compatible with Peter Andre, Mr Blobby Or Bob the Builder. Peekaboo Dance Money is not valid currency in the Ukraine.
a Python object database, offering an easy way to maintain a consistent persistent collection of Python object instances used by one or more processes
Neat, and if it’s lighter-weight than ZODB, potentially useful to me…
Ping Wales – Welsh IT News Online. Launched yesterday after much blood, sweat, and tears by a number of people close to me, most notably the wife… Anyway, God bless Ping Wales, and all who sail in her.
Alex Martelli explaining how Python’s list comprehensions and (new and groovy) generator expressions relate to Haskell, and why Python doesn’t (in generally) do lazy evaluation. As someone with a foot in both camps, but no deep understanding (alas – yet) of what’s actually happening, this is pretty interesting stuff…