Changes at Foyles


The venerable Foyles bookshop on the west side...
Image via Wikipedia

I remember Foyles bookshop in London when, perhaps twenty years ago, it was a warren of books seemingly piled one on top of another and with little order beyond the basic categorisation by subject (that is how it felt anyway).

Buying a book was a rigmarole – you got a chit for the book at one counter, paid at another and then went back to collect the book.

That contributed to the sense that the owners treated their staff abysmally – they seemingly could not trust most of them to run a cash register. I did not like the place and stayed away for many years.

When I did go back, some years ago now, the place was transformed – it really is the best bookshop in London and it is always hard to resist going in there when I pass.

But, I have to be honest. While I maybe buy a book or two there on four or five times a year, more often than not I seem to use its computer section as a sort of glorified library – checking which books look good before ordering them online from Amazon.

Ordering online is not always cheaper in fact – for low volume books Foyles can even turn out cheaper or at least faster at no extra cost as no postage has to be paid. But anything with any sort of volume is usually 50 pence or more cheaper and ordering a few makes the saving worthwhile.

So what to make of the fact they have moved the computer section downstairs to the basement seemingly because more and more computer book buyers do the same and so the computer books cannot be given the more valued retail space upstairs? Should I purchase a book or two just to keep the library open?

Maybe. Because one good thing that has seemingly come from the move to the basement is that there is more shelf space available and, so it seems anyway, more stock to browse.

That is very useful – I was thinking of buying The Little Schemer but having been able to give it a quick browse I can see it does not really fulfil any need for me (I was hoping for a book that would look at the history/thinking behind this dialect of Lisp rather than a cookbook type presentation).

So, what should I plough that saving into?

Slow progress on the project proposal


Crashed payphone -- Linux kernel panic

I have been making slow progress on my project proposal – some times it has felt like a mirage: the further I go the further away the real target seems to be.

But I am getting there – though I seem to have written five pages of dense type explaining how Linux paging developed and works without actually describing any problems or what I intend to do about them.

Well, the plan now – and I am writing this down as an aide memoire/encouragement to actually do it is to move on from where I am now – describing the 2Q-like LRU lists in the Linux kernel, to some of the problems, describing the alternative “working set” approach (eg as used in Windows NT and before than VMS) and then some of the strategies and tactics that could be used in Linux to apply it.

 

LaTeX frustration…


Knowledge of German as a foreign language (sec...
Image via Wikipedia

Anyone who works on software development and in the FOSS world generally is used to seeing books and documentation in English. It is certainly a great advantage to be a fluent speaker and reader.

But it is not always the case – as I have just found out.

Right now I have returned to writing my MSc project proposal and that means back to using the power of LyX and LaTeX. But with great power comes great complexity and it can be tough navigating all of this.

So I discovered there is an O’Reilly “Hacks” book for LaTeX – LaTeX Hacks.

Great! I was going to order it without even bothering to read a review, so sure was I that it would be helpful and useful: until I discovered it was in German and there is no sign of an English translation.

To make matters worse, it seems that the O’Reilly quick reference – LaTeX – is also auf Deutsch.

And there is even 100 neue Latex Hacks

This all has an odd, and unsettling feel to it. A century ago German domination of the physical and mathematical sciences was near-complete. Think of 1905 and Einstein just for starters.

But since the tragedy and disaster of Hitler we are used to thinking of the Germans as great engineers but the US clearly as the world’s leading centre of scientific research. And when a threat to that is identified it is usually seen as being from China (as Barack Obama said only a few weeks ago in his state of the union address). But maybe the LaTeX domination of Germany suggests there is life in the old world yet.

Either that or O’Reilly need to pull their fingers out on translating this stuff.

(The graph shows the numbers of people in EU members states who speak German as a foreign or second language: I did a year of it at High School but would not claim to know much beyond some very basic vocabulary and grammar).

A bit of a Groovy gotcha


This tripped me up this afternoon so it might be useful to write about it…

I have been tidying up my classwork exercise Groovy, seeking to eliminate the repeated redefinition of constants – so I defined something like this:

enum ExerciseConstants {
FIRST(1)
SECOND(2)
THIRD(3)
final int value
ExerciseConstants(int value) {
this.value = value
}
}

Then I wrote some code like this:

ExceriseConstants.each {
int x = it.getValue()
ExerciseConstants.each {
int y = it.getValue()
if (foo(x,y))
return true
}
}
return false

But while foo(x,y) would surely be true only false was ever returned.

The reason is that .each (which is not supposed to be broken out of in this way) sees that return and all that happens is that control is returned to the outer closure.

In these circumstances it is much better to use code like this:

for (i in ExerciseConstants) {
for (j in ExerciseConstants) {
if foo(i.getValue(), j.getValue()) == true
return true
}
}
return false

Which works as (I) expected.

The lambda calculus and closures in Groovy


Alonzo Church (1903–1995)
Alonzo Church: Image via Wikipedia

No sooner had I written about the lambda calculus and Structure and Interpretation of Computer Programs than I sat in a lecture on closures in Groovy and was presented with a structure like this (which multiplies two numbers, in this case 3 and 4):

a simple closure in Groovy

Which immediately reminded me of one of Alonzo Church‘s formulations of lambdas – eg:

A lambda calculus representation of a formula

More to come…

Eating humble pie


Groovy (programming language)
Image via Wikipedia

Maybe this should be titled … why you should check your examples thoroughly.

A few days ago I posted a Groovy code fragment here and said I was having trouble with the same code on an application.

My problem was that the application was a piece of coursework and I really did not want to post that here in case there was some sort of plagiarism issue later on. So I wrote a code fragment that, I thought, encapsulated the problem.

I then also took the issue to the groovy-user mailing list – see here.

The problem, though, was that there was a subtle difference between the two examples and so I was not asking people to test the same thing.

My problem was that I wanted people to enter a string of two integers separated by a comma but that the String.tokenize() method was failing to parse the input string correctly (or so I thought).

In reality the core issue was that the Scanner object (in the real code but not in the test example) was already tokenizing the input string.

To make matters worse, though, my code example was failing, but in a different way, on my Ubuntu machine – though it does not any more now I have upgraded Groovy from 1.7.0 to 1.7.6 – as the screenshot below shows – this may or may not be a bug in the code installed by default with Ubuntu so beware:

Crash in groovyConsole

Anyway, the fundamental issue was the Scanner and not the tokenize message.

Coming up… the lambda calculus


An example of a DFA state diagram
Image via Wikipedia

Another thing that The Annotated Turing taught me is what all those lambdas that I have seen over the last 25 years were about, or at least it introduced me to what they were about.

So I have just ordered a copy of Structure and Interpretation of Computer Programs: and I can guess that some blog posts will eventually follow.

Oh no. Maybe I am turning into a LISP hacker – having finally reached the age that all these guys were when I first became aware of them (older, actually).