Archive for the 'rant' Category

bash functions: it is mad!


bash can export functions to the environment. A consequence of this is that bash can import functions from the environment. This leaves us #shellshocked. #shellshock aside, why would anyone want to do this? As I Jackson says: “it is mad”.

Exporting bash functions allows a bash script, or me typing away at a terminal in bash, to affect the behaviour of basically any other bash program I run. Or a bash program that is run by any other program.

For example, let’s say I write a program in C that prints out the help for the zgrep program:

#include <stdlib.h>

int main(void)
    return system("zgrep --help");

This is obviously just a toy example, but it’s not unusual for Unix programs to call other programs to do something. Here it is in action:

drj$ ./zgrephelp
Usage: /bin/zgrep [OPTION]... [-e] PATTERN [FILE]...
Look for instances of PATTERN in the input FILEs, using their
uncompressed contents if they are compressed.

OPTIONs are the same as for 'grep'.

Report bugs to <>.

Now, let’s say I define a function called test in my interactive bash session:

test () { bob ; }

This is unwise (test is the name of a well know Unix utility), but so far only harmful to myself. If I try and use test in my interactive session, things go a bit weird:

drj$ test -e /etc/passwd
The program 'bob' is currently not installed. You can install it by typing:
sudo apt-get install python-sponge

but at least I can use bash in other processes and it works fine:

drj$ bash -c 'test -e /etc/passwd' ; echo $?

What happens if I export the function test to the environment?

drj$ export -f test
drj$ ./zgrephelp
/bin/zgrep: bob: command not found
/bin/zgrep: bob: command not found
/bin/zgrep: bob: command not found
/bin/zgrep: bob: command not found
/bin/zgrep: bob: command not found
gzip: /bin/zgrep: bob: command not found
--help.gz: No such file or directory
/bin/zgrep: bob: command not found
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
/bin/zgrep: bob: command not found
/bin/zgrep: bob: command not found
/bin/zgrep: bob: command not found

zgrephelp stops working. Remember, zgrephelp is written in C! Of course, zgrephelp runs the program zgrep which is written in… bash! (on my Ubuntu system).

Exporting a function can affect the behaviour of any bash script that you run, including bash scripts that are run on your behalf by other programs, even if you never knew about them, and never knew they were bash scripts. Did you know /bin/zcat is a bash script? (on Ubuntu)

How is this ever useful? Can you ever safely export a function? No, not really. Let’s say you export a function called X. Package Y might install a binary called X and a bash script Z that calls X. Now you you’ve broken Z. So you can’t export a function if it has the same name as a binary installed by any package that you ever might install (including packages that are you never use directly but are installed merely to compile some package that you do want to use).

Let’s flip this around, and consider the import side.

When a bash script starts, before it’s read a single line of your script it will import functions from the environment. These are just environment variables of the form BASH_FUNC_something()=() { function defintion here ; }. You don’t have to create those by exporting a function, you can just create an environment variable of the right form:

drj$ env 'BASH_FUNC_foo()=() { baabaa ; }' bash -c foo
bash: baabaa: command not found

Imagine you are writing a bash script and you are a conscientious programmer (this requires a large amount of my imagination). bash will import potentially arbitrary functions, with arbitrary names, from the environment. Can you prevent these functions being defined?

It would appear not.

Any bash script should carefully unset -f prog for each prog that it might call (including builtins like cd; yes you can define a function called cd).

Except of course, that you can’t do this if unset has been defined as a function.

Why is exporting functions ever useful?

sed, POSIX, and Node.js


I’ve been implementing sed. A POSIX compatible sed in Node.js.

It just seemed to me that one day soon the world will need a suite of Unix utilities written in Node.js. And I shall be The One.

The experience has made me a bit sad about the POSIX spec. There are problems. For example, it’s not very good at documenting the actual or desired behaviour of classic Unix utilities:

sed has a D command.

This command deletes the initial portion of the pattern space up to the first newline (which may be the entire pattern space if a newline has not been introduced with an editing command or with N); then D begins a new cycle. At the start of this new cycle, the next line of input is loaded into the pattern space, but ONLY IF THE PATTERN SPACE IS EMPTY.

This last bit is missing from the 2004 edition of the POSIX spec. It’s fixed and documented correctly in the 2013 edition of the POSIX spec.

The behaviour of sed hasn’t changed since Version 7 in 1979. The D command has always skipped appending input (if there was anything left in the pattern space). Probably no sed ever had its D command behave in the way documented in the 2004 POSIX spec. Maybe if someone was to try building a version of sed from scratch using the 2004 POSIX spec and without reference to any other sed implementations. But who would be mad enough to do that?

