| Lazy lists, impatience and hubris |
[May. 16th, 2008|12:12 pm] |
There was a recent mailing list post by Andrew Coppin (which received some discussion on programming.reddit) in which he bemoans the way that GHC, when presented with reasonable-looking code, can suddenly and mysteriously decide that it needs to allocate gigabytes of memory, slowing your system to a crawl for ages (I've had similar problems myself). Andrew's example was the following: I offer up the following example:mean xs = sum xs / length xs Now try, say, mean [1.. 1e9], and watch GHC eat several GB of RAM. (!!) This is not so mysterious when you remember that Haskell uses linked lists as its native list structure, and so the only way to calculate length xs is to traverse the list a second time: the runtime system "helpfully" keeps around the copy of xs that it generated while calculating sum xs, and you have a space leak. But what to do about it?
( The story so far )
( Doing it in Perl )
( Doing it in Ruby )
( Take-home messages ) |
|
|
| Sage |
[May. 14th, 2008|01:15 pm] |
Those of you who do scientific computation may be interested in this link:
Bye Matlab, hello Python, thanks Sage.
Short version: Sage is a bundle of all of the various numeric/scientific/graphing tools for Python, made easy to download and install (even if you don't have root access, apparently). According to the blogger linked above, it's now good enough to serve as a replacement for Matlab (and it has ambitions to be a replacement for Maple and Mathematica too, though I don't know how far along it is). It integrates with R, Gap, etc. And because it's Python, you get a real, high-level, well-designed programming language with a proper environment to do your coding in.
In other news, wormwood_pearl finished her Finals yesterday. As you can imagine, we're both pretty relieved. There's no tradition of meeting people outside Finals here like there is in Oxford, but I went along with a bottle of champagne anyway - and only then remembered that public drinking is against Glasgow bylaws. Drat it. We went out to lunch, the bottle went into the Department fridge, and we subsequently went round to her sisters' and drank it there while watching Layer Cake. Because we're that exciting. |
|
|
| Notation that sings |
[May. 9th, 2008|05:08 pm] |
Some Actual Maths for a change. Some of it assumes some mathematical sophistication, but the core idea should be accessible to anybody. Have you ever been an arts student? I'm looking at you. Skate over the words you don't know, they're not important - they're just there to explain how the central result connects to more sophisticated and deeper areas of mathematics.
( Go on, click, you know you wanna ) |
|
|
| LOLhacker? |
[May. 8th, 2008|02:20 pm] |
I know I'm very late to the LOL$thing party, but what the hell:
( Cut for size )
Now, I reckon about half of you will recognise the guy in the pictures, and about half will understand the captions. I'm interested to know how large the intersection is... |
|
|
| Thesis sitrep |
[May. 7th, 2008|11:44 pm] |
I've been collecting some more data on the thesis:Wed May 7 23:45:49 BST 2008
4741 lines 23246 words 163656 characters
thesis.log:Output written on thesis.dvi (84 pages, 643096 bytes).
33 fixmes
80 definitions
141 term-definitions
24 theorems
21 lemmas
6 corollaries
30 examples
143 bullet-points A "term-definition" is a call to the macro \defterm, which I use to emphasize the term being defined. The count's not the same as the number of definitions because I often group the definitions of related terms into the same \begin{defn}...\end{defn} block. The lemmas, theorems etc are mostly other people's :-(
I like bullet points. They reflect how I think, and bullet-pointed text takes up more space on the page. |
|
|
| In case you were wondering how I got this way... |
[May. 7th, 2008|11:30 pm] |
The tail-end of a conversation with my Dad last night:
[A discussion of scary-sounding nonlinear dynamical techniques my Dad has been studying, with Poincaré's name attached for extra scariness] Me: Sounds interesting. Have you come across the idea of considering the Poisson bracket as a symplectic form on the cotangent bundle of phase space?* Dad: No, I don't think so... Me: Something like that, anyway. I went to enough lectures on this stuff to pick up the jargon, but not enough to really get my head around it. Dad: Yes, I know that feeling. Me: But it's interesting how quickly physics becomes geometrical, isn't it? Dad: Yes, certainly. You know, one of these days you and I should put our heads together and try to properly understand General Relativity. Me: Actually, that was my plan for after I hand in my thesis. That, and learning to ride a unicycle. Dad: [laughs] ...and learn a foreign language and a musical instrument. Me: thinks: I wasn't going to tell him about that bit...
* My office-mate, who does The Physics, tells met that I meant "configuration space" - phase space is the cotangent bundle of configuration space! |
|
|
| Fine Structure: The Story So Far |
[May. 4th, 2008|06:49 pm] |
There's a new Fine Structure story up, called The Story So Far. Go read it. Actually, there's another one that I never got round to posting about, called Failure Mode, which is... rather moving, actually. Great stuff.
Anyway, the missing story ( has now been revealed... )
I'm not going to write too much now, because I have a hangover. But I think there'd be some benefit to thinking harder about the fictional physics - I definitely should have spotted the "superlight" connection. I think there may be more insights to come from that source.
There's now a comments system on the Fine Structure pages themselves, which I suspect will largely replace the discussions here. Please continue to comment on my posts if you want, though! I'm hoping someone else will start blogging in depth about FS. Maybe we need a Fine Structure wiki? An E2 node? |
|
|
| Floreat gens togata |
[May. 3rd, 2008|08:33 pm] |
I see that Londoners have chosen the devil they don't know in place of the devil they do. I shall observe my fellow KS's future performance with considerable interest, and at a distance of several hundred miles.
In other news, my flatmates are looking to move to Oxford in the next few months (Nicola's starting an MSc) - can anyone offer some hints on Oxford flathunting? I was a wuss, and stayed in college accommodation for all four years, so can't be too much use. |
|
|
| Mountain photos |
[Apr. 30th, 2008|04:01 am] |
I've put a selection of photos from my last-but-one hiking trip on moblog: part 1, part 2, part 3. We went to Glen Etive (south and a bit west of Glen Coe), and climbed Ben Starav and Beinn nan Aighenan - the plan had been to do more, but we underestimated the time it would take and overestimated our fitness levels. It was an absolutely stunning day, and the scenery was just great. A sample:


By the way, my thesis page-count has finally drawn level with my Munro-bagging count:
Wed Apr 30 04:06:10 BST 2008 4552 lines 22350 words 156883 characters thesis.log:Output written on thesis.dvi (82 pages, 628596 bytes). 34 fixmes
Yay! |
|
|
| Why I like Perl |
[Apr. 28th, 2008|12:18 am] |
I wrote this in an email to a colleague of totherme's a while back, and have occasionally felt the need to refer to it since. Fortunately, I have a place where I can post my ill-informed ramblings for all the world to see, so here it is :-) It's an attempt to convince a computer scientist, who I believe comes from the Haskell/static typing camp, why Perl is worth learning.
[If you're not a computer scientist, the two chief reasons to learn Perl are (1) it's incredibly useful, (2) it's great fun. But I digress.]
In many ways, Perl occupies the opposite corner of design-space to Haskell. To a first approximation, Haskell proceeds from the question "what if everything we think we know about language design is right?", whereas Perl proceeds from the question ( what if everything we think we know about language design is wrong? ) |
|
|
| Argmungers in universal algebra |
[Apr. 26th, 2008|12:32 am] |
Some of you might be interested to learn that argmungers are now explicitly included in my thesis: the mathematical concept, that is, not the code. One can recast classical universal algebra (which works syntactically, with words in a recursive language and denumerable sets of variables) in terms of planar trees of operators (abstract syntax trees, effectively) acted on by munging functions (and yes, I use the term "munging function"). Restricting the munging functions allowed is equivalent to imposing syntactic restrictions on the equations defining your theories: I'm writing up a proof of this at the moment. Interestingly, isolating the concept of munging functions makes the whole thing significantly cleaner: up until then, the theorem was frustratingly obvious, but trying to prove it (or even state it!) rigorously was like nailing jelly to the wall.
Maybe I should thank Hitesh in my acknowledgements...
Oh, and current state of play:Sat Apr 26 00:47:12 BST 2008
4511 lines 22164 words 155551 characters
thesis.log:Output written on thesis.dvi (78 pages, 626444 bytes).
34 fixmes I was up to 79 pages, but then I deleted some redundant stuff, so now I'm back down to 78.
Right, time to pack for the mountains tomorrow. |
|
|
| Attention, readers! |
[Apr. 25th, 2008|01:58 pm] |
You have lost The Game.
That is all.
mi_guida: I have won the Pillaging Game. |
|
|
| The White Spider |
[Apr. 21st, 2008|10:35 am] |
I've just started reading The White Spider, Heinrich Harrer's account of his 1938 first ascent of the fearsome North Face of the Eiger. The climb was one of the pivotal moments in the history of mountaineering, and the book's considered one of the classics of mountain literature. I was particularly struck by the opening paragraphs:"Writing a book about the North Face of the Eiger? Whatever for?" The question was put to me by a man of some standing in Alpine circles. I was taken aback and slightly cross, so I gave him a somewhat off-hand answer: "For people to read, of course." That started him off on a passionate tirade. "Who's likely to read it? Don't you think the handful of climbers who are really interested in that crazy venture have had quite enough literature on the subject already? Or do you just want to join the sensation-mongers, from whose ranks a serious climber like yourself should keep as remote as possible?" I answered him: "If all climbers shared your point of view, it wouldn't be surprising to find the newspaper reports overflowing with mis-statements and exaggerations. I believe the public has a right to authoritative information, especially when mountaineering problems become human ones. And I think it is a climber's duty to contribute to the formation of public opinion in such matters." And with that I dropped the unpleasant argument. It struck me as I read those words that one could replace "climbing" with "mathematics", "the Eiger" with the name of some serious mathematical problem, etc., and be left with a statement that's equally true, and equally important.
[By the way, there are some excellent, not to mention terrifyingly vertiginous, pictures of Sir Ranulph Fiennes on the Eiger's North Face here. Well worth a look.] |
|
|
| Public Service Announcement |
[Apr. 15th, 2008|03:47 pm] |
I say this every year, but judging by my friends page and the state of my flatmates, it bears repeating.
Many of you are, or shortly will be, undergoing examinations - mostly Finals, a scattering of other things. To a man, woman, or small furry creature from Alpha Centauri, you all seem to be panicking, convinced that you haven't done any work, that you don't know anything, and that your only hope of redeeming your tattered academic credibility is to throw yourself into a routine of work so intense that your vocal cords atrophy from lack of use, your pen-holding fingers swell to the size of your arms, and your skin shrivels on contact with sunlight.
This is exactly wrong. First off, if you're reading this you're probably a friend of mine, and hence considerably smarter than the average bear: you have nothing to worry about. Secondly, mere lack of knowledge is not the problem. Mere lack of knowledge is generally a trivial problem. The real problem is Finals stress.
Allow me to expand on that. If you remain calm, keep alert, and generally keep your mind in a state where you can think as opposed to panicking, then your raw talent, coupled with the knowledge you currently have (a lot more than you realise, provided you haven't, say, been doing ten plays a term for the last three years), will get you a lot further than you now realise. Maybe not enough to get you as good a degree as you'd like, but enough to stop you embarrassing yourself. In addition, your mind will be better able to absorb more information, and you'll be more able to actually do some work. If, however, you allow yourself to be whipped up into a fervour of panic, then you will lose the all-important ability to think, and you will be lost. Worse than that: the panic will prevent you from getting any useful work done, and you won't take anything in.
So, your priorities should be:- Don't stress about how little work you're doing. That's not important, and stressing about it is actively unhelpful.
- Do make sure you're sleeping, eating and exercising properly. Get out in the sun. Make sure you see your friends. Chill out. Relax.
- Don't stress about your failure to achieve these goals, either. Get it right tomorrow. Repeat as necessary.
Get these right, and success will follow. |
|
|
| Pozorvlak's Conjectures |
[Mar. 30th, 2008|08:40 pm] |
For the past couple of years (longer, actually), I've been thinking a lot about this business of static and dynamic typing in programming languages. Here's my current position on the matter.
Static and dynamic typing encourage and reward quite remarkably different approaches to the creation of software: everything from the nitty-gritty, (sit and think?)-edit-(compile?)-run-(test?)-(debug?)-(repeat?) cycle to the design (at all levels) of the software to be created, taking in every aspect of the tools and process used to support this design and implementation. Also, the choice of static or dynamic typing is best understood as part of a larger attitude towards development. Unfortunately, the use of a dynamic mindset with a static language not only means that you can't take advantage of the tools available (or even see why they'd be useful), it actively hinders success. The same is true for approaching a dynamic language with a static mindset.
I would therefore like to propose Pozorvlak's Conjectures:- If you find that a modern dynamic type system causes more problems than it solves, you're probably doing it wrong.
- If you find that a modern static type system causes more problems than it solves, you're probably doing it wrong.
For instance, I find Haskell's type system causes me many more problems than it solves. Discussions with more expert Haskell users suggest that I am indeed doing it wrong. This guy, on the other hand, finds that "the dynamic languages stick out like sore thumbs because of the whole class of dynamic run time errors that show up that don't even appear in the statically typed languages". If you find this, I claim that it's because your code is not polymorphic enough1. You can get away with having code which only accepts data of very restricted types when the compiler does all the checks for you statically. When it doesn't, you're better off writing code that behaves well for a wider class of inputs, and dynamic languages give you much more facility to do this. Once you learn to code like this, your problems largely go away. As a bonus, your code becomes more flexible, and whole classes of techniques become possible that would have been literally unthinkable before. Similar claims, it appears, can be made for static languages: at the higher levels of mastery, one can use a static type system as a theorem-prover to establish some quite nontrivial properties of your program automatically and across the entire codebase. This allows for some excitingly different approaches to program development.
A corollary is that if you ever finding yourself saying that your port of Feature X to Language Y is better than the original Feature X solely because it's (statically|dynamically) typed and the original Feature X was the other one, you should probably save your breath. It will probably also be worth your while to go back and determine what advantages the opposite choice of typing regimen gave to Feature X's users.
1 A less interesting, but probably valid conjecture is that you're also not testing enough, or at least testing the wrong things. But this can't be the only answer. Dynamic programmers, in general, are not idiots; they are usually also Lazy, in the good sense. They're smart enough to work out that writing the equivalent isa_ok() test every time they would have written a type declaration in Java or whatever is no time-saver at all. Hence, they must need less type information overall for their code to be correct. |
|
|
| Better living through shell scripting |
[Mar. 28th, 2008|03:31 pm] |
As I may have mentioned once or twice before, I'm writing up my thesis. This is an intensely slow and depressing process, and the temptation to slack off is overwhelming. Being a geek, I decided to write some code to help me. Writing code rather than writing thesis is still slacking off, obviously, but it's slacking off to a useful end. Writing blog posts about writing code that's meant to help me write my thesis is another matter...
( Read more... ) |
|
|
| Beinn Dubhcraig - photos |
[Mar. 25th, 2008|12:13 am] |
I've posted some photos of the Beinn Dubhcraig trip to my moblog. Larger versions exist, and I'll try to find a home for them: my Flickr account has sat unused for so long (prior to the Yahoo buyout) that it's not letting me log in any more :-( |
|
|
| Mountaineering experience |
[Mar. 24th, 2008|06:58 pm] |
"What you need is combat experience. That's what keeps you alive in real combat." "OK, but how can you tell the difference between combat experience and real combat?" "Simple. If you're alive at the end, it was combat experience." (From The Ballad of Halo Jones) Saturday's trip to the hills started inauspiciously: I slept through all my alarms, and was only woken up by Jo texting to say "I'm parked outside". My bag was packed, but there was still a forty-minute interval of running around before I was showered, breakfasted, infused with tea, dressed and ready to go. Then we were off, at the decidedly late starting time of 9am.
( Beauty )
( Drama )
( A&E and TMI )
All in all, not exactly Touching the Void, but it had some frightening moments.
( Lessons learned )
Time to throw it open to the floor: what should I have done differently?
[Edit: some photos of the trip can be seen here.] |
|
|