[Home] [Credit Search] [Category Browser] [Staff Roll Call] | The LINUX.COM Article Archive |
Originally Published: Monday, 13 August 2001 | Author: Nile Geisinger and the BlueBox Team |
Published to: develop_articles/Development Articles | Page: 3/3 - [Printable] |
An Introduction to Word Oriented Programming with BlueBox
Exciting new open source projects are growing every day. Here
at Linux.com we're delighted to bring them to your attention, especially
projects like BlueBox, a program that introduces the concept of a linkable
programming unit. These structures, known as words, can
be published on the Internet and linked together to create richer
software. Words have the same potential for growth as the Web since anyone
can extend software published on the Internet simply by creating new words
that link to it. The BlueBox team wrote this weeks feature article
just for Linux.com readers, so read on and get involved!
|
<< Page 3 of 3 | |
Posting it on the InternetWe now have a small set of chemistry words. Each of these words is a discrete entity that can be linked to other words to form more powerful programs. Let's take advantage of that linkability now and post our sample chemistry language on the Internet. To do this, copy the reaction, atom, molecule, subscript, addition, production, and number words to a test directory on your webserver. Once the words are on published on the Internet, documents written in those words can be posted on the Internet and BlueBox will understand them. To load the words into BlueBox, type:
Bluebox can now run any balanced equation document. In the future, BlueBox will automatically download the words it needs to understand a document from the Web and eliminate the process of user interaction. A user, for example, will request a document from http://www.dloo.org/examples/balancedequation.txt and all of the words needed to run it will be downloaded with the document. In this way, users will browse through software with the same ease and transparency they browse the Web. How to Add to the Language through Inheritance, Polymorphism, and LinkingAs our language stands, it does not have any atoms. Never fear! Since it is on the Internet and words are polymorphic, a third party can extend the language by linking to it. A chemist, for example, that wanted to extend the language to include all of the atoms in the periodic table could do so without ever talking to the original creator of the Chemistry language by posting new words that link to the Atom word. The Molecule word would then polymorphically match words that inherit from Atom wherever it matched Atom. The chemist could post Hydrogen: <?xml version="1.0"?> <word:word xmlns:word="<a href= "http://www.dloo.com">http://www.dloo.com</a>" > <!-- Specify the Match to match against--> <word:symbol name="Hydrogen"> <word:match matcher="absregex" expression="H"></word:match> </word:symbol> <word:inherits> <word:inherit><a href= "http://yoursite/Atom.word">http://yoursite/Atom.word</a> </word:inherit> </word:inherits> <word:definition> <word:method name="start" > <word:access></word:access> <word:code href="Python" > self.numberOfElectrons = 2 self.numberOfPositrons = 2 self.numberOfNeutrons = 2 </word:code> <word:return> <word:variable></word:variable> </word:return> </word:method> </word:definition> And Chlorine: <?xml version="1.0"?> <word:word xmlns:word="http://www.dloo.com" > <!-- Specify the Match to match against--> <word:symbol name="Chlorine"> <word:match matcher="absregex" expression="CL"></word:match> </word:symbol> <word:inherits> <word:inherit><a href= "http://yoursite/Atom.word">http://yoursite/Atom.word</a> </word:inherit> </word:inherits> <word:definition> <word:method name="start" > <word:access></word:access> <word:code href="Python" > self.numberOfElectrons = 17 self.numberOfPositrons = 17 self.numberOfNeutrons = 18 </word:code> <word:return> <word:variable></word:variable> </word:return> </word:method> </word:definition> And so on ... A third-party would then be able to download all of the original Chemistry words plus the new atoms that link to them and have a language that automatically balances equations with all of the new atoms. When the Molecule word is matched in the original language, it will polymorphically match all of the words that inherit from Atom wherever it matches Atom. Word languages can also be extended by directly linking to existing words in abstract regular expressions. A chemistry high school teacher, for example, might want to use the language in a different way: to grade homework papers. To do so, he could create a Problem word and a Chemistry Test word. The Problem word would link to the Reaction word and the Chemistry Test word would contain any number of "Problem" words. Here's the Problem word. It matches the problem number plus an equation. <?xml version="1.0"?> <word:word xmlns:word="<a href= "http://www.dloo.com">http://www.dloo.com</a>" > <!-- Specify the Match to match against--> <word:symbol name="Problem"> <word:match matcher="absregex" expression="[0-9]*\)\s*{#Reaction}"/> </word:symbol> <word:definition> <word:method name="start" > <word:access></word:access> <word:code href="Python" > self.answer = 0 </word:code> <word:return> <word:variable name="self.balanced"></word:variable> </word:return> </word:method> <word:method name="parsing" > <word:access></word:access> <word:code href="Python" > reaction = self.getFirstWord() self.answer = reaction.isBalanced() </word:code> <word:return> <word:variable name="self.balanced"></word:variable> </word:return> </word:method> <word:method name="getAnswer" > <word:access></word:access> <word:code href="Python" > </word:code> <word:return> <word:variable name="self.answer"></word:variable> </word:return> </word:method> </word:definition> The ChemistryTest word matches any number of Problem words, sums up the correct answers, and prints the students score. <?Xml version="1.0"?> <word:word xmlns:word="<a href= "http://www.dloo.com">http://www.dloo.com</a*gt;" > <!-- Specify the Match to match against--> <word:symbol name="ChemistryTest"> <word:match matcher="absregex" expression="(\s*{#Problem}\s*\n*)*"/> </word:symbol> <word:definition> <word:method name="parsing" > <word:access></word:access> <word:code href="Python" > self.score = 0 numberOfProblems = 0 currentProblem = self.getFirstWord() while (currentProblem != None): numberOfProblems += 1 self.score += currentProblem.getAnswer() currentProblem = currentProblem.getNextWord() print "Student scored", self.score,"out of", numberOfProblems,"problems." </word:code> <word:return> <word:variable name="self.balanced"></word:variable> </word:return> </word:method> </word:definition> Like the chemistry language itself, the chemistry test can be extended by third parties on the Internet. Other teachers could then inherit from the Problem word and create additional problems that students could be tested on in addition to balanced equations. The ChemistryTest word would then polymorphically match the new types of Problems that inherit from the Problem word to create a richer test with several types of problems. By endowing coded information with the same properties that made the Web so successful, it is possible to create a Web of software with the same potential for growth. The atoms and chemistry examples illustrate how software written in words can become scalably richer through linking. Like Web pages, the value of the chemistry language is not in itself, but in the network of words it resides in. ConclusionInternet-defined languages can have a significant impact on the evolution of the Internet. The Internet is defined by shared standards. By changing the way that standards can be defined and and creating a technology where standards can be extended by anyone on the Internet, the speed at which Internet technologies evolve can be greatly accelerated.
In this picture of the Internet, standards are not implemented by committees, but dynamically defined by hundreds of people around the world, and then downloaded and assembled by a word compiler. To talk with another person or to understand a document that they have written, you don't have to write a specialized compiler, just dynamically download the discrete words that define the language being used. Since the core of the Internet consists of the standards (TCP/IP, SMTP, NFS, etc.) and its higher level languages (HTML, DHTML, Javascript, XML, RDF, etc.), this is a radically different vision of how the Internet can evolve. Call for participation: The open source community has always led in defining the languages and standards that make up the Internet. Word-oriented programming transforms the process by which the Internet is defined from being top-down by committee to bottom up by developers. Join us in bringing about this transformation. To participate, subscribe to the mailing list, learn more about word-oriented programming, and download the source. More information on Bluebox, including the BlueBox source and examples, can be found at http://www.dloo.org.
| |
<< Page 3 of 3 |