<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Bluish Coder: mozilla</title>
 <link href="http://bluishcoder.co.nz/tag/mozilla/atom.xml" rel="self"/>
 <link href="http://bluishcoder.co.nz/"/>
 <updated>2012-04-11T11:40:28+12:00</updated>
 <id>http://bluishcoder.co.nz/</id>
 <author>
   <name>Chris Double</name>
   <email>chris.double@double.co.nz</email>
 </author>

 
 <entry>
   <title>Travelling to Pitcairn Island</title>
   <link href="http://bluishcoder.co.nz/2012/04/11/travelling-to-pitcairn-island.html"/>
   <updated>2012-04-11T12:00:00+12:00</updated>
   <id>http://bluishcoder.co.nz/2012/04/11/travelling-to-pitcairn-island</id>
   <content type="html">&lt;a href='http://www.flickr.com/photos/wheatstrong/211069189/' title='Pitcairn Island Approach by wheatstrong, on Flickr' style='float:right'&gt;&lt;img width='240' height='180' alt='Pitcairn Island Approach' src='http://farm1.staticflickr.com/98/211069189_6616901143_m.jpg' /&gt;&lt;/a&gt;
&lt;p&gt;From Sunday 15th April through to 29th April I&amp;#8217;ll be mostly offline as I take some leave to visit &lt;a href='http://en.wikipedia.org/wiki/Pitcairn_Islands'&gt;Pitcairn Island&lt;/a&gt;, one of the remotest inhabited islands with a population of about 50 people.&lt;/p&gt;

&lt;p&gt;My first stop is flying from New Zealand to &lt;a href='http://en.wikipedia.org/wiki/Tahiti'&gt;Tahiti&lt;/a&gt; where I spend a couple of days, then I fly to &lt;a href='http://en.wikipedia.org/wiki/Mangareva'&gt;Mangareva&lt;/a&gt; on the 17th to board the &lt;a href='http://www.xplore-expeditions.com/1-15991-The-yacht.php'&gt;Xplore sailing yacht&lt;/a&gt; for the approximately two day trip to Pitcairn. I spend a couple of days on the island itself, then return on the Xplore back to Mangareva, followed by flying back to Tahiti for a few more days.&lt;/p&gt;

&lt;p&gt;The trip was easy to organise through &lt;a href='http://pitcairntravel.pn/'&gt;Pitcairn Travel&lt;/a&gt;. Longer trips are available than the one I&amp;#8217;m taking but none are scheduled at this time of year. Assuming this trip goes well I hope to go for longer, and maybe to the other Islands in the Pitcairn group, in the future.&lt;/p&gt;

&lt;p&gt;Why Pitcairn? Pitcairn is the island that was settled by the &lt;a href='http://en.wikipedia.org/wiki/Mutiny_on_the_Bounty'&gt;Bounty mutineers&lt;/a&gt;. My grandmother was born on the island and through her I&amp;#8217;m a descendant of three mutineers (&lt;a href='http://en.wikipedia.org/wiki/Fletcher_Christian'&gt;Fletcher Christian&lt;/a&gt;, &lt;a href='http://en.wikipedia.org/wiki/Descendants_of_the_Bounty_Mutineers'&gt;John Mills&lt;/a&gt;, &lt;a href='http://en.wikipedia.org/wiki/Ned_Young'&gt;Ned Young&lt;/a&gt; and their Tahitian wives are my sixth great grandparents). I&amp;#8217;m looking forward to visiting the &lt;a href='http://www.flickr.com/photos/suraark/5860727435/'&gt;Bounty monument&lt;/a&gt; in Tahiti and the &lt;a href='http://www.panoramio.com/photo/25634071'&gt;Bounty Plaque&lt;/a&gt; on Pitcairn.&lt;/p&gt;

&lt;p&gt;Electricity is available on Pitcairn for about 10 hours per day which limits laptop/gadget usage time. Luckily I plan to spend as much time as possible exploring the island, weather permitting.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ll have internet access while in Tahiti but I suspect access to be a bit hit or miss on Pitcairn. In the past internet access was available by sharing satellite internet that was provided by a United States Geologic Survey station on the island. A &lt;a href='http://bit.ly/IyCi2g'&gt;description of the setup is available here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Later the Pitcairn Island Government arranged &lt;a href='http://cbc.am/pitcairn.htm'&gt;their own satellite internet capability&lt;/a&gt;. Recently &lt;a href='http://www.rnzi.com/pages/news.php?op=read&amp;amp;id=66624'&gt;speeds have been improved&lt;/a&gt; to 512 kilobits per second - shared amongst the approximately 50 people on the island. Costs for residents of the island are around $40 per 400MB of usage from what I hear. I would imagine that if someone wanted to regularly access the internet there for work they&amp;#8217;d require a dedicated satellite internet connection just for that (Something like &lt;a href='http://www.pactelint.com/products/satellite-internet-products.php?RICS-Ku-Band-1'&gt;Pactel&amp;#8217;s VSAT internet&lt;/a&gt; maybe). I&amp;#8217;ll be sure to do a later post on what using the modern web is like in this part of the world.&lt;/p&gt;

&lt;p&gt;Anyone in the area of Tahiti, Mangareva or Pitcairn, let me know, I&amp;#8217;d be keen to meet.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Building and Running Boot To Gecko on the Nexus S</title>
   <link href="http://bluishcoder.co.nz/2012/03/20/building-and-running-b2g-on-nexus-s.html"/>
   <updated>2012-03-20T12:00:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2012/03/20/building-and-running-b2g-on-nexus-s</id>
   <content type="html">&lt;p&gt;Update 2012-03-29 - The Nexus S port has moved to an ICS base system and the existing Gingerbread base no longer works correctly. I&amp;#8217;ve adjusted the instructions below to build the ICS based system. It just involves using &amp;#8216;config-nexuss-ics&amp;#8217; instead of &amp;#8216;config-nexus&amp;#8217;.&lt;/p&gt;