At some point someone drafting the POSIX spec didn’t notice the actual behaviour of sed, made a mistake in documenting the behaviour of its D command, and noone noticed until 2013 (well, a few years before, presumably). Which brings me to…

The pace of change is glacial.

Another thing about the POSIX spec which saddened me a little was the way all sorts of bizarre, obscure, and not very useful behaviours get documented and locked-in. You knew that sed has a ! modifier that negates an address. So «sed -n /barf/!p» prints all the lines that do NOT match /barf/. Did you know you can have as many ! as you like? «sed -n /barf/!!!!p» has the same behaviour as the previous program. At least according to the spec, and the Version 7 sed that I tried. There’s no point to this. No real program relies on this behaviour, yet there it is in the spec, so you have to implement it (if you want to comply to the spec). GNU sed (popular on Linux) gives an error instead. Which brings me to…

You can’t really rely on what you read in the spec being implemented.


GNU feel free to depart from the spec whenever they see fit to do so.

sed is a bit weak. For example, its regular expressions (POSIX Basic Regular Expressions) don’t even support «|» for alternation. POSIX has Extended Regular Expressions. Wouldn’t it be sensible to move towards adding Extended Regular Expressions to all the tools that only had Basic Regular Expressions? Well, maybe yes, but there seems to be no taste for doing that in a POSIX committee. And remember…

The pace of change is glacial.

The importance of AV


As you may know here in the UK we’re about to have a referendum to change the way we vote for our elected MPs. It means I have something important to talk about.


Kerning is the “negative space” between a pair of letters. Where the shapes of two adjacent letterforms complement each other, there is a danger of leaving too large a space between them if you space out the letters too rigidly. In the logo above, the A and the V in the first line have been brought closer together compared to the second line. I hope you can appreciate that “Yes to AV” has the better letter-spacing. And if you can’t, GET OFF MY BLOG!

This is the launch of the “Yes to AV; No to A V” campaign. I even have a logo with totally web 2.0 compliant round corners in a shade that isn’t blue.

Any half decent package that allows you to type in text should allow you to adjust the kerning, the spacing between the letters. In Mac OS X the feature has been built into the standard text widget, and hence incorporated into every application that plays nicely, since the dawn of time. I did the graphic in Inkscape which, being an X11 app, does not play nicely, but it didn’t matter. Most of the time you don’t need to hand kern the spacing between individual letters, because the font files that describe the letterforms also come with kerning tables, to adjust the spacing between pairs of letters that comonly need attention. “AV” is not as common as “Ye” or “Wo” but i’d still expect it to be kerned by the font software.

And so it is. It turns out that in my installation of Inkscape I have two Times fonts that I can choose in the pull-down font selector thingy. One called Times New Roman, one called Times.

So in making my “Yes to AV; No to A V” logo, all I had to do was choose Times New Roman for the “Yes to AV” line, and choose Times for the “No to A V” line. I expect Times New Roman is the system font exposed as an X11 font, and Times is some craptastic knockoff supplied with Inkscape that obviously has second-rate kerning tables. Thanks for that.

This article was of course inspired by the leader in The Observer (you will recall the dark ages of the 20th century when people read the news in print; The Observer is a notable Sunday publication from that era):

Weird. The appalling typography almost distracted me from reading the article (another win for that new-fangled web technology). Even weirder: they get their typography sorted on the opposite page.

So the message is clear: “Yes to AV; No to A V”.

Screw the planet!


The earth is getting warmer. Ecosystems are changing. Food webs around the world are upset. We are in the middle of mass extinction.

For years the green lobby have been complaining about this, finally over the last decade their voice can be heard as global warming becomes a political talking point. We can save the Earth.

Screw that! The greens are getting way too much political capital out of global warming. Sending your money to Friends of the Earth, World Wildlife Fund for Nature, the RSPB, and so on, will not solve global warming. They are not in the game.

The planet is not under threat. Our life on this planet is under threat. Runaway global warming will be bad. For any metazoan. Everything larger than than a hyrax will be wiped out. But life will go on, the Earth will be claimed once more by the Archaea and it will be business as usual really. Nature’s brief experimental dalliance with multi-cellular life will have ended. She will conclude that “further research is necessary”.

