Older blog entries for mbrubeck (starting at number 122)

Fennec 2 update: The road to alpha

The Mozilla Mobile team has been quiet lately. We're making a lot of under-the-hood changes for the next version of Fennec (Firefox for mobile), and have been focused on getting basic functionality working again after some major platform changes.

Now things are starting to stabilize, and we are gearing up for the first Fennec 2.0 alpha release in just a few weeks. There are still noticeable bugs in our current builds, but it is possible to use them now for testing, add-on development, and regular web browsing (if you don't mind occasional crashes).

Under the hood

The biggest back-end change in Fennec 2 is Electrolysis (a.k.a "e10s"). By moving content rendering and JavaScript into a separate process, e10s allows the Fennec UI to stay responsive while pages are loading. This required us to rewrite large parts of the Fennec UI and platform code, a process that is finally approaching completion.

After the alpha release, the next big platform changes will be related to Layers. Fennec currently handles panning and zooming by dividing pages into "tiles" and rendering them on HTML canvas elements. This works, but it is complicated and not as fast as we'd like. The new layers system will let us replace Fennec's custom tile management with hardware-accelerated rendering and compositing built into the Firefox 4.0 platform.


We have a bunch of new features planned for the Fennec UI. A few of these have already started to land, so you can try them in nightly builds or the upcoming alpha:

  • Firefox Sync is now built in – sync tabs, bookmarks, and history from your computer to your phone, no add-on required!

  • The new Find In Page command is available through the site menu (or by pressing Control+F on a hardware keyboard).

  • You can now share links through Twitter, Facebook, Google Reader, or email. (The final version of this feature will also let you send links using native Android or Maemo apps.)

  • Fennec 2 can use your phone's address book to make it easy to enter phone numbers and email adresses into web forms. (This works on Maemo now; support for Android will be added later.)

  • We're adding multi-touch gestures. Pinch zoom has landed for alpha; later releases will also include multi-touch swipe gestures to go to the top or bottom of the current page, or navigate between pages.

The design of these features is not yet final, so their look and feel may change significantly before the final release.


Fennec 1.0 and 1.1 were for available only for Nokia's Maemo operating system. Fennec 2 will run on the Google Android platform, as well as Maemo and its successor MeeGo.

Fennec for Android is brand new, but it is progressing fast. Most of the blocking bugs for alpha 1 have been fixed in the last few days, and the very latest nightly builds are usable for regular browsing, though still rough in places.

Some of our most visible Android bugs were related to keyboard and input method support. Jim Chen's IME rewrite fixed a lot of these bugs, including a crash on startup with the popular Swype keyboard. There are still a few keyboard bugs left to fix before alpha 1.

Other Android changes, like alert-bar notifications and a new visual theme, will appear in our beta releases this fall.


For Fennec add-ons, the biggest change coming is Electrolysis. Any add-on code that interacts with web content through the DOM must now be in a separate script that runs in the content process. Mark Finkle has written a very useful Electrolysis guide for add-on authors.

In Fennec 1.1 we added the site menu and context menu. Fennec 2 will have improved APIs for add-on authors to add new items to either of those menus. Documentation of the new APIs is coming soon.

(Note: Add-on installation from web pages is broken in today's nightly build. This will be fixed before the 2.0a1 release.)

Nightly builds

Fennec 2.0 alpha 1 will go into code freeze as soon as the remaining a1 blocker bugs are fixed. If you want to start testing or developing for Fennec 2 even sooner, you can download a nightly build today. Just remember this is still pre-alpha software, and you should expect bugs.

  • Maemo users can use the trunk repo to stay up to date with the latest nightly build.

  • For Android users, the Fennec for Android wiki page has pointers to the latest nightly build, plus a list of known bugs and compatible hardware. (A number of Android blogs have linked recently to random TryServer builds and out-of-date blog posts. Please go to the wiki page instead to get the latest information.)

  • If you don't have a compatible Maemo or Android device, you can always download nightly Fennec builds for Mac/Windows/Linux and try out Fennec on your desktop or laptop.

If you have questions, feedback, or bug reports, file them under Fennec in Bugzilla, or come to the #mobile channel on irc.mozilla.org to chat with us!

Syndicated 2010-08-12 23:23:00 from Matt Brubeck

Implementing the viewport meta tag in Mozilla Fennec

The upcoming release of Mobile Firefox (Fennec) 1.1 features improved support for the <meta name="viewport"> tag. Previous version of Fennec supported the width, height, and initial-scale viewport properties, but had problems with some sites designed for iPhone and Android browsers. We now support the same properties Safari does, and we changed Fennec to render mobile sites more consistently on screens of different sizes and resolutions.

touch.facebook.com before:

touch.facebook.com after:

You can see these changes for yourself in the latest 1.1 or trunk nightlies.


Mobile browers like Fennec render pages in a virtual "window" (the viewport), usually wider than the screen, so they don't need to mangle existing layouts by squeezing them into a tiny window. Users can pan and zoom to display different areas of the viewport.

Mobile Safari introduced the "viewport meta tag" to let web developers control the viewport's size and scale. Many other mobile browsers now support this tag, although it is not part of any web standard. Apple's documentation does a great job explaining how it works for web developers, but it leaves out some information that would be useful to browser vendors. For example, it says the content attribute is a comma-separated list, but existing browsers and web pages use a mix of commas, semicolons, and spaces as separators.

A pixel is not a pixel

The iPhone and many popular Android phones have 3- to 4-inch screens with 320×480 pixels (~160 dpi). Fennec's target devices have the same physical size but 480×800 pixels (~240 dpi). Because of this, the last version of Fennec displayed many pages about one third smaller (in physical units) than iPhone or Android. This caused usability and readability problems on many touch-optimized web sites. Peter-Paul Koch wrote about this problem in A pixel is not a pixel is not a pixel.

Fennec 1.1 for Maemo will use 1.5 hardware pixels for each CSS "pixel," following the lead of the Android browser. This means a site with "initial-scale=1" will render at the same physical size in Fennec for Maemo, Mobile Safari for iPhone, and the Android Browser on both HDPI and MDPI phones. It's also consistent with the CSS 2.1 specification, which says:

If the pixel density of the output device is very different from that of a typical computer display, the user agent should rescale pixel values. It is recommended that the pixel unit refer to the whole number of device pixels that best approximates the reference pixel. It is recommended that the reference pixel be the visual angle of one pixel on a device with a pixel density of 96dpi and a distance from the reader of an arm's length.

This change only affects web pages that explicitly set the viewport size or scale. The pixel ratio is 1.5 applies only if the viewport scale is set to 1. The size of a "pixel" on any page changes with the zoom level, and the default zoom level for most pages in Fennec has not changed.

On 240-dpi screens, pages with initial-scale=1 will effectively be zoomed to 150% by both Fennec and Android WebKit. Their text will be smooth and crisp, but their bitmap images will probably not take advantage of the full screen resolution. To get sharper images on these screens, mobile web developers can create images at 150% of their final size (or 200%, to support the rumored 320-dpi iPhone) and then scale them down using HTML/CSS.

WebKit on Android also supports an additional undocumented target-densityDpi to let web developers override the CSS-to-device pixel ratio. Fennec doesn't support this property now, but if we see a compelling need for it (or if it becomes part of a documented standard) then we might implement it too.

Right now Fennec uses the same default ratio of 1.5 on all devices. (This is a hidden preference that can be changed in about:config or by an add-on.) Later we'll need to change this – as well as many other parts of Fennec's user interface – to choose the correct size automatically, depending on the screen density.

Viewport width and screen width

Many sites set their viewport to "width=320, initial-scale=1" to fit precisely onto the iPhone display in portrait mode. As mentioned above, this caused problems when Fennec 1.0 rendered these sites, especially in landscape mode. To fix this, Fennec 1.1 will expand the viewport width if necessary to fill the screen at the requested scale. This matches the behavior of Android and Mobile Safari, and is especially useful on large-screen devices like the iPad. (Allen Pike's Choosing a viewport for iPad sites has a good explanation for web developers.)

We also added support for minimum-scale, maximum-scale, and user-scalable, with defaults and limits similar to Safari's. These properties affect the initial scale and width as well as limiting zooming after the page is loaded.


Viewport metadata has proved to be a useful extension to HTML, and I think it is worth standardizing. According to the HTML5 spec, new names for the meta element should first be registered on the WHATWG wiki and then be ratified through the W3C standards process. If anyone at Mozilla or elsewhere is working on a standard specification for viewport metadata, please let me know.

Syndicated 2010-05-10 22:36:00 from Matt Brubeck

Fennec on Android: user feedback and next steps

Last month I joined Mozilla as a UI engineer on the Fennec (Mobile Firefox) project. Firefox is already available for Nokia's Maemo platform, and now a group of Mozilla programmers are porting it to Google's Android OS. This Tuesday they made an early preview build available for public feedback.

Until now, the only people working on Firefox for Android were platform developers getting the back-end code to build and run. This week was the first time most other people – including me – got to try it out. We front-end developers and designers are now starting to adapt the user interface to Android. (The preview build used the look and feel of Firefox for Maemo, designed for rather different hardware and software.)

Because we are an open source project, we like to share our work and hear your feedback even at this early stage of development. While I wasn't directly involved in the Android development effort, I spent some of my spare time this week talking to users via Twitter and our Android feedback group. Here's what I heard, in rough order of importance to users, plus some information on our future plans.1

  • Zoom and multi-touch: Pinch zoom gestures are coming! We are reviewing a patch for animated multi-touch (pinch) zooming on Qt-based devices, and testing similar code on Android. (Current Maemo devices have no multi-touch, so we use the volume buttons to zoom. That code hasn't been ported to Android, so only double-tap zoom was working in the preview build.)

    We also had some requests to fit text to the screen when zoomed in, like the Android browser. Today Brad Lassey and Ben Stover released the Easy Reading add-on that does exactly that. We might make this a built-in option in Fennec once it is fast and reliable enough.

  • Menu and Back buttons: The preview build did not handle Android's standard hardware buttons, but code is now checked in to support the back button and the menu and search buttons. We still need to do some UI work to make good use of these.

  • Size: I didn't anticipate this problem, but in retrospect it should not have been a surprise. A ten megabyte download (over 30 MB installed) is not huge for a desktop browser, but it's hefty for a mobile app – especially on Android, where apps are saved to limited onboard memory. Even worse, users reported that our Fennec build did not work with the feature in some custom Android ROMs to move apps to the SD card.

    Shrinking Fennec is possible, but not trivial. Some of the library and toolkit code in our build is probably unused and could be removed. And we could try minifying our Java­Script source, like many websites do.

    Mozilla's Android developers also hope to fix the problem with SD installation. It will be nice someday when app storage on Android is as plentiful as it is on other mobile platforms.

  • Hardware compatibility: There are a lot of different Android phones out there. Some of them won't run Fennec because they still have Android 1.5 or 1.6. We hope this will be fixed by the hardware vendors soon, since we currently rely on some Android 2.0 APIs. Other devices failed for different reasons, possibly related to insufficient RAM or incom­patible OpenGL APIs. We will need to optimize Firefox's memory footprint on Android, and test on a wider selection of devices, perhaps with help from Firefox users.

  • Keyboard problems: There were many problems with the software keyboard working intermittently or not at all, especially in landscape orienta­tion. There were also prob­lems with Shift and Alt keys on some hardware keyboards. I haven't heard any news about of these bugs, but we know we need to fix them quickly.

  • Speed: Strangely, we had some users calling Fennec slooooooow and others calling it fast as hell (and those tweets were sent just one minute apart)!

    Once a page is loaded, Fennec is pretty speedy. It's faster than the Android browser in some areas, and slower in others. But it's definitely choppy while a page is still loading or complex scripts are running. To fix this, our next major release of Fennec will include Elec­trolysis. This gives Firefox a multi-process architecture much like Google Chrome, and ensures that the browser always stays responsive.

    Electrolysis requires many changes to our code, so it may be a couple of months before it appears in usable Fennec builds. In the mean­time, Mozilla is working on many other performance improvements. This work will also speed up Firefox for desktop computers – I've been using the FF4 nightly builds, and they are already much snappier than the Firefox 3.5 I was using before.

    We've also checked in some simple changes to improve perceived speed, like better feedback when pages start loading.

  • Crashing bugs: Users were generally forgiving of crashes and other obvious bugs, to be expected at this stage of development. We will of course fix any such bugs as fast as possible.

  • Add-ons: We're just starting Fennec 1.1 beta testing, and most of our add-ons are not yet updated for version 1.1. Unfortunately, the timing means that many add-ons were not available to our first Android previewers. This should be fixed over the next few weeks.

    I believe add-ons are the biggest advantage Firefox has over other mobile browsers. For the first time on a mobile phone I can easily customize the browser to scratch my own itch. (See my first Fennec add-ons, Read Later and Show Image Title.) And there are many great add-ons from other devel­opers to choose from.

  • User interface: Most of the feedback on our UI was positive. Users told us that panning to reveal the toolbars felt natural and easy. I think Madhava and Sean have done a great job with the design. This will get even better as we take advantage of Android features like the hardware buttons, integration with other activities, voice input, and the notification bar.

  • Flash: Firefox for Maemo supports plugins like Flash, although enabling Flash does cause performance problems on some sites. (We are working on fixing that with major changes to our graphics code.) Flash is not yet included in our Android builds, but it will be supported eventually.

  • Web site compatibility: Fennec renders almost all pages the same as desktop Firefox. Users did report problems entering data on some pages, and found that most sites do not have mobile versions targeted at Firefox. One of my personal goals is to make Firefox compatible with more mobile sites, and to give web developers the tools and information they need to make their sites work great in mobile Firefox. I'll write much more about this in future articles.

We don't have a regular schedule yet for releasing new builds on Android. Once we get the code merged and automated build servers configured, we'll publish nightly builds of Firefox for Android alongside our Maemo and desktop nightlies. Later this year we will have alpha and beta versions, and hopefully a stable release. Until then, you can follow @MozMobile or Vlad (@vvuk) to hear about any new previews.

  1. Please remember I am still new to the project, and cannot speak for the whole team. This is a personal blog, not a Firefox roadmap!

Syndicated 2010-04-30 07:00:00 from Matt Brubeck

Headless Web Workers: Does the web need background apps?

At my last job, I created several web applications designed to replace built-in apps on mobile phones. While modern browsers and HTML5 made this incredibly easy in many ways, we still ended up writing native (i.e. non-web) code for most of our applications. There were a few different areas where the browser alone didn't meet our needs, but one that I found suprisingly common was background processing.

Consider the following mobile applications:

  • Calendar or clock with alarms.
  • E-book reader that syncs content from a server.
  • IM or email client that notifies the user of new messages.
  • Shopping list that pops up whenever you are near the store.

Ideally, each of these apps will perform some actions even when the user does not have it open. (Background processing is not strictly necessary for the e-reader, but it would be useful to ensure the library is up-to-date even when opened in a place with no network connection.)

You can't do this with a web app. Web Workers don't solve the problem, because they run only while the web page is open. What we need are headless web workers.1


Headless workers could use almost the same API as Web Workers. Instead of responding to messages from a web page, they would listen to events from the host system (browser or OS). These events might include time intervals, power-on/resume, changes in network connection, geographic locations, or "push" notifications from a remote server.

The event-driven architecture of JavaScript in the browser allows the host system a high level of discretion over resource consumption. There's no special code needed to suspend processes and later restore their state, because JavaScript workers are naturally inactive between events. The host can provide limits on CPU or memory usage per event, with a separate message to notify processes whose handlers were aborted. And it can limit the number of concurrent processes by choosing when to dispatch events to listeners. Some listeners could even be disabled completely at times (like if the device is busy or the battery is low), and notified later of the events they missed.

This is almost a return to the old days of cooperative multitasking. Mobile computing is definitely driving everyone towards higher-level process control in the OS, and different assumptions for applications. It's not surprising that my whole proposal resembles Android and iPhone 4.0 multitasking in several ways, since I've been doing development on Android for the last 18 months and encountering many of the same issues.

The UI

Headless workers do need some way to interact with the user. They could display standard system notifications (via Growl on the Mac, libnotify on Ubuntu, the status bar in Android, etc.) using W3C Web Notifications, which already have an experimental implementation in Chrome.

Users also needs to know which sites have background tasks installed. Headless workers could be represented by icons in a standard location (perhaps a toolbar in desktop browsers, or the home screen on a mobile device). The icons could display ambient status; clicking one would reveal a menu with options to configure or remove it.


This proposal might be hard to standardize, especially where it's tied to specific OS capabilities. For now I'm just curious: would it be useful? You can write a native app or a browser extension to solve this problem today. But would it be worthwhile to have a standard, cross-platform way to do it? Has anyone else run into problems that this approach could solve?

  1. Because all web standards should have names that sound like Harry Potter creatures.

Syndicated 2010-04-22 07:00:00 from Matt Brubeck

Read Later: a Mobile Firefox extension

Hello, Planet Mozilla! I'm Matt Brubeck, the newest member of the Mobile Firefox (Fennec) front-end team. I'm working remotely in Seattle, but you can find me in #mobile during the North American day, or follow me on Buzz/Twitter/etc.

To help myself learn Fennec and XUL, I wrote a simple extension called Read Later. Like Marco Arment's Instapaper service it stores a list of web pages so you can return to them later. Unlike Instapaper, my extension does not save pages to a remote server. Instead, it uses your mobile device's storage, so you can view saved pages offline. I use code from Arc90's Readability bookmarklet to extract the main content from the page, save it, and present it in a simple mobile-friendly layout.

One thing the extension can't do (which Instapaper and other services can) is synchronize saved pages between computers. This would be a great feature for a Mobile Firefox add-on, but writing my own sync service is a bit more work than I want to put into this little side project. A future version may use Weave to sync saved pages, as long as the size of the data is not a problem.

If you are using a recent Fennec 1.1 build, try out Read Later and let me know what you think. And if you're a developer, you can look at the source code to see how a simple Fennec extension works.

Syndicated 2010-04-18 07:00:00 from Matt Brubeck

Discovering Urbit: Functional programming from scratch

C. Guy Yarvin is a “good friend” of Mencius Moldbug, a pseudonymous blogger known for iconoclastic novella-length essays on politics and history (and occasionally computer science). Guy recently published under his own name a novel project in language and systems design. His own writing about his work is entertaining but verbose (as Moldbug's readers might expect), so I will attempt to summarize it here.

Nock, Urbit, Watt

First there is Nock, “a tool for defining higher-level languages – comparable to the lambda calculus, but meant as foundational system software rather than foundational meta­mathe­matics.” Its primitives include positive integers with equality and increment operators, cons cells with car/cdr/cadr/etc., and a macro for convenient branching. Nock uses trees of integers to represent both code and data.

Next, Guy provides the rationale for Nock. In short, he asks how a planet-wide computing infrastructure (OS, networking, and languages) would look if designed from first priniciples for robustness and interoperability. The answer he proposes is Urbit: a URI-like name­space distributed globally via content-centric networking, with a feudal structure for top-level names and cryptographic identities. Urbit is a static functional name­space: it is both referentially transparent and monotonic (a name, once bound to a value, cannot be un- or re-bound).

Why does this require a new formal logic and a new programming language? In Urbit, all data and code are distributed via the global namespace. For interoperability, the code must have a standard format. Nock's minimal spec is meant to be an un­ambiguous, unchanging, totally standardized basis for computation in Urbit. Above it will be Watt, a self-hosting language that compiles to Nock. Urbit itself will be implemented in Watt, so Nock and Watt are designed to treat data as code using metacircular evaluation.

The code

A prototype implementation of Watt is on GitHub. It is not yet self-hosting; the current compiler is written in C. Watt is a functional language with static types called “molds” and a mechanism for explicit lazy evaluation. (I was suprised to find I had accidentally created an in­com­patible lazy dialect of Nock – despite its goal of unambiguous semantics – just by implementing it in Haskell.)

The code is not fully documented, but the repository contains draft specs for both Watt and Urbit. Beware: the syntax and terminology are a bit unconventional. Guy has offered a few exercises to help get started with Nock and Watt:

The Nock challenge:
Write a decrement operator in Nock, and an interpreter that can evaluate it.
Basic Watt:
Write an integer square root function in Watt.
Advanced Watt:
How would you write a function that tests whether molds A and B are orthogonal (no noun is in both A and B)? Or compatible (any noun in A is also in B)? Are these functions NP-complete? If so, how might one work around this in practice?

If you want to learn more, start with these problems. You can email your solutions to Guy.

Will it work?

I find Urbit intellectually appealing; it is a simple and clean architecture that could potentially replace a lot of complex system software. But can we get there from here?

Guy imagines Urbit as the product of an ages-old Martian civilization:

Since Earth code is fifty years old, and Martian code is fifty million years old, Martian code has been evolving into a big ball of mud for a million times longer than Earth software. (And two million times longer than Windows.) …

Therefore, at some point in Martian history, some abject fsck of a Martian code-monkey must have said: fsck this entire fscking ball of mud. For lo, its defects cannot be summarized; for they exceed the global supply of bullet points; for numerous as the fishes in the sea, like the fishes in the sea they fsck, making more little fscking fishes. For lo, it is fscked, and a big ball of mud. And there is only one thing to do with it: obliterate the trunk, fire the developers, and hire a whole new fscking army of Martian code-monkeys to rewrite the entire fscking thing.

… This is the crucial inference we can draw about Mars: since the Martians had 50 million years to try, in the end they must have succeeded. The result: Martian code, as we know it today. Not enormous and horrible – tiny and diamond-perfect. Moreover, because it is tiny and diamond-perfect, it is perfectly stable and never changes or decays. It neither is a big ball of mud, nor tends to become one. It has achieved its final, permanent and excellent state.

Do Earthlings have the will to throw out the whole ball of mud and start from scratch? I doubt it. We can build Urbit but no one will come, unless it solves some problem radically better than current software. Moldbug thinks feudalism will produce better online reputation, but feudal reputation does not require feudal identity; it is not that much harder to build Moldbug's reputation system on Earth than on Mars. I still have not figured out the killer app that will get early adopters to switch to Urbit.

Syndicated 2010-03-12 08:00:00 from Matt Brubeck

The network is the human being

Nathanael Boehm wrote a nice essay last month called The Future of Employment?, about a disconnect between workers' and employers' views of social networks. (This post is based partly on my comment in the ensuing Hacker News thread.) Boehm wrote:

When I need help with a challenge at work or need to run some ideas past people I don’t turn to my co-workers, I look to my network of colleagues beyond the walls of my workplace. Whilst my co-workers might be competent at their job they can’t hope to compete with the hundreds of people I have access to through my social networks...

The late Sun Microsystems taught us that the network is the computer. It's true: we still use non-networked computers for specialized tasks, but nobody wants one on their desk – it's just so useless compared to one that talks to the entire world. Boehm could have titled his essay The Network is the Employee. There are still tasks that people do in isolation, but the ability to contact a network of peers and experts makes the difference in my job, and many others.

Alone together

The lone computer programmer in a small business has thousands of colleagues on Stack Overflow, Reddit, and so on. It's a chaotic and messy way to find answers, but it's better than the days when your only choice was to call tech support – or smack the box with your fist, whichever seemed more useful. I can't begin to list all the problems I've solved and things I've learned by Googling for others with relevant experiences, and getting help from a different expert for every problem.

Decades before the web, computer geeks had virtual communities for on mailing lists, Usenet, and IRC. Now any job in the world has an online forum. Even the night clerk at the gas station has Not Always Right.

Teaching has long been a solitary profession. Despite working in a crowded classroom, teachers are isolated; they rarely have colleagues observing or participating directly in their work. This has such an impact that teacher education sometimes includes training in meditation or reflection, to compensate for lack of external feedback. So I'm really curious what happens when teachers start to work together remotely the way programmers do.

You will be assimilated

Boehm's essay reminded me of a vague sci-fi-like idea I've been kicking around: the first group minds will evolve from the intersection of Mechanical Turk, virtual assistants, social networking, and augmented reality.

Starting around the 1990s, it was possible to instantly "know" any fact that was published online. Since then, we've increased the amount of content online, our tools for searching it, and ways of connecting to the network. Today we have instant access to almost any published knowledge, anywhere.

The number of people on the net has grown too, and the number of ways to find and talk to them. Most of us can contact dozens of friends at any given moment, plus friends-of-friends, co-workers, fellow members of communites like Hacker News or MetaFilter, and also complete strangers. Along with raw facts, we now have access to vast amounts of human judgement, experience, and skill.

One result of this is the "virtual assistant," who provides a service that was once available only to high-powered executives. The new personal assistant can work remotely (often overseas), spread costs by serving many masters, and leverage the internet superpowers listed above. Today their services are targeted at small business owners and the Tim Ferriss crowd, but I'm sure someone soon will start marketing virtual personal assistance to all sorts of other creative workers, teachers, even stay-at-home parents.

So, how long before I can simply touch a button to let a remote assistant see what I'm seeing in real-time and help me make transportation plans, translate foreign signs and speech, look up emails related to whatever I'm doing or thinking, or even advise me on what to say? Some of these queries will go to my circle of friends, others to the general public, and some to a personal assistant who is paid well to keep up with my specific needs. And that assistant of course will sub-contract out portions of each job as needed to computer programs, legions of cheap anonymous Turkers, or to his or her own network of assistants. At that point, I'm augmenting my own perception, memory, and judgement with a whole network of brains that I carry around ready to engage with any situation I meet.

If nothing else, I hope someone writes a good sci-fi thriller story in which a rogue virtual assistant subtly manipulates the actions of unknowing clients, leading them to some unseen end.

Syndicated 2010-03-01 08:00:00 from Matt Brubeck

Finding SI unit domain names with Node.js

I'm working on some ideas for finance or news software that deliberately updates infrequently, so it doesn't reward me for checking or reloading it constantly. I came up with the name "microhertz" to describe the idea. (1 microhertz ≈ once every eleven and a half days.)

As usual when I think of a project name, I did some DNS searches. Unfortunately "microhertz.com" is not available (but "microhertz.org" is). Then I went off on a tangent and got curious about which other SI units are available as domain names.

This was the perfect opportunity to try node.js so I could use its asynchronous DNS library to run dozens of lookups in parallel. I grabbed a list of units and prefixes from NIST and wrote the following script:

  var dns = require("dns"), sys = require('sys');

var prefixes = ["yotta", "zetta", "exa", "peta", "tera", "giga", "mega",
  "kilo", "hecto", "deka", "deci", "centi", "milli", "micro", "nano",
  "pico", "femto", "atto", "zepto", "yocto"];

var units = ["meter", "gram", "second", "ampere", "kelvin", "mole",
  "candela", "radian", "steradian", "hertz", "newton", "pascal", "joule",
  "watt", "colomb", "volt", "farad", "ohm", "siemens", "weber", "henry",
  "lumen", "lux", "becquerel", "gray", "sievert", "katal"];

for (var i=0; i<prefixes.length; i++) {
  for (var j=0; j<units.length; j++) {
    checkAvailable(prefixes[i] + units[j] + ".com", sys.puts);

function checkAvailable(name, callback) {
  var resolution = dns.resolve4(name);
  resolution.addErrback(function(e) {
    if (e.errno == dns.NXDOMAIN) callback(name);

Out of 540 possible .com names, I found 376 that are available (and 10 more that produced temporary DNS errors, which I haven't investigated). Here are a few interesting ones, with some commentary:

  • exasecond.com – 32 billion years
  • petasecond.com – 32 million years
  • petawatt.com – can be produced for femtoseconds by powerful lasers
  • terapascal.com
  • gigakelvin.com – possible temperature of picosecond flashes in sonoluminescence
  • giganewton.com – 225 million pounds force
  • gigafarad.com
  • kilosecond.com – 16 minutes 40 seconds
  • kilokelvin.com – 1340 degrees Fahrenheit
  • centiohm.com
  • millifarad.com
  • microkelvin.com
  • picohertz.com – once every 31,689 years
  • picojoule.com
  • femtogram.com – mass of a single virus
  • yoctogram.com – a hydrogen atom weighs 1.66 yoctograms
  • zeptomole.com – 602 molecules

To get the complete list, just copy the script above to a file, and run it like this: node listnames.js

Along the way I discovered that the API documentation for Node's dns module was out-of-date. This is fixed in my GitHub fork, and I've sent a pull request to the author Ryan Dahl.

Syndicated 2010-01-13 08:00:00 from Matt Brubeck

Weekend hack: outline grep

I keep almost all of my notes and to-do lists in plain text files, so I can edit and search them with Vim, grep, and other standard Unix tools. I often indent lines in these files to create a simple outline structure, and use the autoindent and foldmethod=indent options to make Vim into a simple outliner.

To get useful output when searching through these outline-structured files, I wrote a simple grep replacement. Given a text file with a Python-style indentation structure, ogrep searches the file for a regular expression. It prints matching lines, with their "parent" lines as context. For example, if input.txt looks like this:

  New Year's Day!
    No work today.
    Visit with family.
  Grocery store and library.
  Stay home.
  Back to work.
    Remember to set an alarm.

then ogrep work input.txt will produce the following output:

  New Year's Day!
    No work today.
  Back to work...

You can download ogrep from the outline-grep repository on GitHub, or just read the literate Haskell file. The code is almost trivial (40 lines of code, plus imports and comments); I'm publishing it just in case anyone else has a use for it, and because some of my friends were curious about how I'm using Haskell. I've now written a few "real-world" Haskell programs (compleat was the first). I'm finding Haskell very well suited to such programs, though this particular one would be equally easy in a language like Perl, Python, or Ruby.

This is a one-off tool to fill a gap in my workflow; there are no configuration options or useful error messages. It would be fairly easy to extend it, though. For example, it might be handy to have an option to include children (as well as parents) of matching lines. I recently realized that ogrep often works for searching through source code too, which might generate some more unexpected use cases.

Syndicated 2010-01-12 08:00:00 from Matt Brubeck

Android 2.0 ships with V8 JavaScript engine

Google has not yet released most of the Android 2.0 source code, but they did publish source for a very small number of components, including a WebKit snapshot. I was very excited to see that the snapshot includes Google's V8 virtual machine! (Previous Android releases used Safari's JavaScriptCore/"SquirrelFish Extreme" VM.) But without the rest of the source tree, there was no way to build and run this on a real Android phone. The SDK includes a binary image that runs only in the qemu-based emulator.

Today I got to try out a Motorola Droid. Here is how its browser compares to Android 1.6 on my HTC Dream (Android Dev Phone / T-Mobile G1) in the V8 Benchmark Suite (version 5):

Test Dream Droid Change
Richards 13.5 15.6 16%
DeltaBlue 5.23 12.9 147%
Crypto 13.2 10.9 -17%
RayTrace 10.9 80.1 635%
EarleyBoyer 23.5 74.7 218%
RegExp did not complete 16.5
Splay did not complete did not complete

Some tests (Richards, Crypto) see little or no improvement, while others (DeltaBlue, RayTrace, EarleyBoyer) are dramatically faster. Just for comparison, let's run the same benchmark on Safari 4 (JavaScriptCore) and a Chromium 4 nightly build (V8) on a Mac Pro:

Test Safari Chromium Change
Richards 4103 4640 13%
DeltaBlue 3171 4418 39%
Crypto 3331 3643 9%
RayTrace 3509 6662 90%
EarleyBoyer 4737 7643 61%
RegExp 1268 1187 -6%
Splay 1198 7290 509%

The precise ratios are different, but the same tests that showed the most improvement from Android 1.6 to 2.0 also show the most improvement from Safari to Chrome. Based on this plus the source code snapshot, I'm pretty sure that Android 2.0 is indeed using V8.

This is exciting news. It makes Droid the first shipping product I know that uses V8 on an ARM processor, although V8 has included an ARM JIT compiler for some time now. For mobile web developers (like me), it means we're one step closer to having desktop-quality rich web applications on low-power handheld devices.

Final thought: Although the Motorola Droid is still 100 times slower than Chromium on a Mac Pro, it's actually faster at some benchmarks than IE8 on a low-end Windows machine, or Firefox 2 on hardware from just a few years ago.

Syndicated 2009-11-06 08:00:00 from Matt Brubeck

113 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!