Weston Ruter

Web application developer in Portland, Oregon

Showing support for JavaScript and the Mozilla Developer Network

spacer

If you want to see access to JavaScript documentation improve on the Web, grab a copy of the code above from PromoteJS to boost the MDN PageRank. Dare I say, we must take the top spots away from W3Schools.

No Comments »

My X-Team Superhero Identity Revealed

Tonight we at X-Team had a very special meeting: the induction ceremony for new superheroes! X-Team employees are given superhero identities, and I was next in line for induction along with Wojtek Zając and Ben King. Our meeting was extra special because five of us have been together in Los Angeles this month working for a client on-site, and so we were able to meet in person while we logged in to our chat room to join up with everyone else around the world. So my superhero identity is:

spacer

spacer (Weston) is a highly intelligent and technologically resourceful elemental of Nordic descent who can manipulate, control weather and transcommunicate (via electronic voice) through his thundercloud static field. With his static field, he also is able to create lightning bolts and move within them, allowing him to travel at impressive speed.

The name is extra meaningful as it was the superhero name that I went by as a kid, so things have come full circle! Along with my name and description, I was also given a badge depicting my superhero self (right), and incidentally my mask actually looks quite similar to Condorman’s, my favorite old superhero movie. Thanks so much to my coworkers at X-Team for the effort that went into this and for making me feel so part of the team. It’s truly an honor to be working with you, such a talented international team!

Here’s the slightly-abridged transcript of our chat for the induction with the unveiling of my superhero:

tine: …and we have one more superhero to induct today.
tine: this is someone who was a superhero coming in, but sealed his superhero status within the first week of working with us.
tine: someone who’s taking us all by STORM and made a BIG, BIG impression.
tine: for this superhero, we travel back to the U.S, and to the Westcoast..and we welcome…
spacer
weston: yay!
benking gave weston a high five!
david gave weston a high five!
tine gave weston a high five!
adi gave weston a high five!
marconi gave weston a high five!
hz gave weston a high five!
dargaud gave weston a high five!
wojtek gave weston a high five!
vio gave weston a high five!
tine: @weston, you shall now be known as…
tine: DRUMROLL PLEASE
marconi: druuuuuuummmmmuuummmmummm
tine: daruuuuuumdrummmmmmmdrummmm
wojtek: come on Tine we’re drumrolling here spacer
tine: druuuuuuuuuuuuuuuumdarrrummm
tine: drrrrrrrrrrr
tine: uuuuuuuuum
tine: ruum
wojtek: Tine!!! spacer
Benking faints with anxiety
tine: Thunderboy
wojtek: yay spacer
marconi: la la la la la la Thunder!
tine: Thunderboy is a highly intelligent and technologically resourceful elemental of Nordic decent who can manipulate, control weather and transcommunicate (via electronic voice) through his thundercloud static field. With his static field, he also is able to create lightning bolts and move within them, allowing him to travel at impressive speeds.
weston: That’s the superhero name I had as a kid spacer
spacer
vio gave weston a high five!
marconi gave weston a high five!
benking: woe nice one weston
josh gave weston a high five!
josh: nice!!
adi gave weston a high five!
hz gave weston a high five!
tine gave weston a high five!
adi: congrats @weston
tine: Welcome to the league, @weston!
weston: Awesome, I like it!
weston: Thanks all!
marconi can’t wait to see the new superheroes with their new avatars spacer
tine: @wojtek, @benking, @weston – you are all amazing, and well-deserving of your new superhero statuses. Wield your new powers with care, but put them to good use!
dave: Welcome!!! The league has gone to a whole new level with these new heroes!

4 Comments »

ECMAScript Proposal: Named Function Parameters

I recently ran across the ES wiki which is documenting proposals and features for new versions of ECMAScript (JavaScript). I was excited to see the spread operator “...” which basically brings Perl-style lists to JavaScript. I was also excited to see the spread-related rest parameters which basically implement Python’s positional parameter glob *args; however, I did not see something equivalent to Python’s named parameter glob **kwargs (see on Python Docs).

I’ve been giving thought to passing in named arguments to function calls in JavaScript, eliminating the need for the current pattern of wrapping named arguments in an object, like:

function foo(kwargs){
    if(kwargs.z === undefined)
        kwargs.z = 3; //default value
    return [kwargs.x, kwargs.y, kwargs.z];
}
foo({z:3, y:2, x:1}); //=> [1, 2, 3]

Instead of this, I’d love to be able discretely define what arguments I’m expecting in a positional list, but then also allow them to be passed in as named arguments:

function foo(x, y, z){
    return [x, y, z];
}
foo(1, 2, 3) === foo(z:3, x:1, y:2); //=> [1, 2, 3]

This could also work with the ES proposal for parameter default values:

function foo(x, y, z = 3){
    return [x, y, z];
}
foo(1, 2) === foo(y:2, x:1); //=> [1, 2, 3]

Although the current proposal has a requirement that only trailing formal parameters may have default values specified, this shouldn’t be necessary when named parameters are used:

function foo(x = 1, y, z){
    return [x, y, z];
}
foo(z:3, y:2); //=> [1, 2, 3]

Furthermore, although the current spread proposal only works with arrays, it could also work with objects for named parameters:

var kwargs = {y:2, x:1, z:3};
foo(...kwargs); //=> [1,2,3]

Finally, the rest parameters proposal uses spread to implement the rough equivalent of Python’s positional parameter glob (*args), but I’m not sure how it could also be applied to named parameters to support Python’s **kwargs at the same time—I’m not sure how named rest parameters would work. For example in Python:

