Big themes

We were talking about the big themes, and what bigger theme than Christmas.  John talks of the Word, that pre-exists all, the Logos, the ruliness we seek in random events, the laws of the universe examined in CERN and comet-hugging satellite, the conversation between God and creation, the Word that was singly, irrevocably and powerfully spoken, the Word that says all and is all, the Word that is “Love”.

It was a Word declared through 10 billion years of the dark star-thread universe, a Word sung by incomprehensible angels, a Word of cosmic significance; but it was no abstract Word, no Word of plain intellectual study, but a Word made Flesh.

Wriggling, scrawny, damp-wrinkled flesh, still flecked with the drying blood of Mary torn in childbirth, prefiguring another bloody day, like and unlike every other baby, letting out one unignorable, earth-shaking cry.

the year that was 2014

While 2013 was full of momentous events (Miriam getting married, online HCI course and walking 1000 years around Wales), 2014 seems to have relatively little to report.

A major reason for that is the REF panel and the time taken, inter alia, to read and assess 1000 papers.  I am not at all convinced by the entire research assessment process – however, if it is to happen it is needs to be done as well as possible, hence while still reeling from the walk (indeed asked whilst on the walk) I agreed to be on the panel at a relatively late stage late in 2013.

At the end of the year with the results out I guess the other members of the REF panels and I are either loved hated deepening on how different institutions fared … maybe it is good that I live on an island so far from anyone :-/

I guess I am no more convinced at the end of the process than I was at the beginning.  It was good to read so much over such a wide range of topics, I feel I have an overview of UK computing that I have never had before.  This was often depressing (so many niche areas that clearly will never affect anything else in computer science, let alone the world), but also lifted by the occasional piece of work that was theoretically deep, well reported and practically useful.

