Related Work

comparison to similar systems

Before choosing to implement a web application in BRL, any wise project manager will choose to look at all the options. This document compares BRL to other systems that also tie databases into the WWW. Each section gives a comparative example. Take the time to read each example carefully and ask yourself which system you'd rather program in. Don't just look at the relative code sizes; look at readability.


PL/SQL

If you constantly depend on Oracle support, it may be to your advantage to use only Oracle products. They provide tools that output code in PL/SQL, a procedural language built around SQL. If you'll just use this output as it comes and aren't too concerned about making your own sophisticated web design, you should have no problem. However, if you plan on doing maintenance to the PL/SQL code outside of the Oracle design tools, be prepared for lots of tedious work.

BRL code PL/SQL code
Hello World!
create or replace package pkg_hello_world AS
    PROCEDURE hello_world;
END pkg_hello_world;

create or replace package body pkg_hello_world AS

    PROCEDURE hello_world IS
    BEGIN 
        public_htp.htmlOpen;
        public_htp.bodyOpen(NULL);
        public_htp.print(public_htf.italic('Hello World!'));
        public_htp.bodyClose;
        public_htp.htmlClose;
    END hello_world;

END pkg_hello_world;

This is a very simple example, but even with more sophisticated examples it's easier to see what the BRL code is doing. BRL is template-based, as are the rest of the products in this document other than PL/SQL. PL/SQL may actually be the best language for Oracle database programmers, but it's the worst for HTML page designers.


Cold Fusion

Allaire has a language called CFML which is designed to look somewhat like HTML. It can't look totally like HTML because it's doing much more sophisticated work. It definitely qualifies as a full-fledged programming language; it just happens to be a language that nobody knows yet. They also provide graphical design tools, so maybe the learning curve won't be much of an issue to you.

The underlying language of BRL is Scheme, a mature programming language that is used at hundreds of colleges, universities, and secondary schools. Many of your programmers may already know it, but it's easy to pick up from examples, and there are several books available.

CFML is a mix of HTML-like syntax, C-like syntax, and syntax unlike anything else. If you look at CFML in a web browser, some of the code is hidden. You'll notice in the example below (adapted from an example in an Allaire white paper), that CFML duplicates some SQL functionality. The BRL style is to use as much of SQL as possible to simplify the rest of the code. In this example, prices are formatted by CFML when they could have been retrieved from the database already formatted.

