Comparing Water to JSP for Building Web Sites
- The Task: Define a Function and Call It From HTML
- Why should you program in XML?
- Water shares the same syntax as HTML and XML
- Water supports a flexible architecture
- Water Implementation
- JSP Implementation
- References and Useful links
When building a web site, how does Water compare to other technologies? The first and second articles in this series showed how to build a simple program with a few lines of code.
The Water code in the first articles was very simple and compact. How does it actually compare to the code required to do the same thing in one of the leading web development platforms, JSP and Java? This article demonstrates how a 7-line program written in Water has the same functionality as a 65-line program written in JSP and Java. The comparison is summarized in the following table:
|# Files||# Lines||# Characters||# Languages|
|JSP, Java, and Custom Tag Libraries||4||65||1337||4|
Water is a new XML-Native object-oriented programming language that allows you to program in XML. It is an open language designed to simplify the creation of new Web services and programs. Water adheres to a "Learn Once, Use Everywhere" philosophy where a single language unifies data, logic, and presentation. An interpreter is freely available from www.waterlang.org. The Water Runtime is deployed on a standard Servlet engine. Clear Methods, www.clearmethods.com, sells a commercially supported XML-Native platform based on the Water language.
The Task: Define a function and call it from HTML
A common task in web development is to define a function that can be called from multiple pages. For example, defining a single dynamic footer to put in multiple pages. The task is to create a new method with a single parameter, message, and call the method from an HTML page. The method returns the value of the argument.
This description does not sound very complicated, but the implementation is about 10 times smaller in Water than other technologies such as JSP or ASP. Before we view the code, I will describe several ways in which Water simplifies the development of Web services and programs.