torsdag den 29. maj 2008

Release 0.1

We released version 0.1 of the Mascara ECMAScript 4 to JavaScript compiler today.

First a warning: This is an alpha release, and there may be all kinds of problems getting it to run. If you have any problems getting it to run on your platform, please mail me or write it in a comment. A known bug is that many unittest uses cscript.exe to run the code. This engine is only available on windows. A future version will support your favorite engine.

Installation
Python 2.5.2 is required.
Download and unpack Mascara.0.1. You don't need to install, just run from the folder.

Getting started

In the root folder is a script translate.py. Run this script with an es4 file as input, and the script will generate a js file as output. You can try it with the file testfile/classtest.es4 which is included. Example:

translate.py testfile/classtest.es4

You can get help to the cli options by typing:

translate.py --help

Since the ECMAScript 4 standard is still in flux, this implementation is obviously incomplete. Here is some of the major differences:

Include/Import
The include/import implementation is based on a early draft of the standard. Syntax and possibly semantics will change before release.

The Include directive includes the content of a file in the compilation. Basically this is similar to the #INCLUDE directive in C.
Example:
include "unittest.es4";
The files are located either in the standard library, or relative to the main input file.

The Import directive loads declarations from a file and uses them for verification, but does not include the file content in the generated code.
Example:
import browserapi;
The files are located in the standard library, or relative to the main input file, and is expected to have the ".es4" extension.

Some files which is useful to include:
browserapi : defines the main objects avaliable in the browser: window, document and so on. Note: the declarations are just for proof-of-concept, and is not yet the full API as defined by WHATWG and W3C.
htmldom: The full W3C HTMLDOM
canvasapi: The WHATWG Canvas drawing API

Type verification and code generation
The translator will warn about any type error it detects, but it will also try to generate the code anyway if at all possible. Code with type errors might not work as intended, so the warnings should be taken serious. However in the interest of experimentation and gradual migration from classic JavaScript, we have chosen to allow code to be generated even with type errors.

Features supported
  • Type verification
  • Classes and inheritance, constructors, super initializers
  • Static members
  • Type inference from initialization
  • Parameterized types; Map and Vector classes
  • Union types
  • Structural types
  • Getters/setters
  • Namespaces
  • Nullable types
  • Like-constraints
  • And much more :-)
Features not yet supported
  • Interfaces
  • public/private attributes
  • override/final attributes
  • Iteration and itemization protocols (*)
  • Array comprehensions (*)
  • Let expresssions
  • Destructuring assignments (*)
  • Runtime type inspection: switch on types, like-operator
  • Generators
  • Generic functions
  • Slice syntax
  • And much more :-)
(*) Supported by Mozilla, but does not yet compile into a syntax supported by all engines.

Features which might never be supported
  • Catch-all methods
  • General metaprogramming (above what is natively supported by the target engine)
Comments and bug reports
Any kind of comment is welcome. Either email me, or just write a comment here on the blog.

2 kommentarer:

Fatih Nakış sagde ...
Denne kommentar er fjernet af forfatteren.
Fatih Nakış sagde ...
Denne kommentar er fjernet af en blogadministrator.
This blog has moved to http://blog.mascaraengine.com. See you!

This blog is (was) for news, announcements and questions regarding the
Mascara ECMAScript 6 -> JavaScript translator.