Thursday 26 January 2012

Important upcoming change: starting Gecko 12, pre-Windows 7 SDKs will no longer be supported

tl;dr: if you're on an outdated Windows build configuration, upgrade.

I just checked in a patch to mozilla-inbound to drop support for SDKs prior to the Windows 7 SDK. Depending on when you last updated your build configuration, your Mozilla build might break.

Everything's documented on the Windows SDK versions page on MDN; here's a quick summary of what you need to do:
  • If you're on Windows 2000: Upgrade to Windows XP, Vista or 7.
  • If you're on Windows XP SP1 or below: Update to the newest service pack.
  • If you have an older SDK (Vista or 2003): Install the Windows 7 SDK instead. You can either download it separately or use Visual C++ 10 Pro, which comes with it.
  • If you use Visual C++ 8 (2005) Express or Visual C++ 7.1 (VS2003): Upgrade to Visual C++ 10 (2010; recommended; pro or express) or Visual C++ 9 with Service Pack 1 (2008; pro or express).

Wednesday 25 January 2012

MSVC9+ opt builds currently broken due to a compiler bug

Optimized builds with Microsoft Visual Studio 2008 (VC9) and above are currently broken because of what we believe is a compiler bug. More information and workaround in bug 718541.

Wednesday 18 January 2012

C# 5.0 to have fresh bindings per iteration

Straight from Eric Lippert. Great news. Now if only ECMAScript Harmony included a fix for this bug...

Saturday 14 January 2012

More experiences with an Apple notebook

It's now been eight months since I got my first Apple notebook. A few months ago I wrote about my initial opinion, where I was pretty sure it would be my last Apple notebook too.

Since then I've had the chance to use it in a variety of situations. Spoiler: none of what I've seen has improved my opinion of it one bit.
  1. The decision to make the outer body out of aluminium is literally shocking. If the notebook isn't plugged in to a grounded socket (for instance, if I'm using the plug that comes with the power brick BY DEFAULT), I'm liable to get electric shocks if I touch the casing. I received a couple of shocks, a mild one and a jolting one, before I realized what was happening. Electrical common sense is that if the outer surface is electrically conducting, it MUST be grounded properly. Having an ungrounded plug by default, or even having one in the first place, is inexcusable. (Update: I've had several people complain to me about this, and one person also complain about his plastic macbook's screws shocking him several times. I'm clearly not the only one with this issue.)
  2. The Wi-Fi reception is the worst I've ever seen in a laptop, and only slightly better than the reception my Nexus S with its puny little antenna gets. Friends tell me it's because the aluminium casing acts as a Faraday cage and attenuates the signal. The "unibody" marketing's clearly far more important to Apple than shipping a working product. (Update: guess who says metal has a "very high" potential to interfere with wireless connections?)
  3. The original power adapters were T-shaped. However, presumably because Apple didn't like the look of and subsequently didn't include the strain-relieving flexes found on all other cables, they were easily frayed. To "fix" this, they started using L-shaped adapters. Of course, what it now means is that depending on the way I insert it, either the power cord blocks the Ethernet port or it gets subjected to strain if I tilt the notebook back.
  4. There's no VGA, DVI or HDMI port, so I need to carry around a set of three dongles everywhere I go. There's plenty of space on the left side, too, so that's not an excuse.
  5. The lack of working sleep is more annoying than I thought it would be. Amazingly, the EFI equivalent to the POST takes almost as long as Windows resuming from hibernation. A few people seem to be working on getting Windows to boot via EFI, and my hopes are mostly pinned on that.
My iPod nano media player, the only other Apple product I own, is actually well-designed (save for the fact that I need to keep the piece of crap called iTunes around on my computer, even though I don't need to use it.) This is not. This stinks of form-over-function failure.

Edit (25/1): Two inline updates.

Friday 30 December 2011

So, what *is* recursion?

Recursion's one of the cornerstones of computer science. The fundamental thesis of computer science says that recursion and iteration (and the untyped λ-calculus) have the same power. People introduced to programming through imperative languages often find the idea of recursion hard, though there are good arguments that that's really a deficiency in our teaching.

So, what exactly is recursion then? And what, for that matter, is iteration?

Wikipedia defines recursion as "a method where the solution to a problem depends on solutions to smaller instances of the same problem". I haven't had major problems with this definition until recently, when I was reading the wonderful Concepts, Techniques and Models of Computer Programming (CTM), which unsurprisingly defines an iterative computation as "a loop whose stack size is bounded by a constant". The examples that it gives are far more surprising, though. Here's an iterative computation to find the length of a list in Oz, the language CTM uses:

fun {IterLength I Ys}
  case Ys
    of nil then I
    [] _|Yr then {IterLength I+1 Yr}
  end
end

Programs like this wouldn't be called iterative in a language like C at all! They'd instead all be called tail recursive. Oz optimizes tail calls so that they don't cause the stack to blow up.1

Even more surprisingly, and perhaps a bit confusingly, it then goes ahead and calls iterative computations a special case of recursive computations, rather than something distinct. It then talks about converting recursive computations to iterative ones (using accumulators and the like), which I take to mean converting non-iterative computations to iterative ones.

Granted that these definitions are from a declarative point of view, where all state is immutable and thus for or while loops don't make sense, but does that then mean that recursion and iteration can only be defined with respect to the language you're writing in? I've never been fully convinced by Guido van Rossum's arguments against tall call optimization in Python, but considering that the feature can determine whether a given program is iterative or not, the arguments start making a lot more sense.

And what about tail recursion modulo cons then, as found in languages like Haskell and Oz? Optimizing tail recursion modulo cons allows functions that aren't tail-recursive, but where the only thing left to execute after the call is a data constructor like cons, to avoid blowing up the stack2. Consider this definition of the map function:

fun {Map F Xs}
  if Xs==nil then nil
    else {F Xs.1}|{Map F Xs.2}
  end
end

This function is clearly not tail recursive, and if translated directly to a language like Scheme which optimizes tail calls but not tail recursion modulo cons, this function would cause a stack overflow with a large enough list. However, since the only thing left after the recursive call is the cons operation (denoted by |), in Oz this function is iterative by the CTM definition3.

So, then, does it make sense to define iteration as any computation in a given language which only takes O(1) implicit (stack) space when executed, and recursion as any computation in a given language which references itself? This would mean that the two aren't quite the opposites they're often portrayed to be, and that depending on the language, recursion and iteration could either overlap or be distinct.

And does it make sense to make this explicit while teaching kids how to program?


1 Interestingly, Oz doesn't have a separate optimization for tail calls. That tail calls don't cause the stack to blow up follows naturally from the way Oz executes programs, as became clear to me when I wrote a self-interpreter for Oz for a school assignment.

2 Again, neither Haskell or Oz have a separate optimization for this. It's a natural, straightforward result of Haskell's laziness and Oz's data-flow variables (everything's a promise in Oz!).