Beyond the many many hours of reading for REF, the world has moved on:

  • Fiona has begun to sell more textile art online and at events, including a stall at Fasanta where the Tiree Tapestry was also exhibited.
  • Miriam passed her driving test and has a car.
  • Esther has had a number of performances including a short film (although sadly I’ve not managed to attend any this year :-()

Personally and work-wise (the boundary is always hard to draw):

  • I eventually managed to fill in the remaining day blogs for Alan Walks Wales in time for 1st anniversary!
  • I’m gradually managing to spread the word about the unique data I collected at various talks including at events in Bangelore and Athens.
  • The OnSupply project about awareness of renewable energy production was wonderfully successful with several workshops in Tiree, a best paper nomination at ICT4S and an accepted CHI paper.
  • Work with Rachel on Musicology data, which has been slowly ticking along informally, has now been funded as the InConcert project and we ran an exciting symposium on concert-related data in November.
  • At Talis I am looking at the benefits of learning analytics and published my first journal paper in the area, as well as using it practically in teaching.
  • Tiree Tech Wave has gone from strength to strength with capacity attendance and digital fabrication workshops for the Tiree community in the autumn.
  • … and not least competed in the 35 mile round Tiree Ultra-marathon in September 🙂

… and in 2015

who knows, but I’ve already entered for next year’s ultra – why not join me 🙂

 

A week in Athens

Last week I visited Athens again to give keynote “Long-Term Engagement” at Usability And Accessibility Days 2014.  The rest of the event was in Greek, so I got excused to wander across to see the exhibition of contemporary icons by Helena Krystalli in the adjoining room.

The talks included vignettes about Walking Wales, Tiree Tech Wave and other technology projects on Tiree, the InConcert musicology data project, and Talis software for learning analytics.  the linking theme was the different time frames for engagement and key properties/heuristics at each level including ‘desire and disaster‘, matching cost–benefit, and ‘Micawber management’.

talk-themes

As well as the talk I got to see old friends in Athens, many of whom I’d not seen for five years since my last visit for the 2009 SIGCHI Greece event when I was talking about ‘Touching Technology‘.  Despite the years it seemed like just yesterday when we’d last talked together.

Although there was some evidence of change (Angela who I stayed with now has two daughters instead of one), much was the same (George’s house is still waiting to get its central, hearing working).

However, when I was in the research office the day after the talk I decided that Athens definitely is in stasis when I am not there.  We were sitting talking and I happened to look up at the board and saw writing there.  It was a little obscure, and intriguing, but as I examined it I realised t was in fact my own handwriting, written there 5 years ago during a discussion in the same office.

athens-stasis-cropped

 

To be fair there was some additional evidence of change beside Angela’s child; the new Acropolis Museum has opened, a wonderful building of glass and steel built to display the many treasures found by archaeologists, and most especially the whole of the upper floor laid out to recreate the frieze around the top of the Pantheon.  There are some gaps, but much of the sculpture is either there, or, where the original is elsewhere, in plaster cast.

The plaster cast sections all say where they come from, except the vast majority simply say ‘BM’ … it took a few before this sunk in, the British Museum … the Elgin Marbles – too sore a point even to write the words in full.  Indeed the whole museum is partly a statement to show just how much is in London not Athens, and also that Greece is now quite capable of preserving them.

It is a complex question undoubtedly much more would be missing, eroded or damaged if Elgin had not shipped them to Britain in the 19th century, and clearly not every work originating in a country should be returned … I imagine all the obelisks around Rome being sent back to Egypt!   However, seeing the museum and vast proportion saying ‘BM’ brings home that this is not simply a small amount elsewhere, but a large proportion, and in many ways the ‘best bits’.

There is also something different about the iconic monuments of any nation: it is as if parts of the Tower of Pisa were in Germany or London Bridge in Arizona …

To take our minds off such heady matters Angela and her family took me swimming in a volcano.  Christmas music playing in the background while bathing in water at 22° C.

Lake3

Tech Wave is coming

The eighth Tiree Tech Wave is just over two weeks away.  We have some participants coming from GRAND NCE Canada’s Digital Media Research Network as well as those closer to home including the Code for Europe Fellows working in Nesta’s Open Data Scotland project.

There will be the normal open agenda, and also a few special activities.  Jacqui Bennet has  a little friendly competition planned and Steve Foreshaw from Lancaster will run a workshop on using low-cost 3D scanners, which we hope to then use to scan some of the lug boats around the island in collaboration with the Tiree Maritime Trust.

FabLab Cardiff are bringing a sort of mini-FabLab-in-a-van.  During the Tech Wave they will be making things themselves, including re-installing the Tiree touchable in a glorious new enclosure. They will also run some short tutorial/workshops on using some of the equipment for TTW attendees and Tiree locals.

FabLab Cardiff Cubify Sense 3D scanner Tiree Maritime Trust - lug boat in action

Although time is getting tight, I am hoping we might also have a couple of MicroViews, a miniature Arduino with built in OLED display.  I ordered a Learning Kit through their Kickstarter campaign with two MicroViews (Blinking Eyes), so looking forward to some winking teddy bears 🙂   After being ahead of schedule, they had a slight production problem with their second batch, and TTW is in the third batch, so keeping fingers crossed, but, if not this time, certainly at the spring 2015 TTW.

    

 

running and talking

September saw two events on Tiree; both exciting but each very different: at the beginning of the month the first Tiree Ultramarathon organised by Will Wright our very own Tiree superhero and towards the end ‘Re-Thinking Architecturally‘, a workshop of the European Network of Excellence on Internet Science organised by Clare Hooper from Southampton University.    I was lucky enough to take part in both.

In addition, in a few weeks time (23-27 Oct) there will be the eighth Tiree Tech Wave, which will include participants from Canada, Scotland, Wales and England (but no-one from Ireland yet).  As well as the usual unstructured serendipity, we will have some tutorial workshops of 3D scanning, 3D printing and laser cutting … but more about that in another post.

The Tiree Ultra

photo Rhoda Meek

I should first emphasise that I did not run all of the 35 mile ultra-marathon course around the coast of Tiree, but did about 50:50, walk/run.  I’d never done anything remotely like this before.  The longest I’d run was the Tiree half marathon back in May and the longest I’d walked during the Wales walk was a 29 mile day (although I did that over more than 12 hours).  I had as a schoolboy once done a 34 mile day hike up into the coal valleys above Cardiff, and one of the spurs to sign up for the Ultra was to beat my 17 year old self!

With my usual level of preparation it came to the beginning of August and I realised I’d not run at all, nor even taken a walk longer than to the beach and back, since the half-marathon in May.  Just before the event I found a couple of sites with training schedules for marathons, all of them were several months long and the ‘beginner’ level was “runs 15-25 miles  a week regularly” … what about zero miles a week?  Anyway my lengthy one month training schedule consisted mainly of short (2.5 mile) beach runs with the occasional 7.5 mile run to Hynish and towards the end a run of 8.5 miles along part of the route of the Ultra round the base of Ben Hynish.  I was aware I’d not done any really substantial runs and so, rather foolishly, on the Wednesday 4 days before the event I ran (and walked!) 21 miles around part of the route on the east end of the island and down to Hynish and back.  A good last run before the event, but one I should have done a week earlier.

Somehow or other, despite my foolish training schedule, I managed to get round without any serious injury.  My main problem was eating, or rather failing to eat. I found I could only mange food during walking stages, and then just a small amount of Kendal Mint Cake and few bananas, I guess overall I managed to burn around 4000 calories, but ate less than 1000, which really made the legs start to tire as I got to the latter parts of the course.  I’ve already entered for the 2015 Tiree Ultra next September (half the places are already gone and entries have only been open a week), but I will have to work out how to eat better before then.  Crucially I got round the course … and not even last.  The serious contenders managed times not much more than 4 1/2 hours whilst I got round in just over 8:20, but I was simply happy to get to the end.

Although it was further and faster than any day walking last year, it was in many ways a lot easier than the Wales walk.  About 2/3 of the way round the Tiree course my right ankle and calf started to stiffen, which was where I’d had Achilles ankle problems a couple of years ago.  Although I did try to ease a little I was not terribly worried; the worst would be that I’d be hobbling for a month or so after the run.  In contrast, last year I knew that I would be walking again the next day, and the next,and the one after that; with each ache I worried whether it would be the injury that did not get better, and stopped the walk. And, despite the worry of this, I had also learnt quite how resilient the body is, that most pains and strains did get better, albeit slowly, despite unrelenting exercise.

I was also reminded very much of the walk when I finished.  I took off my running shoes and socks, the latter sodden from beach and bog, and filled with fine layer of sand.  The soles of my feet, which had been subjected to 35 miles of damp sandpaper, felt like I was walking on coals and I hobbled about between van and Ceadhar where they laid on a post-walk pizza and party.  It was just like that so many days last year, I would get to where I was staying, ease off my boots, put on sandals, and then hobble out in search of food, wondering if I would get as far as the closest pub or cafe, let alone walk again the next day.

Re-thinking Architecturally

The Internet Science workshop was equally enjoyable, but a little less physically challenging!  It brought together economists, architects, lawyers, policy advisors, and some with more technical background from as far afield as Umea in northern Sweden. It was lovely being able to attend a technology workshop on Tiree that I hadn’t organised 🙂

Clare had been to one of the Tiree Tech Waves, and then, when she was organising a workshop for the European Network of Excellence on Internet Science, she thought of Tiree.  The logistics were not without problems, but after the event I’ve been getting together with the Tiree Trust to make an information pack for future organisers to make the process easier.  So if if you would like to organise an event on Tiree, get in touch!

The participants all seemed utterly taken with the venue, several brave souls even swimming in the mornings off the Hynish pier, in the words of one of the participants on the way back after the event “I’d rather be in Tiree!”.  Another said:

“one great consequence of the week in Tiree was a kind of intellectual regeneration that let me set aside the stresses of the coming academic year and…think openly a bit.”
Alison Powell (London School of Economics)

In fact this is precisely the feedback I get from many who have been to Tiree Tech Wave.  It is hard to capture in words the way the open horizon and being at the wild-edge opens up the mind, especially when meeting with others equally committed to exploring new ideas freely and openly.

One of the memorable moments from the week was a debate of internet freedom and regulation.  We started off half on one side half the other and then part way through we all had to swop sides.  I can’t believe how passionate I got about both sides of the argument … and I managed to wheel in my school English teacher as authority on benevolent dictatorship1.

photo Parag Deshpande

photo Rory at Balevullin

People

While two very different events, a common story was the wonderful welcome of the people of Tiree.  During the Ulta-marathon, at every way-station there was a glorious array of tray bakes, chocolates, pre-sliced fruit, and above all smiling faces.  This was great for me seeing faces I knew, but clearly very special for the participants who came from afar being greeted as if they too were friends.  For the Re-thinking Architecturally workshop many people made it a success: the wonderful team at the Hynish Centre, especially Lesley who kept on smiling despite a seven hour wait for participants whose travel was disrupted, everyone at Ceadhar, Ring n Ride, and at the airport re-arranging travel across Europe when the Thursday plane was cancelled.

  1. I wrote what I thought to be a masterful mock O’level essay that asserted that Macbeth was actually a good king taking a ‘he made the trains run on time’ argument — my English teacher, Miss Griffiths, was not impressed.[back]

being British? always a second class citizen

The most important reason for a ‘Yes’ vote in the upcoming Scottish independence referendum is the potential for a new nation that is a beacon of a fairer, greener and more inclusive society.  This would ultimately be to the good of the whole of the UK.

However, I’ve also noted a general lack of comprehension by many south of the border who struggle to understand the desire for Scottish Independence.

This was voiced a few days ago in a Facebook thread and this was my response as a Welshman living north of the border.:

As a Welshman I have always had a romantic nationalist edge, but also felt a strong British patriotism.

However events over the years, and not least the referendum campaign have hardened this.  Again and again Westminster politicians tell us that Scotland is better with England, as if Wales and Northern Ireland did not exist.

I have heard this language all my life: in the 50th anniversary celebrations of the second World War, in numerous debates in immigration, in company registration (registered in Cardiff, a company in England and Wales, but subject to *English* law), … and has been noted several times the Bank of England.

The difference in this campaign is that this is when politicians are supposed to be being careful of their language.  We even had the government lawyer explaining that the separated rUK and Scotland would not be equally parts of a previous single nation when looking towards external international bodies, not based on measures such as the population (reasonable), but because really and legally Scotland was never a partner country in a union, but was always amalgamated unto England.

There have been hundreds of years to sort out these things, but it has not happened yet, what chance for the next 100 years?

As a  child I was pedalled a lie.

There never was, and never will be a Britain.

As a Welshman, I am as British as Indians were in the ‘British Empire’.

Within the UK I always have been, and always will be, a second class citizen.

In contrast to this Scotland (despite sectarian tensions that erupt occasionally in Celtic-Rangers crowds) accepts incomers as was amply demonstrated in the difference between the spitting bigotry of the Westminster leaders’ debates at the last General Election compared with the far more civilised, cultured,and above all inclusive Scottish leaders’ debate, with all parties, including the Scottish Conservative leader, praising the richness through diversity and immigration.

Whether it is a ‘Yes’ or a ‘No’, the shape of the UK will change fundamentally tomorrow.

If it is ‘No’, I hope the UK will eventually wake up to the fact that it is a nation of nations.

If it is ‘Yes’, then I know, that even as a Welshman far from my birthplace, I will be in a country where I can feel at home.

why Ukraine upsets me – the death of democracy

As is probably evident from occasional Tweets or Facebook comments, I can get hot under the collar about the events in Ukraine.  This is for several reasons, but for now the first and most important reason.

It should shock us all.

For the first time since the Second World War, we have seen the violent overthrow of a democratically elected government in Europe.

Let that sink in.

It does not matter whether you are pro-European or pro-Russian, left wing or right wing. In February we saw the overthrow of democracy in Europe.

That is shocking.

We have seen conflict in Europe before.  The breakup of the Iron Curtain was largely peacefully, with just the the odd tank fire on the Russian Parliament, but that can be passed by as the final effects of totalitarian government.  In Yugoslavia we saw a democratic state implode after the secession of part of its people, the violent reaction of central government and eventual ethnic cleansing.

We have seen democratic governments overthrown elsewhere: in Chile in the 1970s, in Egypt more recently.  However, the first was during the Cold War days, when anything was acceptable to defend against communism (the CIA even made contingency plans to  overthrow the Harold Wilson Labour government!), and in the latter case the Muslim Brotherhood government were arguably working to remove aspects of democracy.

But Ukraine was different.  It is clearly a complex situation, and it is easy to be critical from a distance.  The politics there is factional, rather like Northern Ireland, and clearly driven very strongly by the super-rich, not so unlike the US.  So, whether the pre-February Government in Ukraine was a good or bad one is a matter of debate, but its election was not.  The 2010 poll was operated by the previous pro-European administration, so there was no element of Gerrymandering, and, as far as any poll in the area could be, it was regarded as fair.

That is, there was no challenge to the fundamental democratic legitimacy of the pre-Feb 2014 government.

Yet, we watched and encouraged its violent downfall.

It is almost hard to recall now.  Certainly the BBC tends to remind us of the events in Crimea and the rise of pro-Russin separatists as the start of the conflict, but of course these were the response not the start.

The start was the Maidan protests; the daily images of police lines with fire bombs raining down, the arming of the protestors, the eventual bloody clashes with large numbers of protesters and also many police left dead on the streets, and the ensuing decision of the president to give up power rather than bring the army onto the streets of Kiev.

I imagine this was Britain.  Thatcher in 1990 and the Poll Tax riots; Blair in 2003 and the anti-Iraq War protests; Cameron in 2012 and the ‘Occupy’ movement.  In all cases, my sympathy was with the demonstrators, in all cases I wished the government had listened more to them, just as I’m fairly sure most of the Ukrainians I know would have supported the original causes of Maidan.  However, neither I nor anyone in the UK, whether they sided with the Poll Tax, Anti-War or Occupy protesters or with the government, would have wished for this to end with the overthrow of the government and the remaining parliament making decisions with the masked ex-protestors standing with automatic weapons at the doors of Westminster.

This is what happened in Ukraine.

And we in the West supported it, indeed encourage it.  US senator John McCain visited the demonstrators early, while they were still a peaceful ‘occupy’-like movement.  However,  EU representatives were there after the far-right elements had armed.

The press dressed this as people power against autocratic government.

It never was, simply a democratic government that made a decision that a large minority of its people (often violently) disagreed with, and most fundamentally was not one that we in the west agreed with.

And for the majority of people in Ukraine, for those who voted a government they trusted, we taught them that democracy does not pay, that democracy is a sham, that democracy is only good if the government you elect does the ‘right’ things as judged by the western media.

We have witnessed the death of democracy.

And applauded it.

 

just running (and the odd walk)

I now feel  little more prepared for Sunday’s 35 mile Tiree ultramarathon, which is following the coats of the island as closely as possible.  Sort of a bit like my walk around Wales, but on a smaller scale!


Tiree Ultamarathon Route

I’m planning to do a mix of run and walk.  The target is to get round in 10 hours.  This would be a doodle if it were all road and beaches as I can average 4 miles an hour fast walk, but the rough ground sections will be slow, so I need to run when I can to make up.

Today I ran and walked the section of the route that goes round the east end of the island, 11.5 miles on Sunday’s route, then 2 miles back across the island to home, and then, to cap off threw in a little 7.5 mile run down to Hynish and back.  In all 21 miles in five and a quarter hours, so the running and slow walking averaging out at 4 miles an hour, on track. I’m bound to slow a little as the day wears on, and the weather is set to be less good on Sunday, but it’s good to know I’m in the right ballpark.

My only problem is eating enough while moving.  I did manage to eat a Mars bar, but find it hard to eat when I’ve just been running, so had to wait for the long walk sections — I guess why the professional runners all use those gel packs.  I think I’ll get some more Kendal Mint Cake as that is far easier to simply suck/crunch and swallow, and no load on the stomach — straight sugar!

Of course, now it is evening I have to try and catchup with all the work I should have been doing in those five and quarter hours :-/

I’m not really doing it ‘for’ anything , but if you feel inspired the JustGiving pages on AlanWalksWales are still open for donations.

big brother Is watching … but doing it so, so badly

I followed a link to an article on Forbes’ web site1.  After a few moments the computer fan started to spin like a merry-go-round and the page, and the browser in general became virtually unresponsive.

I copied the url, closed the browser tab (Firefox) and pasted the link into Chrome, as Chrome is often billed for its stability and resilience to badly behaving web pages.  After a  few moments the same thing happened, roaring fan, and, when I peeked at the Activity Monitor, Chrome was eating more than a core worth of the machine’s CPU.

I dug a little deeper and peeked at the web inspector.  Network activity was haywire hundreds and hundreds of downloads, most were small, some just a  few hundred bytes, others a few Kb, but loads of them.  I watched mesmerised.  Eventually it began to level off after about 10 minutes when the total number of downloads was nearing 1700 and 8Mb total download.

 

It is clear that the majority of these are ‘beacons’, ‘web bugs’, ‘trackers’, tiny single pixel images used by various advertising, trend analysis and web analytics companies.  The early beacons were simple gifs, so would download once and simply tell the company what page you were on, and hence using this to tune future advertising, etc.

However, rather than simply images that download once, clearly many of the current beacons are small scripts that then go on to download larger scripts.  The scripts they download then periodically poll back to the server.  Not only can they tell their originating server that you visited the page, but also how long you stayed there.  The last url on the screenshot above is one of these report backs rather than the initial download; notice it telling the server what the url of the current page is.

Some years ago I recall seeing a graphic showing how many of these beacons common ‘quality’ sites contained – note this is Forbes.  I recall several had between one and two hundred on a single page.  I’m not sure the actual count here as each beacon seems to create very many hits, but certainly enough to create 1700 downloads in 10 minutes.  The chief culprits, in terms of volume, seemed to be two companies I’d not heard of before SimpleReach2 and Realtime3, but I also saw Google, Doubleclick and others.

While I was not surprised that these existed, the sheer volume of activity did shock me, consuming more bandwidth than the original web page – no wonder your data allowance disappears so fast on a mobile!

In addition the size of the JavaScript downloads suggests that there are doing more than merely report “page active”, I’m guessing tracking scroll location, mouse movement, hover time … enough to eat a whole core of CPU.

I left the browser window and when I returned, around an hour later, the activity had slowed down, and only a couple of the sites were still actively polling.  The total bandwidth had climbed another 700Kb, so around 10Kb/minute – again think about mobile data allowance, this is a web page that is just sitting there.

When I peeked at the activity monitor Chrome had three highly active processes, between them consuming 2 cores worth of CPU!  Again all on a web page that is just sitting there.  Not only are these web beacons spying on your every move, but they are badly written to boot, costuming vast amounts of CPU when there is nothing happening.

I tried to scroll the page and then, surprise, surprise:

So, I will avoid links to Forbes in future, not because I respect my privacy; I already know I am tracked and tracked; who needed Snowdon to tell you that?  I won’t go because the beacons make the site unusable.

I’m guessing this is partly because the network here on Tiree is slow.  It does not take 10 minutes to download 8Mb, but the vast numbers of small requests interact badly with the network characteristics.  However, this is merely exposing what would otherwise be hidden: the vast ratio between useful web page and tracking software, and just how badly written the latter is.

Come on Forbes, if you are going to allow spies to pay to use your web site, at least ask them to employ some competent coders.

  1. The page I was after was this one, but I’d guess any news page would be the same. http://www.forbes.com/sites/richardbehar/2014/08/21/the-media-intifada-bad-math-ugly-truths-about-new-york-times-in-israel-hamas-war/[back]
  2. http://www.simplereach.com/[back]
  3. http://www.realtime.co/[back]

JavaScript gotcha: var scope

I have been using JavaScript for more than 15 years with some projects running to several thousand lines.  But just discovered that for all these years I have misunderstood the scope rules for variables.  I had assumed they were block scoped, but in fact every variable is effectively declared at the beginning of the function.

So if you write:

function f() {
    for( var i=0; i<10; i++ ){
        var i_squared = i * i;
        // more stuff ...
    }
}

This is treated as if you had written:

function f() {
    var i, i_squared
    for( i=0; i<10; i++ ){
         i_squared = i * i;
         // more stuff ...
    }
}

The Mozilla Developer Network describes the basic principle in detail, however, does not include any examples with inner blocks like this.

So, there is effectively a single variable that gets reused every time round the loop.  Given you do the iterations one after another this is perfectly fine … until you need a closure.

I had a simple for loop:

function f(items)
    for( var ix in items ){
        var item = items[ix];
        var value = get_value(item)
        do_something(item,value);
    }
}

