When a Language Becomes a Platform

Develop multiplatform distributed desktops with device-independent REBOL.


March 12, 2002
URL:http://www.drdobbs.com/web-development/when-a-language-becomes-a-platform/184414510

===A sample REBOL application.

REBOL [
	Title: "A Sample Document"
	Author: "Kurt Cagle"
	Date: 12-Jan-2002
	Version: 1.1.2
]	

flash "Fetching image..."
read-thru/to http://www.rebol.com/view/demos/palms.jpg %palms.jpg
unview

content: {A Sample Document

===My Introduction

The ability to create rich wizards via easy to use text is perhaps one of the real advantages 
that REBOL offers. This, for instance, is a modified script from the initial documentation, 
where such elements as headers are indicated by elements such as the characters ===.
These are automatically parsed out by the REBOL engine into control headers.

---Inline Code

You can also introduce inline code into REBOL scripts. For instance, the following line will create a pop-up text message:

   view layout [
		text "This is a sample app!"
		button blue "With a Button"
		]

===A Second Section

Much more information can be contained within one of these documents.



}



code: text: layo: xview: none

sections: []

layouts: []

space: charset " ^-"
chars: complement charset " ^-^/"

rules: [title some parts]

title: [text-line (title-line: text)]

parts: [
	  newline
	| "===" section
	| "---" subsect
	| "!" note
	| example
	| paragraph
]

text-line: [copy text to newline newline]
indented:  [some space thru newline]
paragraph: [copy para some [chars thru newline] (emit txt para)]
note: [copy para some [chars thru newline] (emit-note para)]
example: [
	copy code some [indented | some newline indented]
	(emit-code code)
]
section: [
	text-line (
		append sections text
		append/only layouts layo: copy page-template
		emit h1 text
	) newline
]
subsect: [text-line (emit h2 text)]

