What’s the Milescript Team up to?

June 2, 2008 – 8:22 am

Just thought I’d let everyone know what the Milescript team is up to.

We’ve spent the last few months fixing bugs and designing the last bits of functionality that will bring Milescript up to Beta.  In the works are function closures, dynamic linking (finally), an Apache module, and several updates to the MSEclipse plugin.

We are also fixing a few issues with the Alpha version of the Milescript compiler.  In addition to fixing some glaring bugs with Generics, we are focusing on increasing the efficiency of the compiler.  In our early tests we have reduced compile time by almost 80%, and we believe we can improve on that even more.

We are working hard in an effort to get Milescript to Beta before the Ajax Experience conference in September.  Look back here often to see many new documents and tutorials, as well as periodic updates coming to the software itself.

See ya in September!

May 2, 2008 – 1:19 pm

On a whim, we sent an application to the folks at ajaxian in response to their call for papers back in January. Well guess what? It got accepted! We are absolutely thrilled to be giving a lightning round (15-minute) talk to the entire conference on the first day of the “Ajax Experience 2008.” It will be held in Boston, starting on Monday, Sept. 29th, and lasting for three days.

We just finished putting together the presentation, and now all I have to do is rehearse it every day for the next five months so I don’t wet myself on stage. On the bright side, this also provided a nice shot-in-the-arm as far as Milescript development goes, as we’ve got a lot we want to implement before then.

Why Milescript Externals Make Wrapping Javascript Easy and Efficient

January 24, 2008 – 11:55 pm

Wrapping Javascript libraries is easy in Milescript, all you have to do is define the specification. When you use a method in a statically-typed language like Milescript, you must know the type of each parameter to the method, as well as the return type. We wanted interfacing with existing Javascript libraries to be as easy as writing down this specification.

You use external classes to define the interface with existing Javascript.

Supoose you have two Javascript methods you wish to use in Milescript named “add” and “subtract”,

function add(int1, int2) {
return int1 + int2;
}

function subtract(int1, int2) {
return int1 - int2;
}

To wrap these methods in Milescript you would write the following external class,

package com.example;

public external nameless class MathClass {
public static int add(int int1, int int2);
public static int subtract(int int1, int int2);
}

All you have to do to wrap an existing Javascript library is write down the specification. You do not have to implement “adapter” classes which generate code and execute in the runtime.

Milescript external classes are not generated.

This means that a wrapper library for a library such as ExtJS or YUI will not generate any additional code. Only the external library itself (under the respective library’s license) and the code you write to make use of the library will be executed in the runtime. No adapter code will be executed in the runtime.

These methods we just wrapped can be called in Milescript as follows,

int result = MathClass.add(2,3);
window.alert(result);
window.alert(MathClass.subtract(10,result));

When run, this would pop up an alert box with the text “5″ twice.

This means that large Javascript libraries such as ExtJS and YUI can be made available to Milescript quickly. It also means that the Milescript programmer can make use of available Javascript resources in any existing system, without generating additional “adapter” code.

The Milescript Paradigm

January 20, 2008 – 4:06 pm

Object-oriented software processes involve four basic stages, which occur over and over again in an iterative cycle: inception, elaboration, implementation, and transition. For the layman this means think-it, design-it, create-it, and deploy-it. You may wonder where testing comes in; the answer is that testing is performed during the entire process. The goal of any object-oriented software process is to build extensible systems efficiently using reusable components.

Where does OO process fit into web development?

Usually on the server-side. There are many languages and platforms which facilitate the OO process. Java and JSP, C# and ASP, etc… . These languages rely heavily on server components to dynamically render HTML. This is great for applications which require a lot of server feedback. What about a website which simply lets the client do something interactive without a lot of server feedback?

Choose your weapon…

There are two primary methods of creating client-side Rich Internet Applications, Javascript and Flash.

If you choose Javascript you must then choose between a variety of often conflicting libraries or you must implement everything on your own.

If you choose Flash you must then choose a version of the authoring program which meets the budget and licensing constraints of the project.

Will these frameworks enforce OO practices and foster reuse of code?

These frameworks are not restrictive enough to guarantee that code you produce will work with code someone else produces, even code written in the same framework. Flash allows the developer to package code for distribution, but Javascript does not enforce a single distribution paradigm nor any type of contract between library developers and library users. What you end up with is a large variety of independently created libraries, very few of which work together.