So the debate around global warming is not about saving the Earth, it is about saving our way of life on the Earth. And let’s get this straight, once we’ve “solved” global warming, we’ll have put a nuclear power plant on every (100 Km or so of) coastline, we’ll have replaced inefficient sheep pastures with huge plantations of biofuel crops, we’ll have peppered the entire countryside with wind turbines, and glazed vast deserts with solar PV farms.

We will not have saved the polar bear, the poison arrow tree frogs. All those bromeliads teetering on the brink of their fragile hilltop ecosystems in the South American rain forest? All gone. It will be our fault, collectively. And it will be sad. But solving global warming and saving your favourite obscure cute species are not the same problem.

Carbon into Trees


The BBC report that the Forestry Commission want to afforest 4% of the UK. And thereby get us 10% of the way towards our 80% emissions reduction target. Their wording is slightly odd, but see paragraph 12:

It is hoped the latest plan would absorb 10% of the UK’s target of slashing its emissions of greenhouse gases by 80% by 2050.

Alarm bells ringing. 1 million hectares (4% of the UK land) can sequester 8% (10% of an 80% emissions reduction) of the UK’s current CO2 emissions? No. My earlier article on coppicing willow suggests that an optimistic estimate for sequestration is 18 tonnes CO2 per hectare. So with 4% of the UK land, we could sequester 18 million tonnes, or about 3% of our (600 million tonnes of) emissions. I think my 3% figure is a really top end estimate. It’s not like willow grows particularly well in this country (but it is one of the best crops for sequestration) and with 4% of the UK covered, we may have to afforest some sub-optimal sites; short rotation coppicing is also different from growing mature forest, but I have a hard time believing that growing mature forest pulls down more carbon (yeah yeah, soil, nitrogen).

So where do the Forestry Commission get 8% from? I have no idea. And as usual the clueless journalists at the BBC fail to use the power of hyperlinking (welcome to the 1990’s) and they don’t have a link to the Forestry Commission research. Or even their press release (I suppose that would let everyone know they copied their homework).

Oh wait, here’s the first paragraph of the Forestry Commision press release: (ewgh Lotus Notes)

If an extra four per cent of the United Kingdom’s land were planted with new woodland over the next 40 years, it could be locking up ten per cent of the nation’s predicted greenhouse gas emissions by the 2050s.

Oh. So they mean 10% of our 2050 emissions. Which, as you know, are going to be 80% less than our current emissions. So 10% of 20% of our current emissions. Or 2%. Yeah, I buy that (just about, but at least it’s biologically plausible).

So the BBC mangled the press release. Does the BBC version seem very unclear to anyone else?

Windy isn’t it?


Damn hippies think we can just sprinkle a few wind mills around, and because Europe has “huge wind resources” we’ll be okay.

This silly web article claims that europe’s wind energy potential is “huge”, and “equivalent to almost 20 times energy demand in 2020”.


YA RLY, according to the European Environment Agency’s report, Europe’s onshore and offshore wind energy potential.


YA RLY: It’s hard to miss this sentence from the executive summary: “Europe’s raw wind energy potential is huge. … it may be equivalent to almost 20 times energy demand in 2020”.

“energy demand”, that’s the problem. Their assumed energy demand is between 3537 TWh and 4078 TWh. (By the way, notice that the EEA cover their backs with a “may” when they use the lower demand figure to get the “20 times” headline-grabbing numbers, but the web article referencing somehow manages to drop the “may”). So, Europe has 271e6 people (according to Google); that’s 15.3 kWh per person per day. Oops. They must have meant…

Electricity demand.


The electricity demand, in Europe, in nothing like our energy demand. In the UK we travel around by burning oil, and we heat our houses and food by burning gas. That hugely swamps our electricity usage.

Energy and Electricity are not the same thing.

Double twats for the people who ignorantly repeated them. Of course the European Environment Agency know the difference. There are two occurrences of the phrase “energy demand” in the document; 7 occurrences of “electricity demand”. Both the “energy demand” phrases related to the “20 times” sentence. One is in it, the other is in the footnote of the table of data on the same page as the “20 times” sentence. Before I did the textual analysis (by which I mean I used the PDF search feature; it’s abysmal, but it’s what I have available) I put the use of “energy demand” down to sloppy practice. Now I think it’s mischievously deliberate. I think they used “energy demand” in that “20 times” sentence in the executive summary because they knew people would make a headline of it.

I have to say that apart from this headline grabbing glitch, the report is well worth reading. Map 6.1 is particularly interesting (apologies for the pixelly rendering, partly their fault, partly mine, but mostly the fault of STOOPID PDFs):
Cost of wind in europe

