HybridJava 0.97

by admin November 25, 2009 at 5:00 pm

A new Java-based technology for programming dynamic web content. The obvious and common approach to this well known task is to combine mark-up and decision-taking information in one text. This means combining in one compact source HTML and operators of some general programming language. One old way of doing that is to embed HTML into a program e.g. writing print(““) in a CGI/C program. Another, more recent – to embed elements of programming language into HTML. There is also a symmetric way of doing things and Java Server Pages (JSP) technology is of that kind. Unfortunately that seems to be the only advantage of JSP.

HybridJavaâ„¢ (HJ) is a new language that is a symmetric cross between Java and HTML and in this sense HJ is a direct successor of JSP. The great difference is that JSP processor is just a ‘template engine’ – it performs a blind text substitutions while HJ is a strictly defined compilable language that equally incorporates Java and HTML.

The immediate advantage of HJ over JSP is a dramatic drop of junk syntax of <% and %> delimiters that usually makes JSP pages barely readable. Another immediate advantage is earlier check for syntax errors.

Besides Java and HTML entities the HJ syntax has a simple but powerful support for code factorization and reuse. Widgets are defined in HJ code and that does not lead to any additional Java programming. Unlike known implementations of user-defined tags HJ widgets may have several named points of insertion. Recursive usage of widgets is supported. A unique feature is transparency of widgets for Java context when variables from a page are accessible in its widgets.

For each page the compiler generates a presentation Java class (P-class) with a method ($render) that, when executed, provides HTML output sent to the client. Code of widgets gets properly inserted into the generated class.

Pages may have a corresponding Java class for page state (PS-class) that contains session-persistent data of the page and/or methods operating on that data. The $handlePage is a special method known to and called by the framework. P-class is created as derived from PS-class so all the non-private members of the latter are plainly accessible in the former and thus in $render and in the page and widgets HJ source.

Widgets may have a corresponding Java class for widget state (WS-class) that contains session-persistent data of the widget and/or methods operating on that data. The $handleWidget is a special method known to and called by the framework. While processing a widget compiler generates access to identifiers defined in its WS-class. Together a widget plus its WS-class (when provided) constitute a component. The framework supports transmission of messages from a component to a senior component or to the page. Components declared as “shared” may be used on several pages with a single component data instance used.

HybridJava language is easy to learn for those who already know both Java and HTML.

HybridJava is free for non-commercial use.

Download: HybridJava 0.97