This all worked well until I needed to get the value asynchronously (AJAX call) and so turned get_value into an asynchronous function:

get_value_async(item,callback)

which fetches the value and then calls callback(value) when it is ready.

The loop was then changed to

function f(items)
    for( var ix in items ){
        var item = items[ix];
        get_value_async( item, function(value) {
                                do_something(item,value);
                          }; );
    }
}

I had assumed that ‘item’ in each callback closure would be bound to the value for the particular iteration of the loop, but in fact the effective code is:

function f(items)
    var ix, item;
    for( ix in items ){
        item = items[ix];
        get_value_async( item, function(value) {
                                do_something(item,value);
                          }; );
    }
}

So all the callbacks point to the same ‘item’, which ends up as the one from the last iteration.  In this case the code is updating an onscreen menu, so only the last item got updated!

JavaScript 1.7 and ECMAScript 6 have a new ‘let’ keyword, which has precisely the semantics that I have always thought ‘var’ had, but does not seem to widely available yet in browsers.

As a workaround I have used the slightly hacky looking:

function f(items)
    for( var ix in items ){
        (function() {
            var item = items[ix];
            get_value_async( item, function(value) {
                                    do_something(item,value);
                              }; );
        })();
    }
}

The anonymous function immediately inside the for loop is simply there to create scope for the item variable, and effectively means there is a fresh variable to be bound to the innermost function.

It works, but you do need to be confident with anonymous functions!