Basically the British Isles is the only place in Europe (not quite, but nearly so) with cheap on-shore wind. And we’re full of NIMBYs.

Unusable Train Reservations


Returning from EuroPython I got the 1730 from Birmingham New Street to Sheffield. The seat reservations in this class of train appear above each pair of seats on a little illuminated dot matrix display that shows 2 rows of text. Each row displays 16 characters (it was quite tricky to count, but it was close enough to 16 that surely, if there is any god, it must be 16).

Each row displays the seat reservation information for one seat. As a little message that scrolls along. Most of these messages were of the form: “20 This seat is not reserved”. This message is 28 characters long. Which means it needs to scroll to fit on the display. Some genius decided to pad the scrolling message with 16 blanks, so that the end of the message scrolls off completely before the message begins again. So, for the display of this message, there are 44 states that a row can be in. Each state corresponds to a position in the 44 character string (each position in the string can be identified with the display state that has that position at the extreme left-hand end of the display).

The seat number is 2 digits long. It is only displayed for 15 of the 44 states. Meaning it is only visible for 34% of the time. It’s actually kind of important to display the seat number. Especially as they made the mistake of putting the larger of the two seat numbers on the top row. The two rows display the reservations for a pair of seats: N (bottom row), and N+1 (top row). Nuts. In fact it’s not necessary to display the seat number on the display itself. Adjacent to the display (on either side) are stickers showing the numbers for the two seats and whether they are window or aisle. It would be a trivial design change for these stickers to point to the appropriate row of the display.

Some of the time the display will show t reserved or eserved or something else that could reasonably be mistaken for reserved. So if you just glance at the display then you have about a 7% of interpreting it as “reserved” (when in fact it’s not reserved).

The shorter the message is, the more likely we are too be able to comprehend it instantaneously without having to wait for it to scroll. So it would be good to get rid of unnecessary text. “This seat is” is totally unnecessary. We’re on a train, we can tell that the little display refers to a seat reservation. So all it needs to say is “20 not reserved”. And that’s only 15 characters long, so it can be displayed permanently, without needing any anti-assistive scrolling.

The case where the seat is not reserved is a bit special, but it’s worth concentrating on, because those are the seats that people will want to find when they are boarding the train. At least, people without reservations. People with reservations don’t need the overhead displays at all because they can just look at their ticket to find the seat number. To recap: The reservation displays are only useful for people without reservations, so they should be organised around making it clear which seats are free.

The remaining cases, where the seat is reserved for some of the remaining journey, should probably be handled with text that is something like “free until chesterfield” or “reserved until york”. Possibly the “free” and “reserved” can be “stuck” at the left-hand side of the display while the remainder of the display scrolls to show the whole message. Dunno. But I bet a day of trying out a dozen ideas would be a vast usability improvement on how it works now.

OS X and X11


Apparently Matlab on the Mac is still in the stone-age of using X11, and it sucks.

Yes, Apple provide X11 with OS X. But you’re not supposed to use it. It’s not for lazy retards to base their Mac platform strategy on, it’s for desperate people who absolutely must use that X11 app that some scientist wrote back in 1993.

I find mathwork’s attitude a bit whiny. On moving away from X11: “this is a multi-year endeavor”. Well, yeah. I’m sure it is. But OS X has been out for over 8 years now!

Bottom line: if your answer to “do you have a Mac product” is “Yes, we use X11”, then you do not have a Mac product. You have an inexcusable pile of dingo turd. If the answer is “Yes, it’s written in Java” then you just upgraded your turd to offal. Congratulations.

Of course, this is just my opinion. My opinion and the opinion of every other Mac user. If we liked using X11, we’d all be using Linux already.

PS: Firefox gets it right. How hard can it be?

Python: Tail Call Optimisation


Normally, two words are sufficient to explain why we need tail call optimisation.

Guido still doesn’t get it.

lambda, map, reduce, tail-call optimisation.

I’m going postal. I have shipped a copy of SICP to Guido.

[update 2009-05-20: Guido got the book]

Warning: Generation Green could be in a classroom near you!


British Gas sent me a link to Generation Green. A classic greenwashing move: they seem to have paid a charity to produce a load of “green” lesson plans as a way to get their trademark embedded into every classroom, and therefore also into the minds of every future energy consumer. Leaving aside, for now, the ethics of corporate sponsorship of the classroom (hint: it’s wrong), what is the content like?

I had a look at Lesson 4 – Exploring sources of energy (part 1). One of the resources for this lesson is the “Energy Source Information Cards”: a series of 10 cards, one for each source of energy (coal, nukes, wind, and so on). There’s a Word document containing these that you can download (lower right of the web page I linked to).

It is from these cards that the students will be taking the factoids and copying them onto their posters in colourful crayon so that the posters can be displayed on the corridor walls in time for the first parents’ evening of term.

So, how are they? Well, a bit poor. On the whole, I’m a bit disappointed that “facts” like these are getting fed to children (and, more worryingly, their teachers). The perfect antidote to this generationgreen nonsense would be to use David MacKay’s book, Without Hot Air (go on, it’s free!). The chapters are bite-sized (especially the earlier ones), and they contain facts, and references, and good stuff.

The howlers in the “Information Cards” are Wind (mechanism wrong way round), Biomass (written by two people that never saw each other’s work), and Wave (written by someone who has no idea where the energy in waves is).

Overall there is a confusion between power and electricity. Every card has a section on how electricity is generated using that source. The Natural Gas card points out that gas can be piped into people’s homes, but there’s no mention of the fact that this is then used for heating not electricity generation. Coal, gas, oil, and biomass can be used more efficiently for heating applications directly than via conversion to electricity, but this is never mentioned. Nor is the fact that this is only of limited use because we only exploit a limited amount of low-grade heat.

There is also confusion about cost. Sometimes high capital cost (hydro) is mentioned, sometimes it isn’t (nukes). Often zero running cost is mentioned (wave) without mentioning capital. The important cost, total cost per kWh over the entire lifetime of the plant, is never mentioned.

There is also some confusion about pollution and global warming. Pollution is bad, global warming is bad. But these things are completely separate. There’s a tendency in the cards to assume that anything emitted into the air is bad, because of global warming and pollution; they’re not always specific enough about which it is.

Perhaps you can pick a different lesson and mock that, then at the end we can collect all our answers together and have a chat and make a nice poster?

Page 1 – Traditional Coal

This card is basically fine. The only things worth mentioning:

“Hard black substance that is found buried deep underground.”

Coal is not always hard (anthracite is, but it’s not the only form of coal), and it’s not always buried deep underground (I have picked it up on beaches).

Page 2 – Natural Gas

Basically fine.

Page 3 – Crude Oil

Typo: “most well knows” should be “most well known”.

There’s a double count in the disadvantages: “Burning oil pollutes the air”, and “Burning crude oil produces other emissions e.g. sulphur dioxide”. The “other emissions” are the pollution from burning oil. Perhaps better would be “Burning oil pollutes the air with sulphur dioxide and other emissions” (as does coal, by the way).

Page 4 – Wind Energy

“Wind is the effect of air flowing from low pressure to high pressure.” No, no, no, no, no. Bzzt. You’re wrong. Following is “The air in the warm regions rises and the cool air rushes in to replace it and this is what we know as wind”. A somewhat simplistic explanation, but that’s okay. The “this” is a horribly ambiguous reference; “this movement of air” would be better.

“As one of the windiest countries in Europe, it is perfect for our climate”. Yes, assuming we want to carpet bomb the British Isles with wind turbines. David MacKay’s ludicrously optimistic sketch of using 1/3 of our offshore coast for wind power (including uneconomical deep offshore wind) and carpeting 10% of our land (!) with onshore wind gives 58 kWh/day per person, or nearly half of the UK consumption. Perfect.

“Once it is built the fuel costs nothing”. Not true: offshore wind turbines need frequent replacement of the gear boxes due to sea-salt corrosion (and this should go in the disadvantages section).

Page 5 – Geothermal

Basically fine.

Page 6 – Biomass

In advantages: “It supports farmers because they can sell their crops for biomass fuel”. Whilst this is true it is seems silly to single out farmers. An advantage of wind energy is that it supports turbine blade manufacturers because they can sell their turbine blades as parts; an advantage of crude oil is that it supports oil drillers because they can sell their oil for fuel. It’s just a silly argument. What if crack cocaine was a fuel, would we be saying “it supports drug dealers because they can sell their stash for fuel”?

The “advantages” contradict the “disadvantages”. “Biomass fuel tends to be cheap” versus “Biomass can be relatively expensive compared to other sources of energy”. “Burning biomass produces carbon dioxide gas which contributes towards global warming”, strictly true but as the same card explains in the “advantages” section: “Although carbon dioxide is released when biomass is burned, it is still a carbon neutral source of energy. The amount of carbon dioxide that is released when biomass fuel is burnt is the same as the amount of carbon dioxide absorbed by the plants when they were growing.”