emit: func ['style data] [repend layo [style data]]

emit-code: func [code] [
	remove back tail code
	repend layo ['code 460x-1 trim/auto code 'show-example]
]

emit-note: func [code] [
	remove back tail code
	repend layo ['tnt 460x-1 code]
]

show-example: [
	if xview [xy: xview/offset  unview/only xview]
	xcode: load/all face/text
	if not block? xcode [xcode: reduce [xcode]] ;!!! fix load/all
	if here: select xcode 'layout [xcode: here]
	xview: view/new/offset layout xcode xy
]

page-template: [
	size 500x480 origin 8x8
	backdrop white
	style code tt black silver bold as-is para [origin: margin: 12x8]
		font [colors: [0.0.0 0.80.0]]
	style tnt txt maroon bold
]

parse/all detab content rules

show-page: func [i /local blk][
	i: max 1 min length? sections i
	append clear tl/picked pick sections i show tl
	if blk: pick layouts this-page: i [f-box/pane: layout/offset blk 0x0 show f-box]
]

main: layout [
	across
	h2 title-line return
	space 0
	tl: text-list 160x480 bold black white data sections [
		show-page index? find sections value
	]
	h: at
	f-box: info 500x480
	at h + 456x-24
	across space 4
	arrow left  keycode [up left] [show-page this-page - 1]
	arrow right keycode [down right] [show-page this-page + 1]
	pad -120
	txt form system/script/header/date/date
]
show-page 1
xy: main/offset + 480x100
view main


when a language becomes a platform

REBOL IOS Express

by Kurt Cagle
April 2002

A distributed desktop is an idea that makes intuitive sense when you hear about it, but one that can become quite complex logistically. The desktop is more than just a file repository; it needs to be able to perform any number of activities, from providing support for window and widget APIs to protecting documents so that they can be worked on collaboratively. The desktop must be lightweight, because people are accessing the Web from devices other than just their computers. It needs to be extensible enough that people can build robust applications, yet simple enough that people don't have to be hard-core programmers to build these apps.

REBOL Technologies' Relative Expression Based Object Language (REBOL) Internet Operating System (IOS) products are an attempt to build precisely such systems. While there is certainly room for improvement, REBOL is nonetheless an impressive first foray into the problem of building a next-generation Web desktop.

REBOL is the brainchild of Carl Sassenrath, the system architect who designed the Amiga operating system more than a decade ago. This system was one of the first consumer-level multi-user systems in existence. Even now it commands a devoted following of Amiga fans, though the company that produced it dissolved long ago.

PROS
Lightweight, flexible, robust development language.

CONS
Low industry acceptance, language not yet open source.

Sassenrath envisioned REBOL as an operating system lightweight enough to be deployed anywhere, and the product is certainly making headway in this area. It currently works on more than 40 platforms including AIX, Amiga, BSD, HP/UX, Linux, Macintosh, Solaris, and Windows. As a consequence, REBOL is potentially useful as a way of deploying applications across the increasingly diverse and fragmented multi-system networks that are becoming commonplace in most businesses.

The key to Sassenrath's vision is that holy grail of contemporary distributed computing—an Internet Operating System (IOS). The REBOL IOS line is designed to create enough of a common architecture that sophisticated applications can be built easily for collaborative computing. The IOS consequently is targeted to several different applications, many of which currently exist only as distinct standalone products.

For instance, REBOL IOS makes building conferencing applications comparatively simple, using individual script components (lightheartedly dubbed Reblets) that can be tied together easily. The company offers several sample Reblets on its site. Many of the same core components can also be tied into building address lists, running real-time surveys, adding or viewing sales information as numerical tables or charts and graphics, sharing clipboard resources, and so on.

REBOL IOS isn't trying to replace the browser completely (you can embed REBOL applications within Web pages). Rather, it's intended as a way to create an easy-to-use collaborative environment that can work both independently and seamlessly with browser components. In addition, REBOL IOS supports a certain level of extensibility with other applications. It includes the ability to work with a wide array of external objects—Windows DLLs, Unix/Linux shared libraries, and so on. Because of REBOL's distributed nature, other interesting possibilities arise, such as creating a REBOL script that ties into external objects on one system and accesses them from another. REBOL can also work well with shell environments like Unix's bash shell or DOS.

REBOL IOS supports streaming for apps that use voiceover IP, MP3, video, and so on. As the company adds each new media type, it licenses the libraries and provides them on all platforms, so users on BSD or Linux can run the same apps as people on Windows.

REBOL's design is responsible for its easy deployment. The simple scripting language was designed to make network transactions transparent, with a feel that evokes both shell scripts and HTML. REBOL allows the creation of sublanguages or dialects that are handled within the general context of the main language to efficiently express semantic concepts over a network between computers, but without transmitting viruses or related problems.

Long term plans for REBOL include three distinct REBEL IOS products. REBOL IOS Express (shown in Figure 1) works in conjunction with existing Web servers to provide REBOL support, and is available both for purchase and as a demo from the REBOL site (www.rebol.com). REBOL IOS Lite includes its own server only for a company's internal use, while REBOL IOS Host provides this same service across the Internet. The latter two are still being developed.

REBOL IOS Express is an enterprise workgroup product with two parts: a server piece called REBOL Serve, and a client called REBOL Link. The product's price depends on several factors. The basic model has a per-seat client price of $100 (10 seats minimum) plus $1,000 per server. In addition, the company suggests an Alliance support package for $5,000 per year. Of course VARs, OEMs, ISPs, and large purchases are specially priced.

impressive graphics

Eye candy is important. IOS Express has sumptuous graphics, which are typically lacking in inter-system collaborative solutions. The demos that ship with even the basic product demonstrate its ability to cleanly work with graphic images. REBOL can apply a wide variety of filtering effects including the ability to blur and sharpen, apply gradient overlays, multiply image bitmaps together, and perform basic rotations on the images. In fact, REBOL was robust enough to let me create a credible Tetris game.

Because REBOL works by manipulating widgets at an abstract level, the rich graphics translated into the ability to create skins for various applications. For example, I made an input form that could then be skinned for use on the Macintosh, in Windows, and on Linux. Without knowing the origin, I wouldn't have realized that these weren't resources created expressly for the targeted platform. Such look-and-feel capabilities are, of course, part of most contemporary programming languages, but they often require a significant amount of work to pull off well. With REBOL, it was painless.

Also, REBOL scripts facilitate the easy markup of text for display, using a flow model similar to that of HTML. As a consequence, making features such as multi-page wizards becomes almost trivial. REBOL is made up of a series of objects, each of which can have one or more declarative facets applied to them. These objects include things like headline tags (h1, h2, and so on), body text, and more. The objects are then modified via facets. For instance, you can create a banner with an accompanying button using the script:

view layout [
banner "Hi, there!" white blue 
button green "Enter"
]

The view layout command is the primary interface for building dialogs and other system resources, and can be either typed into a command line or put into a REBOL script. Without knowing much more than a few basic commands, I found that I could put together a simple help system by saving a REBOL document file and reworking it in my own local folder (see Listing 1).

features

API-based Web services receive a lot of noise, but the REBOL IOS architecture shows that you can build somewhat more robust applications through declarative services. The power of REBOL Link and applications like it comes from a strong rendering engine combined with a transparent mechanism for connecting the client to the server. Instead of making remote procedure calls to retrieve data, REBOL uses a messaging architecture to retrieve the information necessary to build its core objects, along with whatever data it needs to work on.

This architecture may seem familiar. In fact, it's exactly the same way the Web itself works, except where HTML requires an HTML browser, REBOL uses its own engine to interpret and display REBOL script language. This document-oriented approach also means that the application doesn't necessarily have to reside on the client. You can create applications that are accessible from a centralized server, and because of the text nature of REBOL the applications can be individually customized for each user or customer.

REBOL supports an extensive set of protocols, including the ability to work across FTP, HTTP, NNTP, POP, SMTP, TCP, and UDP. Thus, you can use REBOL to create both an email server and an email client. Perhaps you can even create a newsgroup reader that extracts the contents and converts them into both POP protocol format and HTML pages across HTTP.

REBOL can also make calls out to Web browsers for additional display and to redirect content from HTTP calls, filtering information in or out as appropriate. That means REBOL can act as an intermediate Web server, loading in data (like XML files) and performing localized transformations on that data before sending it on to the browser.

room for improvement

There are a few deficiencies in the product, but these shouldn't keep people from trying it out. However, these problem areas do indicate that the product has room for improvement.

The default editor that comes with REBOL (again, written in the language) is woefully underpowered, though it's easy enough to edit REBOL documents with other text-based editors. I don't believe that the poor quality of the editor represents a language limitation. If it does, it could seriously undermine REBOL's efficacy as a collaborative environment. Yet, because you have the option to use another default editor, you can use whatever you're most comfortable with.

The REBOL library is fairly robust, but it also has a sophisticated extensibility model that lets users develop Reblets to access almost any external library procedure. This comes at the cost of some portability, which is often a reasonable trade-off.

Similarly, for a language that is so tied to a declarative model, it would be useful to have filters for creating XML versions of REBOL scripts. This shouldn't be difficult to do. It could be written in REBOL in all likelihood. What's more, the lack of a built in XSLT resource dulled the shine on this product slightly, though again this could be implemented via external function calls to a command line XSLT processor written in Java or C++. Carl Sassenrath says that sometime this summer he's partnering with another company that has a good XSLT processor. He couldn't provide further details, but did say that it's the fastest existing XML implementation.

According to Sassenrath, another complaint he hears often is that REBOL isn't open source. The scripts are open source, but the system itself is not. Sassenrath says that the company plans to release the system one day, but that it needs to age a bit more. "While we control it, we can give 100 percent confidence that a script you write on one machine will run on any other machine. Once we open it, that will start to fade." Strangely enough, this hasn't proven to be a problem for the many other languages that have been released openly.

wrapping it up

The REBOL IOS is still evolving. There are several places where a more complete script library would make up for the limitations imposed by the language itself. REBOL IOS's declarative language system gives it an advantage, however, in that these aren't crippling limitations, the way they might be with a compiled language. Declarative models become increasingly robust over time as people use them, while procedural code tends to go out of date or become dependent upon large (and usually expensive) overhauls from iteration to iteration.

REBOL is exciting. In several respects it points to a different future for application development than the large hierarchical programming systems like Microsoft's .Net, or Sun's Java. It extends the HTML browser metaphor to a mode where applications can reside across many different systems, yet stay very lightweight and flexible. REBOL lets you create programs without possessing extensive coding experience. It's a language that should only become richer over time.


Kurt is an author, trainer, consultant, and researcher who specializes in XML-based technologies. He's also president of Cagle Communications. You can contact him at [email protected].

Terms of Service | Privacy Statement | Copyright © 2024 UBM Tech, All rights reserved.