- REBOL
Infobox programming language
name = REBOL
paradigm = multi-paradigm
year =1997
designer =Carl Sassenrath
developer = REBOL Technologies
latest_release_version = Core 2.7.6, View 2.7.6
latest_release_date = March, 2008
typing = dynamic, strong
implementations =
dialects =
influenced_by = Self, Forth, Lisp, Logo
influenced =
operating_system =Cross-platform
license = freeware, commercial, open mezzanine,closed source
website = http://www.rebol.comREBOL, the Relative Expression Based Object Language (pronounced ['reb-ol] ), is a proprietary,
closed source data exchange and programming language designed specifically for network communications anddistributed computing . Its designer,Carl Sassenrath , calls it a 'messaging' language, and says: "The main idea of REBOL is that it gets used for: server, client, communications between them, and storage on them. The power of REBOL comes from its unique integration of programming language concepts and meta-data language concepts. The ultimate goal of REBOL is to provide a new architecture for how information is stored, exchanged, and processed between all devices connected over the Internet. It [REBOL] is meant to be used for the semantic exchange of information between people and machines."History
First released in 1997, REBOL was designed over a 20 year period by
Carl Sassenrath , the architect and primary developer ofAmigaOS , based on his study ofdenotational semantics and using concepts from the Lisp, Forth, Logo, and Self programming languages.REBOL/Command, which added strong encryption and ODBC access, was released in September 2000.
REBOL/View was released in April 2001, adding graphical capabilities on top of the core language.
REBOL/IOS, an extensible collaboration environment built with REBOL was released in August 2001.
The REBOL SDK, providing a choice of kernels to bind against, as well as a preprocessor, was released in December 2002.
REBOL 3, the newest version of REBOL, is currently in development. Alpha versions are being released publicly since January 2008.
Programming
REBOL is a high-level, interpreted, multi-platform, multi-paradigm, dynamically reflective, symbolic programming language. It is also strongly homoiconic—meaning that code and data have the same representation—making it very suitable for
metaprogramming .It supports structured, functional, and prototype-based programming. REBOL is not a pure functional language;
imperative programming is supported by using functions with side-effects. It is also not a pureobject-oriented language , having non-object datatypes and support for otherprogramming paradigms . REBOL is particularly well suited forLanguage Oriented Programming ; more specificallyDialecting .REBOL is dynamic, and dynamically typed (values are
strongly typed , variables are not). It uses garbage collection formemory management , and supportsexception handling anddynamic name resolution (through [http://www.fm.tul.cz/~ladislav/rebol/contexts.html computed binding] ).Data definition and exchange
To support its use as a data exchange language, REBOL has minimal syntax with the following properties:
* There are no statements; expressions are the primary semantic unit.
* There are no keywords
* It is punctuated using only whitespace and [ ] ( ) " { } as delimiters
* There is a wide range of native datatypes, many of which are defined by their lexical form. (see below)As a data language, REBOL has strongly typed values; it supports more than 30 native data types. As in many programming languages, there are basic values like integers, decimal numbers, and strings. REBOL extends the range of datatypes identified by their lexical form to include values such as email addresses (name@host.dom), URLs (http://www.rebol.com), markup tags (<b>, <font size="2" color="blue">), money values ($100.00, USD$25.25), dates (30-Nov-2005, 1-Dec-2005/10:30-7:00), times (12:00:00), coordinate pairs (5x5), tuples (255.255.255, 192.168.100.1), and words (how are you?). These datatypes use lexical forms familiar to many non-programmers to facilitate its use as a data exchange language. REBOL's main data structure, used for grouping values, is a "block!", which is somewhat comparable to a "list" in Lisp.
Implementation
The REBOL interpreter is available in several editions (/Core, /View, /Command, /Base, /Face and /Pro). At the time of this writing the /Core version, which is a subset of all other versions except /Base, was available for 43 platforms.
The source code of the REBOL interpreter is proprietary. Both REBOL/Core and REBOL/View have been made available for producing distributable commercial applications at no charge. Extended editions, such as REBOL/Pro, still require a paid license; they add features like ODBC data access, the ability to use dynamic link libraries, and the option to create standalone EXE files.
The runtime environment is currently stored in a single executable file. REBOL/Core, the console edition, is about 300kB and REBOL/View, the
graphical user interface edition, is about 650kB in size. Application scripts are rarely more than a fewkilobyte s, so you can fit the interpreter and scripts on a singlefloppy disk , send application scripts in email messages, or run them over theInternet .It contains support for many Internet protocols, making it easy to write internet applications such as
electronic mail agents or web applications.REBOL/View provides platform-independent graphics and sound access, and comes with its own windowing toolkit and extensible set of styles (UI widgets). With it, you can build distributed GUI applications. Due to REBOL's dialecting model, it is a lightweight solution for developing x-internet applications.
The REBOL community is linked through a "REBOL desktop", a graphical representation of REBOL-related files stored on the Internet that is installed together with the REBOL interpreter. The REBOL desktop itself is an
open source REBOL application.Examples
In the console, you can just type:
print "Hello World!" A cross-platform GUI version could be done like this:
REBOL [ Title: "Hello World in a Window" File: %hello-view.r Date: 12-January-2002] view layout [ text "Hello world!" button "Quit" [quit]
And here is a simple internet application that uses two internet services,
HTTP andSMTP :REBOL [ Title: "Web Page Emailer" File: %sendwebpage.r Date: 12-January-2002 Purpose: "Get an HTML document from the web and send it through e-mail"] send branko@collin.example read http://www.rebol.com
The Header section, beginning with the word Rebol, is required in scripts so the interpreter knows where the script begins. The header need comprise only
REBOL []
; however, good practice encourages a verbose, descriptive header such as shown in the examples.Dialects
REBOL is a context dependent language that provides support for domain-specific sublanguages called dialects. An example of REBOL's context sensitivity can be seen with the word "return". Under 'normal' evaluation, "return" exits a function passing back a result value. In the context of the "Visual Interface Dialect" (VID), an occurrence of the word "return" causes the layout engine to simulate a
carriage return , moving the "rendering pen" down to the beginning of the next line. REBOL programmers can create their own dialects, reusing any existing REBOL word and giving it a different meaning in the context of that dialect.Dialects are usually implemented by functions processing REBOL blocks in a specific way (string processing can be used too, see examples below). Similarly, as with other functions, we can discern native dialects (implemented by native functions) and dialects written in REBOL.
Dialect examples:
*do dialect - this is the 'normal' REBOL as the do function 'understands' and interprets it (native)
*reduce dialect - a modification of the do dialect collecting the results (native)
*compose dialect - a modification of the reduce dialect evaluating parens only (native)
*"function spec" dialect - a dialect used for function header specification (native)
*parse dialect - a tool to specify BNF-like grammar parsing rules (native)
*"VID" - a dialect specifying Graphical User Interface, implemented as a layout function (mezzanine)A user can create dialects using any REBOL functions, but reduce and compose functions are better suited than other functions and the parse function is specifically optimized for that purpose.
The parse function's purpose is to analyse and interpret dialects by specifying
parsing expression grammar rules in a BNF-like format, much as you would for aparser building tool likeyacc orGNU bison . The rules are interpreted by REBOL at runtime. Actions can be included to be taken during the parsing process as well.The parse function can be used to process REBOL blocks or REBOL strings.
Using parse against a string allows for near-complete flexibility, but requires more effort, as it is a lower level approach. "Block parsing" makes it easier to create dialects, but there is a tradeoff. In block parsing mode, REBOL handles the lexical scanning for you and your rules are written at the level of REBOL values, not characters and
delimiter s. The up-side to this is that you can write your rules at a much higher level ofabstraction , but your data must fit within the standard REBOL lexical form.Grammar rules
The rules you feed to the "parse" function are, themselves, written in a dialect of REBOL. When parsing strings, a subset of REBOL
datatype s can be used in rules; in block parsing mode, all REBOL datatypes can be used along with some other features that make building sophisticated dialects easier.tring parsing example
This first example will parse a string, looking for some specific words, and copying parts of the data out which are variable, and that may be used elsewhere. In this example, all the parts copied from the string are, themselves, strings.
strings: [ "write Graham a thank-you note" "send Allen the new source code"] foreach string strings [ print string ; Our rules go in a block, enclosed by square brackets parse string [ ; Each string should start with one of these words. COPY will ; copy the text of interest so we can use it later. copy how ["write" | "send"] (print ["How:" how] ) ; Now, copy everything up to the next space, which should ; then be followed by either "a" or "the". We use parenthesis ; to define actions to take when a rule succeeds. copy who to " " ["a" | "the"] (print ["Who:" who] ) ; Finally, copy everything to the end of the string. copy what to end (print ["What:" what] ) ] print ""]
Consider the final line of the "parse string" block. "copy what" means copy the text from the current parser position ( after "a" or "the" ) and assign it to the arbitrary variable "what" .. and since the dialect specifies "to end", this means to copy everything to the end of the string. So, "what" has the value "thank-you note" for the first string, and "new source code" for the second.
Print ["What:" what ] will output:
What: thank-you note
What: new source code
Block parsing example
Let's say you have a file analysis utility, and you want to provide an easy way for users to specify which files to operate on, what times to run it, where to post the results, and who to notify. A dialect could be used to provide a flexible text-based interface for this kind of task.
The dialect allows for multiple items, alternate word orders, and optional words that a person might include for readability, but which shouldn't affect the program's operation.
Here are two sets of commands users might send to the app:
command-blocks: [ [ analyze %test-1.txt %test-2.txt post results to http://www.wikipedia.org/results.dat notify rebol-xyz@wikipedia.org at 10:00 and again at 10:00pm ] [ at 10:00 and at 10:00pm analyze %test-1.txt notify rebol-xyz@wikipedia.org and reb-guy@wikipedia.org post to ftp://wikipedia.org/results.dat ] ; Words that have an apostrophe before them are literal words we want to match.; Words that end with an exclamation are datatypes we want to match.; SOME means "one or more". Like "+" in a regexp.; OPT means optionally, i.e. "zero or one".; SET causes a word to refer to the value matched for later use; like setting; a variable.
foreach block command-blocks [ print mold block parse block [ some [ ['analyze some [set file file! (print file)]
['notify some [set who email! opt 'and (print who)]
['at set when time! (print when)]
['post opt 'results 'to set target url! (print target)]
'again
'and ] to end ] print ""]In the example above, the file, email, time, and url values are all native datatypes in REBOL, so the values extracted during the parse operation could be directly applied in REBOL expressions. For example, the "who" value could be used with the "send" function to send email notifications, and the "url" value with the "write" function to post the data.
ee also
* Boo - a language with similar objectives but targeting the
Common Language Infrastructure
* XL, a compiled language with similardialecting capabilitiesExternal links
* [http://www.rebol.com REBOL Technologies] - for the official downloads
* [http://www.rebol.org REBOL Script Library] - for a collection of instructive examples
* [http://www.plain.at/vpavlu/REBOL/tutorial/ REBOL Essentials] - for a concise introduction to the language
* [http://www.rebol.com/cgi-bin/blog.r Carl Sassenrath's REBOL blog] - for developer notes and development plans
* [http://www.rebol.net/cgi-bin/r3blog.r Carl's Rebol 3.0 blog] - for announcements and discussion about the forthcoming release
* [http://rebolweek.blogspot.com REBOLWeek] - for news of the REBOL community, and latest releases
* [http://babelserver.org/rix RIX - the Rebol IndeXer] - a search engine registering only sites containing the word «rebol»
* [http://musiclessonz.com/rebol_tutorial.html Rebol Programming for the Absolute Beginner] - tutorial
* [http://sguish.wordpress.com Italian blog talking about Rebol & co. / Blog italiano dedicato a Rebol] - tutorials, code snippets, tips & tricks, etc...
* [http://www.pointillistic.com/open-REBOL/moa/steel/liquid/index.html Liquid Rebol] for datafow programming in Rebol
* [http://www.dobeash.com/rebgui.html RebGUI] UI framework for Rebol
* [http://www.codeconscious.com/ codeconscious] Rebol site with code and tutorials
* [http://www.rebol.it/romano/ utilities] for Rebol developers
* [http://www.rebolforces.com/ rebolforces] community
* [http://www.musiclessonz.com/rebol_tutorial.html A tutorial] for beginners
* [http://premshree.livejournal.com/57020.html Yahoo web service] example in Rebol
* [http://c2.com/cgi/wiki?RebolLanguage Rebol] article at c2.com
* [http://www.safeworlds.com/notes/rebol.html altME.com] as a safeworlds.com site in Rebol
Wikimedia Foundation. 2010.