Archives for April 2009

April 2009 (9)
SMTWTFS
« Mar May »
1234
567891011
12131415161718
19202122232425
2627282930

Like this Archive Calendar widget? Download it here.


JavaScript for C# developers: date basics

A scenic diversion on the road to understanding JavaScript when you're a C# programmer. In this episode, we'll look at dates in JavaScript. Dates are implemented in JavaScript by the Date() constructor function, which acts like a class. You can new up a Date object in much the same way as you new up a DateTime object in C#. For instance, here's how to create a date that's equal to the date I wrote this post (Mon, Apr 27, 2009): var today = new Date( 2009 , 3 , 27 ); console.log(today.toDateString...

READ MORE

More on the lock-free stack/queue: memory fences

Last time I talked about the lock-free stack and queue , I was more concerned about proving that my code was free from the ABA problem than anything else. In making my argument I naturally glossed over such niceties as the .NET memory model and so assumed (pretty much) a sequential memory model, because, to be honest, that's how we think as programmers. Consider the following set of statements in C#: int foo; bool fooHasBeenSet = false ; // ... foo = 42 ; fooHasBeenSet = true ; Now, you and I...

READ MORE

Someone is wrong on the internet — the lock-free stack edition

Getting on for 4 years ago, I wrote a series of posts on lock-free containers in .NET, like the lock-free stack and the lock-free queue . They were fun to write, mainly because of the difficulty of the topic and trying to rationalize why early versions didn't work, and so on so forth. Along the way I learned about the .NET memory model, volatile , memory fences, and other arcana, but in the end I had something that worked and worked well. Over the years since then I've had many emails from...

READ MORE

Mentioned in PCPlus letters page

I was reading the latest PCPlus issue yesterday evening in bed — well, all right, the latest one (April) that's reached the Wild West in Colorado, which means them what's in England are probably up to June's issue or something — when I came across a paragraph that mentioned me on the PCPlus Feedback page (or if you like, the letters page). A certain Peter Atherton (obviously a man of great taste and discernment) was complimenting the Editors on an article on displaying Mandelbrot...

READ MORE

PCPlus 267: Use algorithms to break up paragraphs

I write a monthly column for PCPlus, a computer news-views-n-reviews magazine in the UK (actually there are 13 issues a year — there's an Xmas issue as well — so it's a bit more than monthly). The column is called Theory Workshop and appears in the back of every issue. When I signed up, my editor and the magazine were gracious enough to allow me to reprint the articles here after say a year or so. After all, the PDFs do appear on each issue's DVD after a couple of months....

READ MORE

New calculator: Sinclair Scientific

I admit it, I am a helpless geek: I love collecting old calculators and computing devices. My wife thinks I'm bananas, and she may be right, but there's just something about holding something from the dawn of calculating electronics. A couple of weeks ago, I snagged a very nice looking Sinclair Scientific, complete in its original box with the manual. This is a tiny (for the time anyway; this was 1974) calculator in the Cambridge series from Sinclair, and purports to be a scientific calculator...

READ MORE

Party Shuffle Friday

This week it's a Party Shuffle Good Friday. Stereo Tonic , by Thunderball, from Scorpio Rising . Nice bit of electronica from a little known band. I found them through one of Thievery Corporation's remix albums and decided to try them out. Not bad at all: echo-ey, sitar-ey, downtempo beats. Fisherman's Blues , by The Waterboys, from The Best of the Waterboys: 1981-1990 . From the Waterboys' Irish folk phase, and I'd have to say I'm not a great fan of it, I'm afraid. Catchy enough beat and tune, lots...

READ MORE

JavaScript for C# developers: functions are objects

Another stop on the long road to JavaScript understanding from a C# developers perspective. This time we really look at what it means to say that functions are not only objects, but first-class objects in JavaScript. Over this series I've constantly declared functions using function expressions instead of function statements. For example, I've used: var isFiniteNumber = function (value) { return (( typeof value === "number" ) && isFinite(value)); }; instead of this: function isFiniteNumber...

READ MORE

Party Shuffle Friday

The partygoers a couple of weeks ago were sniggering behind my back when they left. It seems that it wasn't Peter Gabriel leaving Genesis that triggered the self-referential name of their next album, but Steve Hackett (thanks to me old mate Larry for pointing it out to me). Man, my memory is surely going. I could have sworn I was right, but Larry and wikipedia have shown me the error of my ways. This week, undeterred, I'm going for broke... Shoo-Bee-Doo , by Madonna, from Like a Virgin . Well known...

READ MORE