User:Atanamir/Zeus/Athena

Athena is the Unified Javascript Model that allows for cross-browser javascript generation from a single source script (written using Thunder programming language), as well as an easy, thunder-integrated method of writing AJAX functions that can be called by both JavaScript and Client-thunder functions.

Pillars of Athena
Athena will be the forefront of the One Code, All Browsers philosophy of the Zeus platform. Athena has several pillars which will provide the best implementation to match the philosophy:
 * The programmer should write one source code to target all browser targets.
 * The progrmamer should not have to worry about minutiae for each browser.
 * The programmer should be able to use the same syntax (Thunder) that he is accustomed to with server-side programming.
 * The programmer should not have to worry about specific JavaScript constructs to use, but should be able to use the standard Thunder constructs for everything.

JavaScript Generation Techniques

 * Server-side browser target determination - this generation model will allow for the smallest javascript to be generated (and probably offers the best client-side performance). Using the HTTP headers sent by the browser, the appropriate browser generation target is selected, and only that browser's code will be sent to the client.
 * Client-side browser target selection - using object detection and other various methods of browser determination, generated javascript for all loaded browser target(s) will be sent to the client, separated out in an if/elseif format.

Athena integration into Thunder
With Athena programming, there is a fine line between language constructs and integrated libraries to facilitate the pillars established above. Because of the blur between the two ideas, it is easier to think of the Athena component as an integral part of the Zeus platform and not as a separate component.

Client Functions
Thunder allows for this JavaScript generation by the use of client functions. Client functions are not sent to the execution unit for server-side Thunder scripts, but instead are sent to the Athena engine for translation. client function get($elementId : string) { var $element = document.get($elementId); var $height = $element.height; return $height; }

W3C primitives / built-in objects
Because JavaScript written using Thunder is not executed, but translated, the programmer should be able to do things that are familiar in Thunder using Thunder-like syntax, but are acutally translated to W3C-compliant JavaScript at runtime. For example, array declarations in Thunder: $x[] = 5; // declaration, instantiation, and assignment

will be translated into: var x = new Array; x.push(5);

Transparent Closures
Closures are a very advanced feature of JavaScript that is hard to understand and to leverage correctly. Athena should also take care of this, allowing for easy access of 'this' instances in JavaScript events:

$element = document.getElementById("element"); $element.onmouseover += this.method($var1, $var2); // note the += syntax. client function method($p1, $p2) { return $p1 + $p2; }

Should be translated into the following JavaScript (note the closure):

// this is from Athena JS libraries: function AddObjWithEvent(obj, method) { return function(evt) { return obj[method](obj, parameters[2], parameters[3]); } } function AddEvent(obj, type, func) { }

// generated JavaScript: var element = document.getElementById("element"); addEvent(element, "mouseover", AddObjWithEvent(element, "method", var1, var2); function method(obj) {  return parameters[1] + parameters[2]; }

Browser Target Selection
The JavaScript generation target system used in Athena is an user-extensible text-file based approach. The script-writer will ship for several target browsers:
 * Internet Explorer 6 (7 as a separate target file?)
 * Mozilla Firefox
 * Opera

Zeus