Skip to content

HaXe and the Future of Web Development

June 27, 2008

Even though I’m focusing more on several theoretical issues these days, I’ve also been keenly interested in web development. When I say Web development, I mean just about everything involved with creating, accessing, and analyzing information using the WWW.

Development on the web takes place on two main fronts:

  1. The server side backend: This aspect deals with managing raw information and processing it into information that client side systems can use. Coding involves using declarative languages such as SQL to describe relationships between pieces of information, and object oriented languages like Java to define and enforce structural aspects of pieces of information.
  2. The client side frontend: This aspect deals with managing the information from the server using code downloaded from the server running on applications supported by the client. The code can contain a document object (such as html), or methods of manipulating html content on the client side (using javascript), or it can include a self-contained virtual machine application that can run inside a page (using SWF/java).

While the Web is completely open for a wide variety of formats, It is imperative for most producers of content to understand the ecosystem of common languages, protocols, and obstacles currently in practice. Web developers can spend years coming to terms with learning the wide variety of languages necessary to create more complex websites, and then spend more years learning how to make their site behave the same on different browsers, and then spending even more years learning how to make their website “gracefully degrade” with the limited feature sets of primitive browsers.

Basically, any new technology that “looks forward” to the future of the web should respect and accommodate the Web’s past protocols, in addition to respecting and following standards and guidelines.

Microsoft, Mozilla, Sun, and Adobe have led the way in promoting and supporting emergent Web technologies through their creation of web browsers and virtual machines. However, as a group (with the possible exception of Sun), they don’t have a good track record of supporting each other’s platforms, respecting standards set by Web authorities, or providing full disclosure of how their platforms operate. The net effect of this is a lot of confusion and complexity for the average developer.

Currently, Sun, Microsoft, Mozilla, and Adobe are promoting a new slate of technologies and releasing them into the wild. These include JavaFX, Silverlight, Javascript 2.0, and Flash 10 (Astro). While I have no doubt these technologies add additional needed features and “goodies” to the developers toolbox, they only add to an already overly complicated landscape of languages and protocols.

I’m of the opinion that this process will continue. One side will release a virtual machine/technology that becomes dominant for some reason, even though it arguably isn’t the “best implemented” technology for that application (SWF, and God help us, ActiveX). Then, the other sides won’t adopt or accommodate this new technology, either because it is closed source, or because of “not invented here” syndrome.

Enter haXe, an object oriented, open source, cross platform “Web programming language” created by Nicholas Canasse and the haXe community. As for right now, the community is very small, and most of the development has been done by Nicholas (A benevolent dictator model of open source development).

HaXe allows for an unprecedented level of control of all the Web programming languages. Using the haXe language and compiler, one can create server side code such as PHP, web documents, javascript code, and SWF bytecode. Literally, all aspects of a web site can be typed, checked, profiled, compiled, and published from a single language and compiler program.

The language should look familiar to folks who use Actionscript (Flash) or Javascript. This is because these languages are based (loosely) on the ECMAscript standard. HaXe essentially is a stricter form of ECMAscript than the other web languages, so it enforces a rigid type checking system. While this makes the language a little less “forgiving” for folks used to untyped variables, it makes error checking much easier, while also greatly improving the speed of the resulting code/bytecode.

Here’s some code that can compile to SWF and draw a square.

class Test {
    static function main() {
        var mc : flash.MovieClip = flash.Lib.current;

All platform specific objects (such as flash objects) are referenced through an API hierarchy, and are essentially identical except for their API prefix. You can see the official API reference for Flash, Javascript, etc. here.

I’ve used haXe to put together my ArtistNet applet for Strands. However, this only uses the Flash API. The real benefit comes when you want to reuse or test code across all the different platforms/API’s. For instance, say you wanted to create a web form that collects users names and information. It’s usually a good idea to check and make sure that information like phone numbers, e-mail addresses, etc. are correctly formatted. This can be checked and enforced on the server side, but it’s also a good idea to check on the javascript side, so that the user can be informed immediately if they haven’t entered something correctly.

The check that the site needs to be performed would have to be implemented twice, once on the server, and again with javascript on the client side. This causes redundancy, which is bad for code production efficiency reasons, as well as maintenance reasons. With haXe, the form checking code can be written once, and generated on as many different platforms as necessary. Furthermore, any changes or modifications can be done in one place, and deployed at once.

That’s all I have time to write about now, but I’ll have more to say about haXe in the future!

From → haXe, Web Development

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: