Posts

Showing posts from March, 2013

Ecma wasn’t always Ecma

Most people know that ECMAScript is the language standard behind JavaScript [1] . Fewer people know that its name comes from Ecma International , the organization managing this standard. Interestingly, that organization started as “European Computer Manufacturers Association (ECMA)”, but renamed itself to “Ecma International” in 1994. That was done to reflect its increasingly international focus. Ecma is now not considered an acronym, any more. Ecma International is located in Geneva. In contrast, TC39 [1] , the Ecma-hosted committee evolving ECMAScript, is rather USA-centric (true to where JavaScript was created and who created it) and usually meets somewhere in California. This little bit of history also explains why it’s spelled ECMAScript and not EcmaScript: That’s a remnant from when Ecma was still ECMA. Reference: ECMAScript: ES.next versus ES 6 versus ES Harmony

Parallel JS (River Trail): soon in Firefox

2013-12-23: A new blog post on ParallelJS (as Parallel JS is now called) supersedes this post. Parallel JS will soon be included in Firefox Nightly builds. This project was initially called River Trail [1] . It automatically parallelizes code that uses the ParallelArray type and its array-like methods ( map() etc.). [Source of this post: “ Parallel JS lands ” by Nicholas D. Matsakis.] Time table: Now: Only a limited subset of JavaScript is supported and you don’t get good feedback as to whether your code could be parallelized and if not, why not. Medium term: All pure functions (that don’t mutate shared state, only data that they create and store in local variables) will be parallelizable; better diagnostics when parallelization is not possible. Long term: Make parallelization as wide-spread in JavaScript as possible and evolve the API. One possible improvement is to bring parallelization to normal arrays. Currently, ParallelArray pulls double duty, it is

Life Is What Happens To You

Image
Before you cross the street Take my hand Life is what happens to you While you’re busy making other plans…            John Lennon   “Beautiful Boy (Darling Boy)” In the fall of my seventh year, my parents bought their first home and I was forced to switch schools a month into second grade.   I loved my old school, even though I did try to run away when I was in first grade .   I have never made friends easily, and have always been a bit of a loner.   My original school was the school of my father, mother, and dozens of aunts and uncles, some only a few years older than me.   There was family tradition and history in the red brick walls of Our Lady of Peace Catholic School, and I had to leave it all behind. There was nothing inviting about my new school.   Now I was a complete outsider—no friends, no connections, no joy.   I arrived in Mrs. Vinette’s class a stranger in a strange land.   She was a woman in the final years of her teaching career, dried up, bitter, tough and severe.  

ECMAScript 6: TC39’s January 2013 meeting

TC39 [1] is the committe that currently plans ECMAScript 6 (code-named ECMAScript.next), the next version of the JavaScript language standard. January 29–31, they had another meeting. Thanks to Rick Waldron’s notes , we can read up on what has been decided. This blog post describes the highlights. Previous blog posts summarized prior meetings. (Note: a blog post on the March TC39 meeting will be posted at some time in the future.) January 29 Object.is() : strict equality ( === ) is safer than sloppy equality ( == ). But it still has the quirk of NaN not being equal to itself [2] . The original plan for ECMAScript 6 was to introduce an is operator that fixes this quirk, but those plans have been abandoned. Instead, you can use Object.is(op1, op2) if you need “stricter” equality [2] . Object.is() also distinguishes positive and negative zero [3] (which isn’t always desirable). ECMAScript Internationalization API (ECMA-402): Chrome 24 shipped with an (unprefixed) imp

Subclassing builtins in ECMAScript 6

[Update 2015-02-15] Newer version of this blog post: “ Classes in ECMAScript 6 (final semantics) ” In JavaScript, it is difficult to create sub-constructors of built-in constructors such as Array . This blog post explains the problem and possible solutions – including one that will probably be chosen by ECMAScript 6. The post is based on Allen Wirfs-Brock’s slides from a presentation he held on January 29, during a TC39 meeting. The problem Creating sub-constructors of built-in constructors is difficult to impossible. The normal pattern for subclassing in JavaScript is (ignoring the property constructor [1] ): function SuperConstr(arg1) { ... } function SubConstr(arg1, arg2) { SuperConstr.call(this, arg1); } SubConstr.prototype = Object.create(SuperConstr.prototype); If you want to use this pattern with built-in constructors, you are facing problems. The following example demonstrates those problems for Array ; they are similar for other builti

Encoding permutations as integers via the Lehmer code (JavaScript)

This blog post explores the Lehmer code, a way of mapping integers to permutations. It can be used to compute a random permutation (by computing a random integer and mapping it to a permutation) and more. Permutations A permutation of an array is an array that contains the same elements, but possibly in a different order. For example, given the array [ 'a', 'b', 'c' ] All of its permutations are: [ 'a', 'b', 'c' ] [ 'a', 'c', 'b' ] [ 'b', 'a', 'c' ] [ 'b', 'c', 'a' ] [ 'c', 'a', 'b' ] [ 'c', 'b', 'a' ] Computing a permutation: a naive solution In order to motivate the Lehmer code, let’s first implement a naive algorithm for computing a permutation of an array. Given the following array arr . var arr = [ 'a', 'b', 'c' ]; A simple way of computing a random permutation

Book Was There

Image
When any writer takes on the subject of reading in the digital age, he must understand that this is not new territory.   The digital age is aging, and the landscape shifts like sand on the beach at high tide.   To me, there is no better book about the state of reading right now than Sven Birkerts’ The Gutenberg Elegies (Faber & Faber, 2006).   However, there is always more to be said, and in that spirit, Andrew Piper takes a crack at 21 st century reading in his 2012 entry, Book Was There:  Reading In Electronic Times (University of Chicago Press, 2012). From the start, Piper assures us that the current so-called crisis in reading is nothing new.   It is true:   reading books has withstood the challenge of movies, television, audio books, and e-readers, yet Bowker.com reports that more than three million hard copy books were published in 2010.   The big change in that statistic is the rise of print-on-demand titles, which accounted for approximately two million of those books