Personal tools

Hajax

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(Added reference to Yhc web service)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[http://en.wikipedia.org/wiki/Ajax_%28programming%29 Ajax] applications are ‘stand-alone’ Web applications that execute into the browser environment, communicating with one or more server back-ends only to get raw data.
+
[http://en.wikipedia.org/wiki/Ajax_%28programming%29 Ajax] applications are stand-alone Web applications that execute into the browser environment, communicating with one or more server back-ends only to get raw data.
   
 
Ajax applications can be written using either:
 
Ajax applications can be written using either:
Line 6: Line 6:
 
** Examples being [http://www.dojotoolkit.org/ dojo] and [http://rialto.application-servers.com/wiki/ Rialto] (see the [http://dmoz.org/Computers/Programming/Languages/JavaScript/AJAX/ Open Directory Ajax page] for more).
 
** Examples being [http://www.dojotoolkit.org/ dojo] and [http://rialto.application-servers.com/wiki/ Rialto] (see the [http://dmoz.org/Computers/Programming/Languages/JavaScript/AJAX/ Open Directory Ajax page] for more).
 
* Higher-level languages that are compiled into native browser code.
 
* Higher-level languages that are compiled into native browser code.
** Examples being the [http://code.google.com/webtoolkit Google Web Toolkit] for Java and [http://www.openlaszlo.org OpenLaszlo], for the high-level UI language Laszlo.
+
** Examples being the [http://code.google.com/webtoolkit Google Web Toolkit] for Java, [http://www.openlaszlo.org OpenLaszlo], for the high-level UI language Laszlo, and [http://www.haxe.org haXe], another high-level language with multiple runtimes.
   
 
Hajax is a proposal to create a Haskell-based tool to program 'stand-alone' Ajax applications.
 
Hajax is a proposal to create a Haskell-based tool to program 'stand-alone' Ajax applications.
Line 38: Line 38:
 
Advantage: possibly higher run-time performance, thanks to a more direct mapping between Haskell and JavaScript.
 
Advantage: possibly higher run-time performance, thanks to a more direct mapping between Haskell and JavaScript.
   
An example of this approach is Dimitry Golubovsky’s nhc98 to JavaScript Compiler, see [http://www.golubovsky.org/repos/nhc98/] and in particular [http://www.golubovsky.org/repos/nhc98/src/compiler98/STGJcode.hs].
+
An example of this approach is Dimitry Golubovsky's nhc98 to JavaScript Compiler, see [http://www.golubovsky.org/repos/nhc98/] and in particular [http://www.golubovsky.org/repos/nhc98/src/compiler98/STGJcode.hs].
   
 
==== Two-Stages Compilation ====
 
==== Two-Stages Compilation ====
 
Haskell code is compiled into an intermediate format (e.g. bytecodes or [http://en.wikipedia.org/wiki/C-- C--] or [http://llvm.org/ LLVM]) that is then compiled to JavaScript.
 
Haskell code is compiled into an intermediate format (e.g. bytecodes or [http://en.wikipedia.org/wiki/C-- C--] or [http://llvm.org/ LLVM]) that is then compiled to JavaScript.
   
For example: [http://www-users.cs.york.ac.uk/~ndm/yhc/ yhc] to yhc bytecode to JavaScript (via the [http://www.eecs.tufts.edu/~rdocki01/yhc-bytecode.html yhc bytecode API] or similarly with GHCi bytecodes.
+
For example: [http://www-users.cs.york.ac.uk/~ndm/yhc/ yhc] to yhc bytecode to JavaScript (via the [http://www.eecs.tufts.edu/~rdocki01/yhc-bytecode.html yhc bytecode API]) or similarly with GHCi bytecodes.
 
 
 
Advantage: much faster to develop as there would be less or no changes required in the compiler and the bytecode to JavaScript compilation should be straightforward.
 
Advantage: much faster to develop as there would be less or no changes required in the compiler and the bytecode to JavaScript compilation should be straightforward.
  +
  +
Dimitry Golubovsky has been working on a Yhc Core to Javascript converter, see [[Yhc/Javascript]]. This continues the nhc98-based compiler to Javascript project mentioned above.
   
 
=== Compiler Targets ===
 
=== Compiler Targets ===
 
Possible targets for the compiler are:
 
Possible targets for the compiler are:
 
* JavaScript/HTML/CSS
 
* JavaScript/HTML/CSS
* Flash
+
* Flash (potentially through [http://swfmill.org SWFmill])
 
* The [http://www.openlaszlo.org/node/331 OpenLaszlo kernel] (currently under development) that can be executed in either Flash or HTML/Web browsers.
 
* The [http://www.openlaszlo.org/node/331 OpenLaszlo kernel] (currently under development) that can be executed in either Flash or HTML/Web browsers.
  +
* The [http://haxe.org haXe] language can compile to Flash Player versions 6-9, Ajax using the JS DOM, or server-side using the Neko VM.
   
 
== Generic Haskell Libraries ==
 
== Generic Haskell Libraries ==
Line 72: Line 75:
   
 
* [http://www.haskell.org/haskellwiki/Haskell_Equational_Reasoning_Assistant HERA] is written in Haskell and JavaScript. HERA uses asynchronous HTTP requests and Haskell threads to attempt many shallow rewrites quickly, in order to offer the user sensible choices. HERA would be a great stress test for Hajax.
 
* [http://www.haskell.org/haskellwiki/Haskell_Equational_Reasoning_Assistant HERA] is written in Haskell and JavaScript. HERA uses asynchronous HTTP requests and Haskell threads to attempt many shallow rewrites quickly, in order to offer the user sensible choices. HERA would be a great stress test for Hajax.
  +
  +
* [[Yhc_web_service|Yhc Web Service]] is an experimental web-based tool to submit Haskell source code for compilation to Javascript and to run it in the web browser. Its frontend exchanges [http://www.json.org JSON]-encoded messages over AJAX (XMLHTTP) with [http://www.couchdb.com CouchDB] based backend. Compilation to Javascript is provided by [[Yhc/Javascript|Yhc Javascript backend]].
  +
  +
[[Category:Applications]]
  +
  +
== Similar Tools ==
  +
* [http://www.flapjax-lang.org/ Flapjax - A Functional Reactive compiler and Javascript library for interactive Web GUIs]

Latest revision as of 13:18, 26 March 2008

Ajax applications are stand-alone Web applications that execute into the browser environment, communicating with one or more server back-ends only to get raw data.

Ajax applications can be written using either:

  • Native libraries/frameworks in JavaScript/HMTML/CSS and/or Flash.
  • Higher-level languages that are compiled into native browser code.
    • Examples being the Google Web Toolkit for Java, OpenLaszlo, for the high-level UI language Laszlo, and haXe, another high-level language with multiple runtimes.

Hajax is a proposal to create a Haskell-based tool to program 'stand-alone' Ajax applications.

The main advantages of Hajax would be:

  • Web development using a very-high level language with extensive compile-time checks
  • No plugins (e.g. a Java VM) required on the user browser
  • No Haskell server back-end required (Hajax applications would communicate with back-ends written in any language).

Likely disadvantages with respect to native Ajax solutions are:

  • An additional compilation step
  • Lower performance

Hajax would consist of the following modules:

  • A Haskell compiler able to generate, directly or indirectly, native browser code.
  • Generic Haskell libraries (a port of a subset of the standard Haskell Libraries.
  • User interface framework and libraries.
  • (Optionally) A development environment.

Contents

[edit] 1 Compiler

Requirements:

  • Support for Haskell 98 + most popular extensions.
  • Fast compilation.
  • Compact and efficient compiled code.

[edit] 1.1 Compiler Design alternatives

[edit] 1.1.1 Direct Compilation

Haskell code is directly compiled to JavaScript.

Advantage: possibly higher run-time performance, thanks to a more direct mapping between Haskell and JavaScript.

An example of this approach is Dimitry Golubovsky's nhc98 to JavaScript Compiler, see [1] and in particular [2].

[edit] 1.1.2 Two-Stages Compilation

Haskell code is compiled into an intermediate format (e.g. bytecodes or C-- or LLVM) that is then compiled to JavaScript.

For example: yhc to yhc bytecode to JavaScript (via the yhc bytecode API) or similarly with GHCi bytecodes.

Advantage: much faster to develop as there would be less or no changes required in the compiler and the bytecode to JavaScript compilation should be straightforward.

Dimitry Golubovsky has been working on a Yhc Core to Javascript converter, see Yhc/Javascript. This continues the nhc98-based compiler to Javascript project mentioned above.

[edit] 1.2 Compiler Targets

Possible targets for the compiler are:

  • JavaScript/HTML/CSS
  • Flash (potentially through SWFmill)
  • The OpenLaszlo kernel (currently under development) that can be executed in either Flash or HTML/Web browsers.
  • The haXe language can compile to Flash Player versions 6-9, Ajax using the JS DOM, or server-side using the Neko VM.

[edit] 2 Generic Haskell Libraries

Libraries that would be useful include:

  • Prelude
  • Generic functional and mutable data structures
  • Parser/Regex libraries

[edit] 3 UI Framework and Libraries

Most of the Haskell frameworks developed for GUI programming (see Libraries_and_tools/GUI_libraries) or Web programming (e.g. HSPClientside, see a full list at Libraries_and_tools/Web_programming) could be adapted for Hajax.

The libraries would include:

  • A complete set of UI widgets
  • Network libraries for browser-to-server communication

[edit] 4 Development Environment

It should be relatively easy to adapt existing Haskell development environments like EclipseFP to work with Hajax.

[edit] 5 Existing AJAX Applications Written in Haskell

  • HERA is written in Haskell and JavaScript. HERA uses asynchronous HTTP requests and Haskell threads to attempt many shallow rewrites quickly, in order to offer the user sensible choices. HERA would be a great stress test for Hajax.
  • Yhc Web Service is an experimental web-based tool to submit Haskell source code for compilation to Javascript and to run it in the web browser. Its frontend exchanges JSON-encoded messages over AJAX (XMLHTTP) with CouchDB based backend. Compilation to Javascript is provided by Yhc Javascript backend.

[edit] 6 Similar Tools