ECMAScript 3.1 Final Draft Emerges

Tagged:  

Also known as ECMAScript 5th Edition, the new JavaScript standard has entered final draft stage. Among the goodies: a formal getter and setter syntax for object properties, language reflection features, support for the JSON data format, additional Array methods, and a strict mode that improves error checking.

Function.bind

Function.prototype.bind(self, args...). A bind function wraps a function in a closure, storing references to the context arguments from the surrounding scope. This is somewhat equivalent to the following:

Function.prototype.bind = function(context) {
  var fun = this;
  return function(){
    return fun.apply(context, arguments);
  };
};

Applications include partial application of arguments to a function and currying. Though you can custom-roll one today, a native bind function in 3.1 should outperform any equivalent user-defined function.

Array

The additional Array methods in ECMAScript 3.1 are identical to methods introduced in JavaScript 1.6-1.8, but were never present in any official ECMAScript specification. They are currently implemented in Firefox 3.x. Of course, having them in ECMAScript 3.1 means that now you will be able to actually use them (provided, of course, that all browsers implement the standard...). These methods are: indexOf, lastIndexOf, filter, forEach, every, map, some, reduce, and reduceRight. There's a good description of each method here.

ECMAScript 3.1, also known as JavaScript Harmony, is the less ambitious version of what was to be JavaScript 2/ECMAScript 4, a plan scuttled when some members of ECMA balked at the large additions to the language.

The new specification is available here.

Google Releases Eclipse Plugin

Tagged:  

Hot on the heels of the announcement that Java can now be used with the Google App Engine, the Google Plugin for Eclipse has been released, supporting both Google Web Toolkit and Google App Engine development.

GWT Features:

  • Recognition of inline JavaScript (JSNI): syntax highlighting, auto-indenting, Java Search and Refactoring integration
  • GWT compiler shortcuts and configuration UI
  • Wizards to create entry points, modules and HTML pages
  • Support for GWT JUnit tests

App Engine Features:

  • Easy deployment to App Engine
  • As-you-type validation ensures that your code is compatible with App Engine
  • Build projects and 'enhance' JDO classes automatically without the need for ANT

The user's manual for the plugin is here. The plugin works with both Eclipse 3.4 (update site) and 3.3 (update site).

Dojo Toolkit 1.3 Released

The 1.3 version of the Dojo toolkit is finally out. The main focus of this release has been browser compatibility (particularly IE 8 and Chrome) and speed. According to Dojo-reported numbers on the TaskSpeed benchmark, Dojo is the fastest JavaScript toolkit on common DOM operations, at least twice as fast as other JavaScript toolkits. Of course, all the usual caveats about micro-benchmarking apply, but the speed increase is nevertheless quite impressive.

Simultaneous with the Dojo 1.3 release is the release of the PlugD, a library allows Dojo developers to mimic some of the popular aspects of jQuery (method chaining, as well as many similarly-named convenience methods).

The full release notes can be found here. You can download the new release here.

Animal Swap - A Fun Free Flash Game

Tagged:  

Not that long ago I mentioned that I have been working on a few fun Flash games. The first game that is finished is called Animal Swap and is a simple pattern matching puzzle game.

The game is very simple and hopefully addictive. If anybody is interested in coding a Flash game and wants to see the source code, just send me a note and I can send it to you.

You can play the game here

You can find more games including this one at my other site wastingtimegames.com.

I'd love to get your thoughts on this game, so feel free to leave a comment about it.

Canvas 3D - The future of the web?

Tagged:  

Today I ran across a cool 3D world terrain texture map demo. The demo is made using Canvas 2D with the 3D code written in JavaScript. The demo runs in Firefox 3, Safari 3 and Chrome. This got me thinking about the future of the web and if we will see a lot of 3D on the web.