3 Peter Van Roy, one of the authors of CTM and an Oz developer, explains how this happens in Oz.

Sunday 25 December 2011

Why we shouldn't switch to git, part 2

If unnecessarily bad performance in the usual configuration for anyone on Windows Vista or above wasn't bad enough, msysgit also automatically sets up terrible defaults, leaving first-time developers' heads scratching.

Mercurial, of course, does the right thing here and leaves files alone.

Practically every editor on Windows -- Visual Studio, emacs, vim, Sublime Text -- supports LF endings just fine. As far as I know, Notepad's the only one that doesn't. If you're optimizing for Notepad over everything else, something's really gone wrong.

Monday 14 November 2011

Why ad blocking is not a moral dilemma

(These are my own views.)

A common meme doing the rounds these days is that blocking advertisements on sites that depend on it is immoral. I don't believe so mainly because fundamental issues like user sovereignty and control override anything else, but some take the more practical stance that it hurts site owners. I don't think this view is valid. Here's why.
  • Web advertising is a relationship among three entities. It's not just the user and the site owner who are part of it, it's the advertiser too.
  • Using ad blockers means the user's not interested in advertising in the first place. Clearly, if she were interested in viewing and clicking on ads, she wouldn't be using an ad blocker. Saying that she should become interested in advertising is not a morally tenable position.
  • Loading ads without being interested in them hurts the advertiser. Assuming a cost-per-impression model, what would benefit the advertiser more: a thousand impressions to people, all interested in advertising, or ten thousand impressions to people, only 10% interested in them?
  • A user not interested in advertising has to "hurt" either of the other two in the relationship. Either the site owner is hurt because the user doesn't load advertisements, or the advertiser is hurt because the user loads advertising that she was never interested in in the first place. Deciding which one is hurt can't be left to either the owner or the advertiser because both have vested interests -- so it has to be done by the user. I don't think there's a way to morally distinguish between the owner and the advertiser.
  • But what about visual impressions? The argument here is the mere sight of advertising, without a click-through, builds up brand recognition and is therefore of value to the advertiser. However, using this as the basis for some sort of normative argument ("you should subject yourself to advertising so that advertisers can build brand recognition in you!") is basically advocating mind control, hence this isn't morally tenable either.
Update: Speak of the devil. A Blogger message just popped up asking if I'd like to add advertising to my blog.

Thursday 20 October 2011

Why we shouldn't switch to git

Apparently basic support for Windows is considered Somebody Else's Problem. This is easy to work around by using PortableGit instead, but I wonder how many more such Somebody Else's Problems are lurking in the shadows.

Wednesday 24 August 2011

Upcoming changes to mozconfig detection

I just checked in a patch to build-system which changes our mozconfig detection logic. Specifically:
  • If you want to specify an explicit mozconfig, the only way to do that now is to set the MOZCONFIG environment variable. We used to support the obscure MOZ_MYCONFIG variable too, but we now error out if it is set. Note that if MOZCONFIG is a relative path, it will be treated as relative to the current directory. (update: apologies, this is still broken).
  • More significantly, we used to support a number of implicit mozconfig locations other than the usual <srcdir>/.mozconfig, such as $HOME/.mozconfig and a couple of variants. This went against build system's policy to be as explicit as possible, so these locations are no longer supported, and if we used to pick up a mozconfig there we will now error out. The only implicit location still supported is the usual <srcdir>/.mozconfig.
This patch should make it into mozilla-central soon, well in time for Gecko 9. This patch will also affect comm-central in the same way

    Tuesday 16 August 2011

    Taskbar overlay icons on Windows 7

    Windows 7's taskbar supports dynamic overlay icons. They're useful for such things as status icons and new mail notifications. We don't support them in Gecko yet, but I have a work-in-progress patch to add support for them.

    Playing along

    Grab this try build and add this restartless extension to your profile. To change the icon being displayed, go to the extension's options and enter the URL to a 16x16 static image (ICO, PNG, JPG...). These URLs can be anything Firefox supports, including http, file and Mozilla's own moz-icon. Interesting URLs to try out:
    • chrome://browser/skin/feeds/feedIcon16.png
    • moz-icon://file:///C:/Windows/explorer.exe
    • moz-icon://foo.jpg
    • moz-icon://stock/uac-shield
    • https://www.mozilla.com/favicon.ico ("yo dawg" if this were an official Firefox build)
    Update (today): forgot to add: the extension's available on GitHub too, so grab the source.