Page 7 – Uranium

“It does not contribute to the greenhouse effect because it does not produce smoke or carbon dioxide”. Mentioning “smoke” is absurd. The smoke produced by other sorts of power generation does not contribute to the greenhouse effect, quite the opposite. Smoke is an aerosol that has a cooling effect. Smoke is of course a pollutant, so nukes avoid air pollution, which is worth mentioning.

In advantages: “It produces small amounts of waste”. True, but so misleading. They make up for it in the disadvantages.

“It is not renewable; when the uranium is used it can not be replaced”. True, but worth mentioning the possibility of sea-dissolved uranium, which is replaced (er, I think).

“It is very difficult to turn off a nuclear power station”. Again, true, but it would be good to say a little bit on why this is a disadvantage. The reason it’s a problem is that no-one wants electricity at night but the nuclear power stations generate it anyway; you have to throw it away.

Page 8 – Solar Energy

“Every second, the Sun turns millions of tonnes of hydrogen into energy”. Well intuitively this didn’t seem right to me, but it turns out to be both right and wrong. The sun converts mass into energy at the rate of 4.4e9 kg per second (or 4.4 million tonnes, if you’d rather), and of course that mass is hydrogen. But it’s a little bit misleading not to mention the 600e9 kg of hydrogen that get converted to helium in the process. In other words every second, the Sun turns 600 million tonnes of hydrogen into helium, producing some energy in the process.

Only talks about PV, doesn’t mention solar concentration electricity generation such as the 11 MW PS10 tower in Spain (warning, EU press release).

Page 9 – Hydroelectric Energy

Hmm, it says here “Solar power can be used to create electricity in remote places where it might be very hard to get
electricity through cables”. Oh rly? What’s that got to do with hydro? Nothing, that’s what. Cut-and-paste hack-job.

Then the voice changes. Suddenly we see “we”: “We can control when the electricity is made by opening and closing the dam gates.”, and “Electricity can be generated 24 hours a day as long as we have the water”. It just hasn’t been proofread.

Disadvantages: “It is very expensive to build a dam”. Oh rly? Well, it is very expensive to build a nuclear reactor, and very expensive to build a wind farm the size of Wales, but you didn’t seem to mention that. Just casting about for disadvantages were we?

Another disadvantage: “There can be negative environmental impacts as water quality and quantity downstream can be affected and have a knock on effect on wildlife”. True, but there can be a positive effect on wildlife as well, as water habitats are created upstream of the dam and they are exploited by suitable species.

Page 10 – Wave Energy

“Wave energy is harnessed from the movement of the surface water of lakes, rivers and oceans.” Wrong. Should read “oceans” for “lakes, rivers, and oceans”. You cannot get usable energy from a wave on a lake. And as for rivers, stop laughing at the back. “Turbines can be placed by the shore, where the movement is at its strongest.” The latter bit, “where the movement is at its strongest” seems like a dubious claim to me. Surely the Atlantic waves have just as much movement a few miles offshore? The advantage of shore placement is shorely (sorry!) shorter cables?

“The wave acts like a piston that pushes air up and down an oscillating water column.” Well, that’s one way to get energy out of a wave, and it’s (kind of) how the Islay LIMPET works, but there are many other ways. Pelamis works by using the flexion of a linear body floating on the surface to drive hydraulic rams. CETO works by having a submerged buoy drive a piston to pump seawater inland at high pressure which then drives generating turbines. Salter’s Duck works, as far as I can tell, a bit like a self-winding watch.

“As an island we have lots of access to the coast and therefore could harness a lot of wave energy.” Yeah man, a lot of energy. According to MacKay, the total Atlantic wave energy hitting Great Britain amounts to 16 KWh/d per person or about 1/8 of our total consumption. If we exploited all of that then the Newquay tourism industry would be very annoyed (a disadvantage not mentioned, incidentally).

“It can be unreliable because it depends on the waves – sometimes you’ll get loads of energy, sometimes nothing”. Ah, no. Wave power is about the most reliable source of energy derived from a moving mass. Thousands of kilometres of Atlantic fetch can’t be wrong. There are always waves.

“Some designs can be very noisy”. Surely bogus, because no-one is proposing living next to them. Visually distracting, maybe, and a menace to fishing and shipping, but those disadvantages aren’t mentioned.

That’s all folks! Don’t forget your homework now, pick a lesson and tear it apart!