Mozilla is working on a Canvas 3D plug-in to ship with a future version of Firefox what will be using a simplified version of OpenGL. The hope is that some cool apps will be made using this plug-in and that will force other browsers to use some form of Canvas 3D (and eventually adhere to standards). So, if some very cool on-line game or useful charting application is made in 3D it is possible that we will be coming up with some interesting 3D user interfaces using Canvas 3D in the future (hopefully in the near future).

This brings up the question of what would you use 3D on the web to do? Do you think it would be useful or just fun? The answers to these questions could shape the future of the web.

You can see the demo here.

JavaScript as a Functional Language

Tagged:  

Douglas Crockford, author of the JSON data format, has written that JavaScript as a language is like a "Lisp in C's clothing":

JavaScript's C-like syntax, including curly braces and the clunky for statement, makes it appear to be an ordinary procedural language. This is misleading because JavaScript has more in common with functional languages like Lisp or Scheme than with C or Java.

This is a really interesting statement, especially if you are used to looking at JavaScript code like this:

var myGlobal = ...;
function myProceduralFunction() {
     // ...
}

Don't laugh...you've probably written JavaScript like this at one time or another. I certainly did, before I really understood JavaScript. For a long time, this is how most people grokked JavaScript, as a kind of dynamically typed C/C++. There are also those who try to make JavaScript behave as a Java-style OOP language (a natural tendency, given the misnomer): using nested objects as package-style "namespaces", trying to make prototypical inheritance look like static class inheritance, etc. It's all a bit of a stretch, but since JavaScript does actually borrow many OOP concepts, it can be done. I would argue, though, that Crockford is right and JavaScript is more naturally used as a functional language. In this article I am going to briefly examine some of the similarities between JavaScript and functional programming languages, and how the JavaScript programmer can use them to his/her advantage.

Back to the 90's

Tagged:  

It's Friday and everyone wishes it was Saturday. Wouldn't it be great to get a jump start on your weekend video game playing. Well, while surfing the web I found a great Doom clone written in Flash (so you can play it once the boss leaves early on Friday, but I wasn't the one that said that). The game is an exact clone of the 90's classic and is still a lot of fun to play.

You can play the game here.

Update: I had the wrong link above (it took you to a link to the game), here is the direct link.

Pligg 1.0.0 RC3 Available

Tagged:  

You may have read my posts on Having Fun with Pligg. In the series of posts I have been talking about setting up a Pligg site using Pligg 1.0.0 RC2. Well, Pligg 1.0.0 RC3 has been released and this will be the final release candidate, so you may want to upgrade your Pligg instance.

Below is an excerpt from the announcement.

Our final version of the release candidate line for Pligg, Pligg 1.0.0 RC3, is available for download now. This version introduces a new admin category page (seen below) and a number of bug fixes including better support for Search Engine Optimized (SEO) URLs and foreign languages. We are only a couple weeks away from a final version of Pligg, which we expect will be picked up by a lot of web hosts and template providers.

You can read more about Pligg 1.0.0 RC3 (including a link to the download) here.

Explorer Canvas Release 3

Tagged:  

Explorer Canvas, otherwise known as the little JavaScript library that allows you to use VML while still coding in HTML 5 Canvas (thank heaven), has released the third version of the library. The major reason for the release is compatibility with Internet Explorer 8, but there are numerous other bug fixes and improvements in the release. A comprehensive list of changes is here.

You can download the new release here.

New Clojure Release (3-20-2009)

Tagged:  

One of the most interesting new languages to emerge recently is Clojure, a dialect of LISP (a very old language) that runs on the JVM and contains an implementation of software transactional memory (STM) in the core of the language itself.

Hot off the presses (Rich Hickey hasn't even blogged about it yet) is a new release for 2009-03-20. Contained in the download zip are the release notes with all of the bug fixes since the previous release in December of last year.

Anyone who hasn't explored Clojure (or who thinks that LISP is when someone talks funny) should definitely check out Rich Hickey's screencasts over at blip.tv.

Syndicate content