def foo(x, *args, **kwargs):
    return [x, args[0], kwargs['z']]
foo(1, 2, z=3); //=> [1, 2, 3]

Python has the * to prefix positional parameter globs and ** to prefix named parameter globs, but so far ECMAScript only has one prefix the “...” spread operator.

These are just some rough ideas about how JavaScript could support named parameters. I’m sure there things I’ve missed and implications I haven’t thought of, but I wanted to get my thoughts out there. What do you think?

2 Comments »

Programming Languages I’ve Learned In Order

Update: See also list on MY TECHNE.

What follows are the programming languages I’ve learned in the order of learning them; their relative importance is marked up with big, and small indicates I didn’t fully learn or actually use the language.

  1. Perl 5
  2. JavaScript / ECMAScript
  3. PHP 4 & 5
  4. SQL
  5. Visual Basic 6
  6. Java
  7. Classic ASP: VBScript & JScript
  8. (Visual) C/C++
  9. XSLT
  10. Ruby
  11. Python (I expect/hope that this will supplant PHP in the next couple years, getting an extra big or two.)

While Python is now my server-side language of choice, I would be much happier to use JavaScript end-to-end. Thanks to the CommonJS initiative, this is becoming a reality.

Not included in the list above are markup languages and other related technologies: (X)HTML 4 & 5, XML, CSS, DOM, RSS, Atom, RDF, XML Schema, XPath, JSON, JSON/XML-RPC, SVG, VML, OSIS, iCal, Microformats, MathML, etc.

Idea via and prompted by James Tauber, via Dougal Matthews.

3 Comments »

Proposal for Customizing Google’s Crawlable Ajax URLs

On the Shepherd Interactive site, we have a dynamic navigation menu in Flash. In order to prevent it from having to reload each time a page is changed, I implemented Ajax loading so that the SWF only has to load once. This is similar to what Lala and Facebook do. So if your browser is Ajax-enabled, upon visiting:

shepherdinteractive.com/portfolio/interactive/

You will get redirected to site root / with the old path supplied as the URL hash fragment which is then loaded in via JavaScript as the page content:

shepherdinteractive.com/#portfolio/interactive/

However, according to Google’s Making AJAX Applications Crawlable specification, Ajax pretty URLs are any containing a hash fragment beginning with !, for example:

shepherdinteractive.com/#!portfolio/interactive/

The purpose of the ! is merely to inform Googlebot that such a URL is for an Ajax page whose content can be fetched via:

shepherdinteractive.com/?_escaped_fragment_=portfolio/interactive/

The problem I have with Google’s specification is that the pretty URL Ajax fragment prefix (!) is mandated; it is not customizable. I should be able to tell Googlebot which fragment identifiers are for Ajax content and which are not. Therefore, instead of requiring authors to to conform to Google’s Ajax specification, I propose that Google adopt an extension to robots.txt which allows site owners to let Googlebot know what to look for. The current specification’s mandate for ! could be indicated via:

Ajax-Fragment-Prefix: !

Or it could be changed to anything else, such as “ajax:“. If the Ajax fragment doesn’t have a prefix at all (as in the case of Shepherd Interactive’s website above), a regular expression pattern match could be specified in robots.txt, for example:

Ajax-Fragment-Pattern: .+/

This would tell Googlebot that a URL with a fragment containing a slash should be fetched via the _escaped_fragment_ query parameter, and that the Ajax URL itself (including the fragment identifier) should be indexed and returned verbatim in the search results.

It’s true that the Shepherd Interactive site implements Hijax (progressive enhancement with Ajax) techniques, so every Ajax URL has a corresponding non-Ajax URL; so in this sense, Google can still access all of the content. The problem, however, is with links to Ajax URLs from around the Web. I assume for Googlebot, every link to an Ajax URL without the obligatory prefix ! is interpreted as referring to the home page (site root /):

  • shepherdinteractive.com/#portfolio/interactive/harmer-steel/
  • shepherdinteractive.com/#about-us/our-company/
  • shepherdinteractive.com/#services/web-development/

So Google then assigns no additional PageRank to our Ajax URLs since it gets assigned to the home page. If, however, Googlebot could be told that those are actually Ajax URLs, then the PageRank could be properly assigned. (My assumptions here could be incorrect.)

Thoughts?

Update 2010-04-22: “Cowboy” Ben Alman brought up the excellent point that customizable Ajax-crawlable URLs need to work on a per-path basis, as different single page web apps on the same server (or even in the same folder) might have different URI requirements. I wonder if in addition to (or instead of) using robots.txt to tell Googlebot the format of the Ajax-crawlable URLs, why not allow that information to be placed in meta tags? Their specification already includes:

<meta name="fragment" content="!">

Why not make Googlebot support additional meta tags for recognizing the prefix (if any) or pattern that characterizes an Ajax-crawlable URL on a given page? For example:

Current default behavior:
<meta name="crawlable-fragment-prefix" content="!">
Starting with “/” like …about/#/us/:
<meta name="crawlable-fragment-prefix" content="/">
All fragments are crawlable:
<meta name="crawlable-fragment-prefix" content="">
Any fragment ending with a slash:
<meta name="crawlable-fragment-pattern" content=".+/">

With these meta tags, authors would be able to have complete page-level control over the structure of Ajax-crawlable URLs (hash fragments).

6 Comments »

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.