Bento Logo
> Bento Home > Bento Documentation > Bento in a Nutshell
Bento in a Nutshell

A Simple Page

To Bento, a web page is an object. An object has a type, a name and contents of some sort. The purpose of Bento is to define objects such as web pages. Here is a very simple object definition in Bento:

    page hello [|
        <h1>Hello, world.</h1>


The type of this object is page, its name is hello, and its content is a block of HTML. The [| and |] are static delimiters, indicating text which is to be sent to the browser.

Once an object has been defined in Bento, it may be constructed by a Bento compiler or a Bento-enabled server. Constructing an object yields HTML (or text in any other desired format) which may either be saved in a file (by a Bento compiler) or sent directly to a client (by a Bento-enabled server).

To see the actual page for yourself, go to hello.

Inheritance, Polymorphism and Composition

There's more to the hello object than just <h1>Hello, world</h1> however. Because hello is an object of type page, it inherits the contents of page as well. These contents include the boilerplate HTML that is a part of every web page, such as all the standard tags found on every proper HTML page (<html>, <head>, <title> and so on).

Inheritance is a key concept in object-oriented languages, and a key source of their power. It lets you define things as special cases of other things. In the case of hello, we defined a specific web page as a special case of a generic page. The concrete benefits of inheritance include making it easier to reuse existing code (reducing development costs), keep shared code in a single place (reducing maintenance costs) and keep content and presentation separate (the Holy Grail of web development).

Every object in Bento definition in Bento automatically also defines a type, which you can use to define new objects. For example, now that we've defined a hello object, we can define a subtype of hello called hello_too:

    hello hello_too [|
        <h1>Hello, world too.</h1>


The contents of hello_too override those of hello. Yet a hello2 can be used anywhere a hello object is expected (as a typed argument, for example), because a hello_too object is a hello object. This standard feature of object-oriented languages is called polymorphism.

In addition to overriding the contents of a type, a subtype may override the type's child definitions. A child definition is definition contained in another definition (the child's parent definition):

    hello hello3 [=
            title [| Hello World |]
            color bgcolor [| #EEDDBB |]


In this definition, title is a child of hello3. Bento definitions comprise a tree, with a special kind of definition called core at its root.

Note that the contents of hello3 are enclosed in [= and =] instead of [| and |] . [= and =] are Bento delimiters and mark a block of Bento statements; [| and |] are static delimiters and mark a block of static text.

A Dynamic Page

A Family of Pages

Integrating with External Objects

Levaraging the Power of Objects


Use of any software, source code and documentation obtained from this site is governed by the Bento Poetic License.

Copyright © 2003 by