&lt;p&gt;Last year Mozilla &lt;a href='http://hacks.mozilla.org/2011/07/announcing-boot-to-gecko-b2g-booting-to-the-web/'&gt;announced the Boot to Gecko&lt;/a&gt; project - a mobile OS based on web technologies. Recently it was &lt;a href='http://tech2.in.com/news/general/mwc-2012-mozilla-qualcomm-and-telefonica-join-b2g-project/285212'&gt;demoed at MWC 2012&lt;/a&gt;. Work is being done to improve video playback on B2G using hardware codecs in &lt;a href='https://bugzilla.mozilla.org/show_bug.cgi?id=714408'&gt;bug 714408&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve built and run B2G on the emulator before but I wanted to try it out on real hardware to test the video support and play around with the OS. I upgraded my main phone to a &lt;a href='http://www.samsung.com/nz/galaxynote'&gt;Galaxy Note&lt;/a&gt; recently leaving a my Nexus S spare for trying different ROMS on it. Support for the Nexus S has started becoming available for B2G (previously the main consumer phone for testing was the Galaxy S II) so I gave it a try. The Nexus S I have is the GSM (non-4G) version. The steps to get the source code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git clone git://github.com/andreasgal/B2G
$ cd B2G
$ make sync&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This takes a long time (on New Zealand networks anyway&amp;#8230;). Multiple gigabytes of git submodules are cloned.&lt;/p&gt;

&lt;p&gt;You&amp;#8217;ll want to make sure you have a build environment set up, as per this &lt;a href='https://developer.mozilla.org/en/Mozilla/Boot_to_Gecko/Setting_Up_Boot_to_Gecko_Build_Environment'&gt;MDN article&lt;/a&gt; so that &amp;#8216;adb&amp;#8217; and other android tools work. Once done, configure for a Nexus S build:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ make config-nexuss-ics&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will download binaries for the phone and get you to confirm a bunch of licenses. To build:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ make gonk
...
$ make
...&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &amp;#8216;gonk&amp;#8217; make invocation builds the underlying android layer. The following &amp;#8216;make&amp;#8217; builds gecko and related parts of B2G. Once those are completed you can flash the phone with the result. &lt;em&gt;Note, you do the following at your own risk! You&amp;#8217;re flashing your phone, overwriting everything, with experimental, possibly buggy software&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To flash a Nexus S you need to have unlocked the bootloader. If you haven&amp;#8217;t done this yet, boot into the bootloader (hold the up volume key down while pressing the power button) and run:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ make unlock-bootloader&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This runs &amp;#8220;fastboot oem unlock&amp;#8221; which is the command to unlock the Nexus S bootloader. You&amp;#8217;ll need to agree to it on the phone. I also installed the CyanogenMod recovery firmware but this is optional. Instructions to do that are &lt;a href='http://wiki.cyanogenmod.com/wiki/Nexus_S:_Full_Update_Guide'&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To flash, boot the phone into recovery mode (Hold down the up volume key while pressing power, from the menu that appears choose &amp;#8216;Recovery&amp;#8217;), plugin in the USB cable to your PC. Run:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ make flash-only&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#8216;flash-only&amp;#8217; will flash your B2G build onto the phone. You&amp;#8217;ll lose everything on the phone, sorry.&lt;/p&gt;

&lt;p&gt;If your Nexus S was running a 2.3 based Android this should just work. If it was running ICS (as mine was) then you might get an error about unsupported baseband and/or bootloader versions. If you get this, I fixed it by editing &amp;#8216;glue/gonk/device/samsung/crespo/board-info.txt&amp;#8217; to add the versions that my bootloader and baseband had. My file looked like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require board=herring
require version-bootloader=I9020XXJK1|I9020XXKA3|I9020XXKL1
require version-baseband=I9020XXJK8|I9020XXKB1|...|I9020UCKE1|I9020XXKI1&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note the addition of &amp;#8216;I9020XXKL1&amp;#8217; and &amp;#8216;I9020XXKI1&amp;#8217; to the bootloader and baseband lines respectively. After editing I redid &amp;#8220;make gonk&amp;#8221;, &amp;#8220;make&amp;#8221; and &amp;#8220;make flash-only&amp;#8221;.&lt;/p&gt;

&lt;p&gt;After &amp;#8216;flash-only&amp;#8217; your phone will reboot. If it boots into an error box saying &amp;#8220;no homescreen found&amp;#8221; then do the following while the USB cable is connected and that error is showing:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ make install-gaia
$ adb reboot&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will install the user files and reboot the phone. B2G should now be running on the device. Enjoy! I&amp;#8217;ve found calls, text messages, Wifi and Web Browsing works.&lt;/p&gt;

&lt;p&gt;&lt;img alt='Nexus S running B2G' src='/images/nexus_s_b2g_320.jpg' /&gt;&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Performing Compatible Updates of Mozilla Central Git Forks</title>
   <link href="http://bluishcoder.co.nz/2011/10/28/performing-compatible-updates-of-mozilla-central-git-forks.html"/>
   <updated>2011-10-28T16:00:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2011/10/28/performing-compatible-updates-of-mozilla-central-git-forks</id>
   <content type="html">&lt;p&gt;Earlier this year I posted about &lt;a href='/2011/02/10/git-conversion-of-mozilla-central.html'&gt;how I created my git mirror&lt;/a&gt; of the mozilla-central mercurial repository. I&amp;#8217;ve been keeping a &lt;a href='https://github.com/doublec/mozilla-central'&gt;fork on github&lt;/a&gt; updated regularly since then that a number of people have started using.&lt;/p&gt;

&lt;p&gt;Users of my mirror have wanted to be able to keep up to date with the mercurial mozilla-central repository themselves, or add updates from other branches of the Mozilla source. It takes a large amount of time to start a conversion from scratch but it&amp;#8217;s possible to start from the existing git mirror, perform the incremental updates from mercurial yourself, and still stay compatible with the incremental updates I push to my github mirror.&lt;/p&gt;

&lt;p&gt;&lt;a href='http://hg-git.github.com/'&gt;hg-git&lt;/a&gt; uses a &lt;code&gt;git-mapfile&lt;/code&gt; in the &lt;code&gt;.hg&lt;/code&gt; directory of the mercurial clone to keep track of the mapping between mercurial and git commits. By using the same &lt;code&gt;git-mapfile&lt;/code&gt; that I use for my mirror you can start your own incremental update from the latest data in the &lt;code&gt;git-mapfile&lt;/code&gt; instead of from the beginning. I keep an up-to-date &lt;code&gt;git-mapfile&lt;/code&gt; in &lt;a href='http://www.bluishcoder.co.nz/git-mapfile.bz2'&gt;git-mapfile.bz2&lt;/a&gt;. It&amp;#8217;s compressed with &lt;code&gt;bzip2&lt;/code&gt; as the uncompressed version is quite large.&lt;/p&gt;

&lt;p&gt;The steps to start your own update process are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the &lt;a href='https://hg.mozilla.org/mozilla-central'&gt;mercurial mozilla-central repository&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;Clone my &lt;a href='https://github.com/doublec/mozilla-central'&gt;git mirror&lt;/a&gt; as a bare repository in &lt;code&gt;.hg/git&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;Place the &lt;code&gt;git-mapfile&lt;/code&gt; in &lt;code&gt;.hg&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;Do an &lt;code&gt;hg bookmark -f -r default master&lt;/code&gt; to mark the commit to convert to&lt;/li&gt;

&lt;li&gt;Perform &lt;code&gt;hg gexport&lt;/code&gt; to update &lt;code&gt;.hg/git&lt;/code&gt; with recent mercurial commits&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;code&gt;.hg/git&lt;/code&gt; directory should now be up-to-date with respect to the mercurial repository. And the additional git commits will have the same SHA id as any commits I push into my mirror when I perform my own update.&lt;/p&gt;

&lt;p&gt;The steps to do an incremental update are the normal:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pull from the mercurial mozilla-central repository&lt;/li&gt;

&lt;li&gt;Run &lt;code&gt;hg bookmark -f -r default master&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;Run &lt;code&gt;hg gexport&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;Push or pull to/from &lt;code&gt;.hg/git&lt;/code&gt; as needed&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As a working example, the following shell commands on a Linux system should set up your own repository ready for incremental updating:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ hg clone https://hg.mozilla.org/mozilla-central
$ cd mozilla-central/.hg
$ git clone --bare git://github.com/doublec/mozilla-central.git git
$ wget http://www.bluishcoder.co.nz/git-mapfile.bz2
$ bunzip2 git-mapfile.bz2
$ cd ..
$ hg bookmark -f -r default master
$ hg gexport
$ cd .hg/git
$ git push --all ~/some/other/repo.git&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Incremental updates just repeat the last few commands above:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ hg pull -u
$ hg bookmark -f -r default master
$ hg gexport
$ cd .hg/git
$ git push --all ~/some/other/repo.git&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note that I use &lt;code&gt;hg gexport&lt;/code&gt; and push from the &lt;code&gt;.hg/git&lt;/code&gt; repository using the &lt;code&gt;git&lt;/code&gt; command instead of doing an &lt;code&gt;hg push&lt;/code&gt; and relying on &lt;code&gt;hg-git&lt;/code&gt; to do the conversion and push. In my &lt;a href='http://www.bluishcoder.co.nz/2011/02/10/git-conversion-of-mozilla-central.html'&gt;original article&lt;/a&gt; I did the latter. The &lt;code&gt;hg-git push&lt;/code&gt; method uses slower python based routines to do the push which can take a long time and large amounts of memory on big repositories like mozilla-central. By splitting this up into &lt;code&gt;gexport&lt;/code&gt; and using the native &lt;code&gt;git&lt;/code&gt; command I save a lot of time and memory.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Temporal Media Fragment Support in Firefox</title>
   <link href="http://bluishcoder.co.nz/2011/08/08/temporal-media-fragment-support-in-firefox.html"/>
   <updated>2011-08-08T12:00:00+12:00</updated>
   <id>http://bluishcoder.co.nz/2011/08/08/temporal-media-fragment-support-in-firefox</id>
   <content type="html">&lt;p&gt;The W3C has a &lt;a href='http://www.w3.org/2008/WebVideo/Fragments/'&gt;Media Fragments Working Group&lt;/a&gt; whose &lt;a href='http://www.w3.org/2008/01/media-fragments-wg.html'&gt;mission&lt;/a&gt; is to specify temporal and media fragments in the Web using URI&amp;#8217;s. The &lt;a href='http://www.w3.org/TR/media-frags'&gt;draft specification&lt;/a&gt; goes through in detail how these fragments work. I recently became a member of the working group and I&amp;#8217;ve been working on adding support for the &lt;a href='http://www.w3.org/TR/media-frags/#naming-time'&gt;temporal dimension portion&lt;/a&gt; of the specification to Firefox.&lt;/p&gt;

&lt;p&gt;In the most basic form you can specify a start time and an end time in the fragment part of a URI in an HTML video or audio element. For example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;video src=&amp;#39;/mediafrag/AudioAPI.webm#t=50,100&amp;#39;&amp;gt;&amp;lt;/video&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &amp;#8216;#t&amp;#8217; portion of the URI identifies the fragment as being a temporal media fragment. In this example &amp;#8216;50,100&amp;#8217; means start the video at a current time of 50 seconds, and stop playing at 100 seconds. There are various other formats for the temporal media fragment &lt;a href='http://www.w3.org/TR/media-frags/#naming-time'&gt;defined in the specification&lt;/a&gt;. Examples can be seen in the &lt;a href='http://www.w3.org/2008/WebVideo/Fragments/TC/ua-test-cases.html'&gt;UA Test Cases&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Development of this feature is being done in &lt;a href='https://bugzilla.mozilla.org/show_bug.cgi?id=648595'&gt;bug 648595&lt;/a&gt;. I&amp;#8217;ve done test builds of the first iteration of the patch and they are available at my &lt;a href='http://www.bluishcoder.co.nz/mediafrag/'&gt;Firefox media fragment test builds page&lt;/a&gt;. The page has builds, an example, and a list of limitations which are currently:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Temporal syntax only. This means no spatial or track dimensions.&lt;/li&gt;

&lt;li&gt;NPT time support only. No SMPTE time codes or Wall-clock time codes.&lt;/li&gt;

&lt;li&gt;When changing the media fragment portion of a URL the media is not immediately updated. You need to refresh the page to see the change. This is most noticeable when directly navigating to the video and adding or changing a fragment.&lt;/li&gt;

&lt;li&gt;The user interface for identifying the fragment in the standard controls is ugly and needs polish.&lt;/li&gt;

&lt;li&gt;The HTML standard includes an &amp;#8216;initialTime&amp;#8217; attribute for obtaining the start time. There is no way to obtain an end time so I&amp;#8217;ve exposed a &amp;#8216;mozFragmentEnd&amp;#8217; attribute on the video DOM object.&lt;/li&gt;
&lt;/ul&gt;</content>
 </entry>
 
 <entry>
   <title>WDCNZ HTML Media Presentation</title>
   <link href="http://bluishcoder.co.nz/2011/08/08/wdcnz-html-media-presentation.html"/>
   <updated>2011-08-08T09:30:00+12:00</updated>
   <id>http://bluishcoder.co.nz/2011/08/08/wdcnz-html-media-presentation</id>
   <content type="html">&lt;p&gt;Last month I went down to Wellington to give a joint talk at the &lt;a href='http://wdcnz.com/'&gt;WDCNZ&lt;/a&gt; conference. The topic was &amp;#8220;HTML Media: Where we are and where we need to go&amp;#8221;. The talk was shared between &lt;a href='http://blogs.msdn.com/b/nigel'&gt;Nigel Parker&lt;/a&gt;, Mobile and Developer Evangelist for Microsoft, and myself. The conference was excellent with some great speakers and talks.&lt;/p&gt;

&lt;p&gt;Nigel and I covered using HTML video and audio elements and how they can be used today across multiple browsers and mobile devices. We also covered upcoming API&amp;#8217;s and directions in the web media area. Demo&amp;#8217;s were shown on Microsoft Internet Explorer 9, Windows Phone 7 (running the Mango update which has a browser that supports HTML media) and Firefox. Nigel has slides and a summary &lt;a href='http://blogs.msdn.com/b/nigel/archive/2011/07/18/wdcnz-html-media-where-we-are-amp-where-we-need-to-go.aspx'&gt;in his blog post about the talk&lt;/a&gt;. I think it took a bit for attendees to get over the shock over a Mozilla and Microsoft representative sharing the stage and working together! Nigel&amp;#8217;s post explains how this came about.&lt;/p&gt;

&lt;p&gt;I spoke to a few Kiwi developers afterwards about using HTML video and there was a fair bit of interest in using it. The main obstacles seemed to be people unsure what codec to use and wanting support for adaptive streaming. The first is an education issue, getting people aware of what codecs to support for maximum coverage across browsers and how to encode to those formats. With regards to adaptive streaming there has been discussion between interested parties in various mailing lists and groups - it&amp;#8217;s definitely something that is wanted.&lt;/p&gt;

&lt;p&gt;At the time of the talk Nigel and I weren&amp;#8217;t able to find any existing New Zealand based sites that use HTML video. Hopefully this will change in the future and Microsoft New Zealand are leading by example by &lt;a href='http://www.microsoft.com/nz/rwc2011/'&gt;using HTML video&lt;/a&gt; on their own site.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>My Git Workflow for Mozilla Development</title>
   <link href="http://bluishcoder.co.nz/2011/04/16/my-git-workflow-for-mozilla-development.html"/>
   <updated>2011-04-16T17:00:00+12:00</updated>
   <id>http://bluishcoder.co.nz/2011/04/16/my-git-workflow-for-mozilla-development</id>
   <content type="html">&lt;p&gt;Since my post on &lt;a href='/2011/02/10/git-conversion-of-mozilla-central.html'&gt;converting mozilla-central to git&lt;/a&gt; I&amp;#8217;ve had a few requests about what my git workflow is for Mozilla Development.&lt;/p&gt;

&lt;p&gt;When working on bugs I&amp;#8217;ll create a git branch for development. The workflow in this branch looks like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git fetch origin
git checkout -b bug/123456 origin/master
...make changes...
git commit
...make more changes...
git commit&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Occasionally I&amp;#8217;ll want to merge with the latest code from mozilla-central. I do this by rebasing my changes on top of the latest trunk code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git fetch origin
git rebase origin/master&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I&amp;#8217;ll often have multiple temporary branches as I work on different ideas during the fix. I find being able to diff between the branches, cherry pick patches, etc useful.&lt;/p&gt;

&lt;p&gt;When I&amp;#8217;ve finished with the fix and want to generate a patch for review I rebase on top of trunk and squash all my commits down into one patch. I do this use git&amp;#8217;s interactive rebase:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git fetch origin
git rebase -i origin/master
...squash commits into one commit and set commit message to my checkin commit message...
git hgp &amp;gt;~/mypatch.patch&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The last command, &lt;code&gt;git hgp&lt;/code&gt;, uses an alias I got from &lt;a href='http://blog.mozilla.com/respindola/2011/04/14/producing-patchs-for-hg-with-git/'&gt;Rafael Espindola&amp;#8217;s Blog&lt;/a&gt;. You can install this alias by adding the following to your &lt;code&gt;~/.gitconfig&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[alias]
hgp = show --format=\&amp;quot;From: %an &amp;lt;%ae&amp;gt;%n%s%n%b\&amp;quot; -U8&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The adds an &amp;#8216;hgp&amp;#8217; git command that does the same as &lt;code&gt;git show&lt;/code&gt; but includes a header for the committers name. This allows an &lt;code&gt;hg import&lt;/code&gt; of the patch to include the correct patch authors details which is useful if you use the &lt;code&gt;checkin-needed&lt;/code&gt; keyword for others to commit the patch.&lt;/p&gt;

&lt;p&gt;I attach the patch file to the bug for review. If I get review comments I then go back to the git branch and make the necessary changes. Regenerating the patch involves repeating the steps above.&lt;/p&gt;

&lt;p&gt;When the patch needs to be committed to mozilla-central it can be imported and pushed directly using mercurial:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;hg clone https://hg.mozilla.org/mozilla-central
cd mozilla-central
hg import ~/mypatch.patch
hg push&lt;/code&gt;&lt;/pre&gt;</content>
 </entry>
 
 <entry>
   <title>A Quick Look at the Rust Programming Language</title>
   <link href="http://bluishcoder.co.nz/2011/03/31/a-quick-look-at-the-rust-programming-language.html"/>
   <updated>2011-03-31T20:00:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2011/03/31/a-quick-look-at-the-rust-programming-language</id>
   <content type="html">&lt;p&gt;The &lt;a href='https://github.com/graydon/rust'&gt;Rust Programming Language&lt;/a&gt; is a systems programming language being developed by Mozilla. It was announced last year and has seen quite a bit of development since then.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve only been lightly following the development over the past year but recently decided to spend a bit more time looking at it. The following is a look at the language and implementation from someone who isn&amp;#8217;t heavily involved in the development so don&amp;#8217;t take anything I write as gospel. Hopefully I don&amp;#8217;t get too many things wrong.&lt;/p&gt;

&lt;p&gt;The &lt;a href='https://github.com/graydon/rust/wiki/Language-FAQ'&gt;Rust Language FAQ&lt;/a&gt; lists the following summary of features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Memory safe. No null pointers, wild pointers, etc. Automatic storage management.&lt;/li&gt;

&lt;li&gt;Mutability control. Immutable by default. No shared mutable state across tasks.&lt;/li&gt;

&lt;li&gt;Dynamic execution safety: task failure / unwinding, trapping, logging. RAII / dtors.&lt;/li&gt;

&lt;li&gt;Typestate system: ability to define complex invariants that hold over data structures.&lt;/li&gt;

&lt;li&gt;Explicit memory control. Layout and allocation control. Interior / value types.&lt;/li&gt;

&lt;li&gt;Very lightweight tasks (coroutines). Cheap to spawn thousands-to-millions.&lt;/li&gt;

&lt;li&gt;Stack iterators (effectively lambda-blocks w/o heap allocation).&lt;/li&gt;

&lt;li&gt;Static, native compilation. Emits ELF / PE / Mach-o files.&lt;/li&gt;

&lt;li&gt;Direct and simple interface to C code (switch stacks and call, ~8 insns).&lt;/li&gt;

&lt;li&gt;Multi-paradigm. pure-functional, concurrent-actor, imperative-procedural, OO.&lt;/li&gt;

&lt;li&gt;First class functions with bindings.&lt;/li&gt;

&lt;li&gt;Structurally-typed objects (no nominal types or type hierarchy).&lt;/li&gt;

&lt;li&gt;Multi-platform. Developed on Windows, Linux, OSX.&lt;/li&gt;

&lt;li&gt;UTF8 strings, assortment of machine-level types.&lt;/li&gt;

&lt;li&gt;Works with existing native toolchains. GDB / Valgrind / Shark / etc.&lt;/li&gt;

&lt;li&gt;Practical rule-breaking: can break safety rules, if explicit about where and how.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Rust implementation is still in the &amp;#8216;only useful for Rust developers&amp;#8217; state since the implementation and libraries are still being developed. There are two Rust compilers in various states of development. They are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rustboot - written in O&amp;#8217;Caml with it&amp;#8217;s own x86 code generation backend. This is being used to bootstrap the &amp;#8216;rustc&amp;#8217; implementation.&lt;/li&gt;

&lt;li&gt;rustc - self hosting compiler written in Rust and bootstrapped using &amp;#8216;rustbost&amp;#8217;. Code generation is done using LLVM.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;rustboot&lt;/code&gt; can be used to write Rust programs and try out the language. &lt;code&gt;rustc&lt;/code&gt; is still in heavy development and only very basic stuff works from what I can see.&lt;/p&gt;

&lt;h2 id='building'&gt;Building&lt;/h2&gt;

&lt;p&gt;Please note, as of 2011-10-24, the instructions for building Rust below are out of date. For updated instructions read &lt;a href='/2011/10/24/building-rust.html'&gt;my recent post on building Rust&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;a href='https://github.com/graydon/rust/wiki/Getting-started'&gt;instructions to build Rust&lt;/a&gt; are in the wiki. One important point is you need an SVN version of LLVM. I built this from source using a git mirror of LLVM (on 64 bit x86 Linux):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git clone git://github.com/earl/llvm-mirror.git
$ cd llvm-miror
~/llvm-mirror $ CXX=&amp;#39;g++ -m32&amp;#39; CC=&amp;#39;gcc -m32&amp;#39; CFLAGS=-m32 CXXFLAGS=-m32 \
                LDFLAGS=-m32 ./configure --enable-shared --disable-bindings \
                 --{build,host,target}=i686-unknown-linux-gnu \
                 --enable-targets=x86,x86_64,cbe
~/llvm-mirror $ make &amp;amp;&amp;amp; make install&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Once you have LLVM and the other pre-requisites installed:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git clone git://github.com/graydon/rust.git
$ cd rust
~/rust $ mkdir build
~/rust $ cd build
~/rust/build $ ../configure
~/rust/build $ make check&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This builds the &lt;code&gt;rustboot&lt;/code&gt; compiler, uses that to compile &lt;code&gt;rustc&lt;/code&gt;, then runs a series of tests using both builds. If you have &lt;code&gt;valgrind&lt;/code&gt; installed this will be slow as the tests are run under &lt;code&gt;valgrind&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id='bootstrap_compiler'&gt;Bootstrap Compiler&lt;/h2&gt;

&lt;p&gt;The bootstrap compiler executable is &lt;code&gt;boot/rustboot&lt;/code&gt;. The command to execute it, assuming the build occurred in the directory &lt;code&gt;~/rust/build&lt;/code&gt; is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o hello hello.rs&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will compile a Rust program in &lt;code&gt;hello.rs&lt;/code&gt; and leave an executable &lt;code&gt;hello&lt;/code&gt;. The &lt;code&gt;-L&lt;/code&gt; argument references the &lt;code&gt;boot&lt;/code&gt; subdirectory containing the Rust standard library in &lt;code&gt;libstd.so&lt;/code&gt;. A &amp;#8216;hello world&amp;#8217; program for testing is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use std;

fn main() {
  log &amp;quot;Hello World&amp;quot;;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To run the executable you&amp;#8217;ll need to adjust the &lt;code&gt;LD_LIBRARY_PATH&lt;/code&gt; to include the &lt;code&gt;rt&lt;/code&gt; subdirectory to pick up the Rust runtime shared library:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o test test.rs
~/rust/build $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/rust/build/rt
~/rust/build $ ./hello
rt: ---
rt: ca09:main:main: rust: Hello World&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='rustc_compiler'&gt;rustc Compiler&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;rustc&lt;/code&gt; compiler lives in &lt;code&gt;stage0/rustc&lt;/code&gt;. The output of this compiler is LLVM bytecode which must then be compiled using LLVM tools. To compile the &lt;code&gt;hello.rs&lt;/code&gt; program mentioned in the previous section:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/rust/build/rt:~/rust/build/rustllvm
~/rust/build $ stage0/rustc -nowarn -L stage0 -o hello.bc hello.rs
~/rust/build $ llc -march=x86 -relocation-model=pic -o hello.s hello.bc
~/rust/build $ gcc -fPIC -march=i686 -m32 -fno-rtti -fno-exceptions -g \
               -o hello.o -c hello.s
~/rust/build $ gcc -fPIC -march=i686 -m32 -fno-rtti -fno-exceptions -g \
               stage0/glue.o -o hello hello.o -Lstage0 -Lrt -lrustrt&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note the need to add the &lt;code&gt;rustllvm&lt;/code&gt; directory to &lt;code&gt;LD_LIBRARY_PATH&lt;/code&gt; to pick up a shared library. That sequence of commands will compile the &lt;code&gt;hello.rs&lt;/code&gt; file to LLVM bytecode. &lt;code&gt;llc&lt;/code&gt; compiles the bytecode to x86 assembly. &lt;code&gt;gcc&lt;/code&gt; compiles this to an object file, followed by a final &lt;code&gt;gcc&lt;/code&gt; invocation to link it. And to run:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ ./hello
rt: ---
rt: ee0b:main:main: rust: Hello World&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='rust_language_details'&gt;Rust Language Details&lt;/h2&gt;

&lt;p&gt;For examples of the Rust language there are multiple tests and the source code to &lt;code&gt;rustc&lt;/code&gt; itself in the &lt;a href='git://github.com/graydon/rust.git'&gt;github repository&lt;/a&gt;. The &lt;a href='https://github.com/graydon/rust/wiki'&gt;wiki&lt;/a&gt; has a link to the PDF documentation, &lt;a href='https://github.com/downloads/graydon/rust/rust-2011-02-25-snap.pdf'&gt;currently a snapshot from 2011-02-25&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The following are some quick examples of Rust features that work with the bootstrap compiler.&lt;/p&gt;

&lt;h3 id='foreign_function_interface'&gt;Foreign Function Interface&lt;/h3&gt;

&lt;p&gt;This program uses the C FFI to call the &amp;#8216;puts&amp;#8217; function from the C shared library:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use std;
import std._str.rustrt.sbuf;
import std._str;

native mod libc = &amp;quot;libc.so.6&amp;quot; {
    fn puts(sbuf s) -&amp;gt; int;
}

unsafe fn main() {
  libc.puts(_str.buf(&amp;quot;hello from C\n&amp;quot;));
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Compile and run with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o cffi cffi.rs
~/rust/build $ ./cffi
hello from C&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id='command_line_arguments'&gt;Command Line Arguments&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;use std;

fn main(vec[str] args) {
  for(str s in args) {
    log s;
  }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;main&lt;/code&gt; function takes a vector of strings as the argument. This holds the command line arguments passed to the program. The example iterates over the vector printing out each element.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o args args.rs
~/rust/build $ ./args a b c
rt: ---
rt: ccca:main:main: rust: ./args
rt: ccca:main:main: rust: a
rt: ccca:main:main: rust: b
rt: ccca:main:main: rust: c&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id='factorial'&gt;Factorial&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;use std;

fn fac(uint x) -&amp;gt; uint {
  if (x &amp;lt;= 1u) {
    ret 1u;
  }
  else {
    ret x * fac(x-1u);
  }
}

fn main() {
  log fac(5u);
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;No language is complete without showing how factorial can be computed.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ ./fac
rt: ---
rt: d158:main:main: rust: 120 (0x78)&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id='spawning_tasks'&gt;Spawning Tasks&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;use std;

impure fn logger(port[str] logs) {
  let int i = 0;
  while (i &amp;lt; 2) {
    auto msg &amp;lt;- logs;
    log msg;
    i = i + 1;
  }
  log &amp;quot;logger exited&amp;quot;;
}

impure fn main() {
  let port[str] logs = port();
  let task p = spawn logger(logs);
  auto out = chan(logs);
  out &amp;lt;| &amp;quot;Hello&amp;quot;;
  out &amp;lt;| &amp;quot;World&amp;quot;;
  join p;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A port is the receiving end of a typed inter task communication mechanism. A channel is the sending end of the communication mechanism. &lt;code&gt;&amp;lt;|&lt;/code&gt; sends to the port and &lt;code&gt;&amp;lt;-&lt;/code&gt; receives from the channel.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o spawn spawn.rs
~/rust/build $ ./spawn
rt: ---
rt: 9a73:main:spawn.rs:1: rust: Hello
rt: 9a73:main:spawn.rs:1: rust: World
rt: 9a73:main:spawn.rs:1: rust: logger exited&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id='types'&gt;Types&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;use std;

tag list {
  nil;
  cons(int, @list);
}

fn list_len(@list l) -&amp;gt; uint {
   fn len(@list l, &amp;amp;uint n) -&amp;gt; uint {
    alt (*l) {
      case (nil) {
        ret n;
      }
      case (cons(_, ?xs)) {
        ret len(xs, n+1u);
      }
    }
  }
  ret len(l, 0u);
}

fn main() {
  let @list l = @cons(1, @cons(2, @cons(3, @nil)));
  log list_len(l);
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This example creates a &lt;code&gt;list&lt;/code&gt; type. It has constructors for an empty list, &lt;code&gt;nil&lt;/code&gt;, and a &lt;code&gt;cons&lt;/code&gt; containing an integer and the rest of the list. The &amp;#8217;@&amp;#8217; prefixed to the &lt;code&gt;list&lt;/code&gt; type in places means that that variable holds a boxed object. That is, it&amp;#8217;s a reference-counted heap allocation.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;list_len&lt;/code&gt; function shows the use of a local function which pattern matches over the list (using the &lt;code&gt;alt&lt;/code&gt; keyword) and keeps a running total of the list length. The &lt;code&gt;main&lt;/code&gt; function creates a &lt;code&gt;list&lt;/code&gt; and prints the length.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o types types.rs
~/rust/build $ ./types
rt: ---
rt: 8126:main:main: rust: 3 (0x3)&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id='typestate'&gt;Typestate&lt;/h3&gt;

&lt;p&gt;The typestate system is one of the things that most interests me about Rust. If you&amp;#8217;ve been reading my &lt;a href='http://www.bluishcoder.co.nz/tags/ats/'&gt;ATS&lt;/a&gt; posts, in particular the ones involving &lt;a href='http://www.bluishcoder.co.nz/2011/02/26/reading-data-from-a-file-in-ats.html'&gt;type safe checking of array bounds&lt;/a&gt;, you&amp;#8217;ll know I&amp;#8217;m interested in languages that can help with detecting programming problems at compile time. It seems to me that the typesafe system can help here.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s a contrived example demonstrating one use of typestate. &lt;code&gt;main&lt;/code&gt; takes a vector of strings containing the command line arguments. I want to call a function, &lt;code&gt;dosomething&lt;/code&gt;, that will use these arguments but for some reason there must be never more than 2 arguments. Imagine I&amp;#8217;m calling some C routine that&amp;#8217;ll die if I do.&lt;/p&gt;

&lt;p&gt;I could check at runtime that the number of arguments is less than three. Here&amp;#8217;s an example that does this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use std;
import std._vec;

fn dosomething(&amp;amp;vec[str] args) {
  log &amp;quot;vector length is less than 3&amp;quot;;
}

fn main(vec[str] args) {
  log _vec.len[str](args);
  check (_vec.len[str](args) &amp;lt; 3u);
  dosomething(args);
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Some example runs:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o ts1 ts1.rs
~/rust/build $ ./ts1 a
rt: ---
rt: b3b1:main:main: rust: 2 (0x2)
rt: b3b1:main:main: rust: vector length is less than 3
~/rust/build $ ./ts1 a b
rt: ---
rt: d884:main:main: rust: 3 (0x3)
rt: d884:main:main: upcall fail &amp;#39;.t0 &amp;lt; 3u&amp;#39;, ts2.rs:5&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notice the last invocation has failed since three arguments are used (the program name is counted as an argument).&lt;/p&gt;

&lt;p&gt;It would be good to be able to check at compile time that somewhere the assertion holds that the number of arguments is less than three. In our example if we left the &lt;code&gt;check&lt;/code&gt; call out, the program would still compile, but &lt;code&gt;dosomething&lt;/code&gt; might do something disasterous. We can tell the typestate system that the precondition must hold for callers of &lt;code&gt;dosomething&lt;/code&gt; and to fail at compile time by adding a &amp;#8216;prove statement&amp;#8217; to the function:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use std;
import std._vec;

fn prove_length(&amp;amp;vec[str] args, uint n) -&amp;gt; bool {
  ret _vec.len[str](args) &amp;lt; n;
}

fn dosomething(&amp;amp;vec[str] args) : prove_length(args, 3u) {
  log &amp;quot;vector length is less than 3&amp;quot;;
}

fn main(vec[str] args) {
  log _vec.len[str](args);
  dosomething(args);
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The addition of &lt;code&gt;: prove_length(args, 3u)&lt;/code&gt; to the function tells the typestate system that this boolean function must evaluate to true. It examines what it knows of the constraints made via &lt;code&gt;check&lt;/code&gt; statements and the like to see if it can prove that this is the case. If it is not then a compile error occurs. The above program will fail to compile:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o ts2 ts2.rs
ts2.rs:14:13:14:19: error: Unsatisfied precondition constraint prove_length(args, 3u) &lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If we add a &lt;code&gt;check&lt;/code&gt; statement we are adding an assertion check that this precondition holds. Typestate makes note of this and will now allow that call to &lt;code&gt;dosomething&lt;/code&gt; to compile:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use std;
import std._vec;

fn prove_length(&amp;amp;vec[str] args, uint n) -&amp;gt; bool {
  ret _vec.len[str](args) &amp;lt; n;
}

fn dosomething(&amp;amp;vec[str] args) : prove_length(args, 3u) {
  log &amp;quot;vector length is less than 3&amp;quot;;
}

fn main(vec[str] args) {
  log _vec.len[str](args);
  check prove_length(arg, 3u);
  dosomething(args);
}

~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o ts3 ts3.rs
~/rust/build $ ./ts3
rt: ---
rt: d9e6:main:main:                       rust: 1 (0x1)
rt: d9e6:main:main:                       rust: vector length is less than 3&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It&amp;#8217;ll be interesting to see how typestate is used in the standard library and third party libraries to help with compile time checking of code.&lt;/p&gt;

&lt;h2 id='conclusion'&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Rust is an interesting language and there&amp;#8217;s quite a bit more to it than I&amp;#8217;ve covered here. I just picked random features to try. I&amp;#8217;m looking forward to &lt;code&gt;rustc&lt;/code&gt; being more complete and trying out some of the language features in more &amp;#8216;real world&amp;#8217; examples to get a feel for it.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>New Wave Audio Backend Landed</title>
   <link href="http://bluishcoder.co.nz/2011/03/31/new-wave-audio-backend-landed.html"/>
   <updated>2011-03-31T16:00:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2011/03/31/new-wave-audio-backend-landed</id>
   <content type="html">&lt;p&gt;Yesterday I landed &lt;a href='https://bugzilla.mozilla.org/show_bug.cgi?id=635649'&gt;bug 635649&lt;/a&gt; on &lt;a href='https://hg.mozilla.org/mozilla-central'&gt;mozilla-central&lt;/a&gt;. This is a refactoring of the wave backend for the HTML audio element. The initial work on this bug was done by &lt;a href='http://blog.mjg.im/'&gt;Matthew Gregan&lt;/a&gt; with me completing the patch.&lt;/p&gt;

&lt;p&gt;Prior to this landing the wave backend implemented the HTML audio API itself, sharing very little implementation details with the other audio backends. This meant the backend had to implement the intricate details of what events get raised and when they get raised. When we wrote the WebM backend we refactored the code so we could share this sort of thing amongst backends. This bug refactored the wave backend to share this code.&lt;/p&gt;

&lt;p&gt;The advantages of this are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Less likelihood of &amp;#8216;wave backend only&amp;#8217; bugs.&lt;/li&gt;

&lt;li&gt;Less code to maintain.&lt;/li&gt;

&lt;li&gt;The &lt;a href='https://wiki.mozilla.org/Audio_Data_API'&gt;Audio Data API&lt;/a&gt; can now use wave files as this was implemented in the shared backend code.&lt;/li&gt;
&lt;/ul&gt;</content>
 </entry>
 
 <entry>
   <title>Git Conversion of Mozilla Central</title>
   <link href="http://bluishcoder.co.nz/2011/02/10/git-conversion-of-mozilla-central.html"/>
   <updated>2011-02-10T14:00:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2011/02/10/git-conversion-of-mozilla-central</id>
   <content type="html">&lt;p&gt;The Mozilla repository for Firefox development, &lt;a href='http://hg.mozilla.org/mozilla-central'&gt;mozilla-central&lt;/a&gt;, is a mercurial repository. I prefer using &lt;a href='http://git-scm.com/'&gt;git&lt;/a&gt; for version control so I usually do my Firefox development using a &lt;a href='http://www.bluishcoder.co.nz/2008/12/changes-to-git-mirror-of-firefox.html'&gt;git mirror&lt;/a&gt; of the mozilla-central repository.&lt;/p&gt;

&lt;p&gt;To convert the repository into git I used &lt;a href='http://repo.or.cz/w/fast-export.git'&gt;hg-fast-export&lt;/a&gt;. This has worked well over the last couple of years. Unfortunately I&amp;#8217;ve noticed that my git mirror and the official mercurial repository differ slightly. The git mirror contains files that have been deleted or moved in the official repository and lately the mirror has stopped building due to some commits not being correctly converted. As a result I stopped updating my mirror and used mercurial directly.&lt;/p&gt;

&lt;p&gt;I still prefer developing using git though so I tried the &lt;a href='http://hg-git.github.com/'&gt;hg-git mercurial plugin&lt;/a&gt;. This took about six days on my laptop to do the conversion and peaked at 14GB of memory. The result was a git repository with a working tree that, according to diff, is an exact copy of the original mercurial repositories working tree. Another nice feature of the hg-git is that commit id&amp;#8217;s in the resulting git repository are the same across multiple runs of hg-git. This would allow other users to push and pull from a git repository that they converted independently.&lt;/p&gt;

&lt;p&gt;To perform the conversion I installed hg-git and ran the following series of commands:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mkdir git
$ cd git
$ git init --bare
$ cd ..
$ hg clone https://hg.mozilla.org/mozilla-central hg
$ cd hg
$ hg bookmark -r default master
$ hg push ../git&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Six days and 14GB later, the resulting git repository ended up being about 7GB in size. I did a &lt;code&gt;git gc --aggressive&lt;/code&gt; on it to get this down to 200MB. Incremental updates of new mercurial commits are done with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cd hg
$ hg pull -u
$ hg bookmark -f -r default master
$ hg push ../git&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I&amp;#8217;ve pushed a mirror of this to github at &lt;a href='http://github.com/doublec/mozilla-central'&gt;http://github.com/doublec/mozilla-central&lt;/a&gt;. I&amp;#8217;m using this for development and will see if it is able to continue importing without diverging from the original mozilla-central source.&lt;/p&gt;

&lt;p&gt;More information about the use of git for Mozilla development can be found in the followup posts I did on the subject:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href='/2011/04/16/my-git-workflow-for-mozilla-development.html'&gt;My Git Workflow for Mozilla Development&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href='/2011/10/28/performing-compatible-updates-of-mozilla-central-git-forks.html'&gt;Performing Compatible Updates of Mozilla Central Git Forks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
 </entry>
 
 <entry>
   <title>WebM Decoder in Flash using Alchemy</title>
   <link href="http://bluishcoder.co.nz/2011/01/15/webm-decoder-in-flash-using-alchemy.html"/>
   <updated>2011-01-15T02:10:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2011/01/15/webm-decoder-in-flash-using-alchemy</id>
   <content type="html">&lt;p&gt;&lt;a href='http://unitzeroone.com/blog/'&gt;Ralph Hauwert&lt;/a&gt; has been posting on twitter about work he&amp;#8217;s done on getting WebM decoding to work in Flash by compiling the &lt;a href='http://www.webmproject.org/code/'&gt;libvpx&lt;/a&gt; source code using Adobe&amp;#8217;s &lt;a href='http://labs.adobe.com/technologies/alchemy/'&gt;Alchemy&lt;/a&gt; technology.&lt;/p&gt;

&lt;p&gt;Alchemy is a research project that allows compilation of C and C++ libraries into code that runs on the ActionScript virtual machine used by Flash. Ralph &lt;a href='http://twitter.com/#!/UnitZeroOne/status/25710899566219264'&gt;originally tweeted&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Had a quickshot porting #WebM codec to Flash 10 using libvpx and alchemy. Surprisingly, got a preliminary version to work.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;He &lt;a href='http://twitter.com/#!/UnitZeroOne/status/25711897814769664'&gt;followed up with a post&lt;/a&gt; saying the intial performance of a 1920x1080 VP8 video with no audio was decoding to YUV at about 1.5 frames per second. He provides an &lt;a href='http://t.co/XGaiLYh'&gt;image&lt;/a&gt; of a decoded frame.&lt;/p&gt;

&lt;p&gt;This is good stuff and it&amp;#8217;ll be worth following his &lt;a href='http://twitter.com/#!/UnitZeroOne'&gt;twitter feed&lt;/a&gt; if you&amp;#8217;re interested in a pure flash implementation of a WebM decoder.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve been interested in having decoders written in JavaScript, which I wrote about in my &lt;a href='http://www.bluishcoder.co.nz/2009/06/05/reading-ogg-files-with-javascript.html'&gt;reading ogg files with JavaScript&lt;/a&gt; post. Maybe something similar to the Flash/Alchemy approach could be done with &lt;a href='http://code.google.com/p/emscripten/'&gt;emscripten&lt;/a&gt;, an LLVM to JavaScript compiler, to get a WebM decoder in JavaScript.&lt;/p&gt;</content>
 </entry>
 
 
</feed>