For example, there are Javascript libraries designed to be used programtically, and there are Javascript libraries designed to interact with pre-created DOM nodes with particular attributes (such as a unique “id”). Toolkits such as Dojo often employ both techniques. A Javascript library designed to interact with pre-created DOM nodes may not be easily adapted for programmatic use, or it may. Large Javascript libraries such as Dojo don’t often work with other third-party libraries. Dojo 0.4 doesn’t work with Dojo 1.0, though many components have updated versions. There are many guides to help ease migration from Dojo 0.4 to Dojo 1.0.

Imagine if Java 1.6 forced developers to rewrite old libraries for compatibility.

Distributing libraries in Javascript is difficult because Javascript does not enforce namespacing and scoping. It doesn’t even require that an attribute or method exist as a member of a class. There is simply no way to guarantee that your code will not conflict with or corrupt code imported from third-party libraries. Even worse, if the library does work there is no explicit contract to guide your usage of the library because Javascript doesn’t support types, interfaces or classes. Documentation is often sparse or non-existent, and even when good documentation is made it must be written in a separate place or a third-party program must be used to scrape for inline documentation, creating a wide variety of documentation formats.

So what do I do?

You must pick and choose the right tools for the job. You’ll need a set of libraries which provide the functionality you’ll need and that have been shown to work together. You’ll need a utility to scrape the code for inline documentation or you’ll need to write your documentation elsewhere. You’ll need to work closely with your co-workers to ensure that your methods and objects will work together. You may wish to find another utility for performing unit tests.

So let’s just bring it all together.

When we were designing Milescript, we wanted a framework which provided a class based inheritance structure and enforced namespacing and scoping at compile-time rather than at runtime. We chose the Java structure for its simplicity and widely accepted syntax and semantics. We also wanted a static-typing system to enforce contracts between code suppliers and code users. We wanted to be able to easily specify interfaces for working with existing code bases, rather than having to implement adapter classes which create unneeded overhead. Most importantly, we wanted the entire tool-chain to be integrated, ensuring that my libraries, tests and documentation will be usable by others without compatibility concerns. Backwards compatibility is inherent in the design which ensures that my libraries will never become obsolete.

Milescript has several deployment options.

I can deploy my code as a library, and it will create an indexed archive file dubbed a “mar.” These libraries have been compiled in order to guarantee their interoperability with other Milescript libraries. Naming and scoping schemes are used to avoid conflicts, and condensed names are mapped to their original names in meta-data files stored in the “mar” but not served to the client. This ensures that my library will be reusable by myself and by others (even those using legacy Javascript).

I can deploy my code as a statically-linked application and the Milescript Compiler will build a Javascript file which consolidates all used code from all imported libraries. If I didn’t use a particular widget or class, then it is not included. I do not have to use a separate utility or a separate process to build my production code. Applications could be as small as a few kilobytes or as large as a few megabytes.

Back to Object-oriented Process

So now let’s revisit creating a client-side Rich Internet Application using an Object-oriented process, but this time let’s use Milescript.

Our analysts will create specifications, our developers will implement them and the testers will, well test.

Here I show the four stages and some tasks to be performed by each role during each phase.

Milescript RUP

The specifications can be easily adapted to Milescript “interfaces” by the developers. This ensures that the contracts between code suppliers and code users are guaranteed to be met.

The testers develop unit tests which ensure that the output of each method or function agrees with the specifications produced by the analysts.

During the Transition phase, all of the specifications and implemented packages are compiled into a library and the documentation and unit test artifacts are packaged for reuse.

Later the libraries, documentation and units tests can be brought together to create statically-linked applications which include only the needed components.

Here’s a brief look at how the Milescript artifacts interact.

Milescript Component Interaction Overview

Due to the static-typing and Java-style class and package structure, the Milescript Compiler is able to create a distributable format that guarantees interoperability with other Milescript libraries. It also provides a host of other tools such as code condensation and logging, but that will all be covered in another article.

For now, we have seen that the Milescript Compiler enforces the principles and practices required to adhere to an Object-Oriented Process.

Point5u Blog Online

January 13, 2008 – 8:06 pm

The Point5u Blog is now online!

The Point5u team will be posting their thoughts and commentary about Milescript, Rich Internet Applications, Web 2.0, and other similar topics.

Check back often and post your own comments.  You can also subscribe to the RSS feed and get the blog in your favorite reader.