BRL rendered CFML rendered
[(html-repeat
   (sql "SELECT ProductName,
           TO_CHAR(Price,
                   '$99999.99')
                  AS FmtPrice
           FROM Products"))]
  • [ProductName] [FmtPrice]
SELECT ProductName, Price FROM Products
  • #ProductName# #NumberFormat(Price, "$_____.__")#
BRL Source CFML Source
<pre>[(html-repeat
   (sql "SELECT ProductName,
           TO_CHAR(Price,
                   '$99999.99')
                  AS FmtPrice
           FROM Products"))]</pre>
<ul>
  <li>[ProductName] [FmtPrice]
</ul>
<CFQUERY NAME="ProductList"
         DATASOURCE="CompanyDB"> 
   SELECT ProductName, Price
     FROM Products 
</CFQUERY> 

<UL>
  <CFOUTPUT QUERY="ProductList"> 
     <LI>#ProductName#
 #NumberFormat(Price, "$_____.__")#
  </CFOUTPUT>
</UL>

Dynamo

Dynamo has an internal architecture that is superior to BRL in some ways. Unfortunately, you don't get to see that internal architecture while developing dynamo applications. You just get to see the language, which is Java. That's nice from a standards point of view, but it makes data access difficult.

Let's take the example used with Cold Fusion and remove the price formatting for simplicity. Also for simplicity, Dynamo code to establish a connection is omitted. BRL caches database connections, while in Dynamo you normally reestablish a connection with each HTTP request, although a shared connection cache could be implemented in Dynamo.

BRL rendered Dynamo rendered
[(html-repeat
   (sql "SELECT ProductName,
                Price
           FROM Products"))]
  • [ProductName] [Price]
BRL Source Dynamo Source
<pre>[(html-repeat
   (sql "SELECT ProductName,
                Price
           FROM Products"))]</pre>
<ul>
  <li>[ProductName] [Price]
</ul>
<!--DYN
import java.sql.*;

Statement stmt = conn.createStatement();
stmt.execute("SELECT ProductName, Price FROM Products");
ResultSet rs = stmt.getResultSet();
out.println("<UL>");
while (rs.next()) {
  out.println("<LI>" +
              rs.getString("ProductName")
              + " "
              + rs.getString("Price"));
}
out.println("</UL>");
-->

ASP/VBscript

Microsoft IIS comes with a facility called Active Server Pages for server-side embedding of program content. The language used is VBscript, which bears some resemblance to VB but will confuse an experienced VB programmer at first.

The most obvious problem with ASP is the amount of verbiage necessary to do simple tasks. Inserting form input values or database values involves a syntax of object.method("name") as opposed to BRL's syntax of name. For complex applications this really adds up to hard-to-maintain code.

BRL rendered ASP rendered
[(html-repeat
   (sql "SELECT ProductName,
                Price
           FROM Products"))]
  • [ProductName] [Price]
    <% set rs=server.createobject("adodb.recordset") sqlstr="SELECT ProductName, Price FROM Products" rs.open sqlstr, lConnect do until rs.eof response.write "
  • " & rs.fields("ProductName") & " " & rs.fields("Price") rs.movenext loop %>
BRL Source ASP Source
<pre>[(html-repeat
   (sql "SELECT ProductName,
                Price
           FROM Products"))]</pre>
<ul>
  <li>[ProductName] [Price]
</ul>
<ul>
  <%
  set rs=server.createobject("adodb.recordset")
  sqlstr="SELECT ProductName, Price FROM Products"
  rs.open sqlstr, lConnect
  do until rs.eof
    response.write "<li>" & rs.fields("ProductName") & " " & rs.fields("Price")
    rs.movenext
  loop
  %>
</ul>

W3-mSQL

If you are using mSQL you might consider using the tool that comes with it. W3-mSQL lets code be embedded in HTML pages using a language called Lite that was created along with mSQL and will only ever be used with mSQL. It has a C-like syntax with some Unix-shell syntax thrown in.

Although you must reestablish an mSQL connection with each HTTP request, code to do so is omitted from the following example.

BRL rendered W3-mSQL rendered
[(html-repeat
   (sql "SELECT ProductName,
                Price
           FROM Products"))]
  • [ProductName] [Price]
    0) { echo("
  • " + $row[0] + " " + $row[1]); } msqlFreeResult($res); >
BRL Source W3-mSQL Source
<pre>[(html-repeat
   (sql "SELECT ProductName,
                Price
           FROM Products"))]</pre>
<ul>
  <li>[ProductName] [Price]
</ul>
<ul>
<! 
  if (msqlQuery($sock,"SELECT ProductName, Price FROM Products") < 0)
  {
    fatal("Error : $ERRMSG\n");
  }

  $res = msqlStoreResult();
  $row = msqlFetchRow($res);
  while (#$row > 0)
  {
    echo("<li>" + $row[0] + " " + $row[1]);
  }
  msqlFreeResult($res);
>
</ul>

Conclusion

Your choices are limited. You can work with a language that is unsuited to the task and only works with Oracle (PL/SQL). You can work with a non-standard language supported by one small company (CFML or W3-mSQL). You can work with a standard but cumbersome language (Java in Dynamo). Or you can work with a standard language that's easy to use (Scheme in BRL) but doesn't have any company currently supporting it. MIT is using BRL internally and distributing it freely, but there's a lot more to support than that.

Maybe you don't need much support. Maybe you can modify the 1000 lines of C and 1000 lines of Scheme to suit your own needs.


BRL

V