Open Source Software Technical Articles

Want the Best of the Wazi Blogs Delivered Directly to your Inbox?

Subscribe to Wazi by Email

Your email:

Connect with Us!

Current Articles | RSS Feed RSS Feed

Tea: A Disney Original Programming Language


Would you expect to write code in a language proposed by the Walt Disney Internet Group? Yep, Disney created its own language and IDE, plus several other utilities, to use in the creation and maintenance of its website, as well as others under its corporate umbrella, such as ESPN and ABC News. The Tea language owes a lot to Java, and so do the rest of the tools – for example, Beandoc converts JavaDoc comments to JavaBean comments. If you know Java, Tea will be right up your alley. If you are familiar only with languages like C++ or C#, it may take a little more getting used to.

Along with Java, the Tcl and Scheme languages have had an influence on Tea. Tea combines features that are hard to find elsewhere in a single language: support for functional programming, closures (taken from Scheme, of course), full object-oriented programming support, library autoloading facilities, and lots of core classes and functions for common functionality like networking, I/O, string processing, and XML. Support for popular DBMSes like PostgreSQL, MySQL, Oracle, Sybase, Informix or Microsoft SQL Server is included.

However, open source purists should be aware that the official Tea interpreter, unlike the other Tea tools, is proprietary, ergo so is the bytecode that results from its use. That means that you can get Tea and use it for personal projects, but for commercial use you have to ask for permission. There are alternatives, though: One is a Perl project called destea that released Language::Tea in CPAN, which generates Java code based on your Tea code. You can also try an open source compiler called TeaClipse, which unfortunately looks a bit neglected at the moment.

To get the Tea interpreter, if you choose to go that route, you can go to the project's download site and follow the usual install-from-source routine. You need a JRE installed, as well as the GNU regexp library. Optional features you may want include XML parsing, for which you need SAX, or a JDBC driver if you need database connectivity. Another very interesting project to look out for is Tea Trove, which seems better maintained than the old SourceForge project and under a more friendly license (Apache 2.0) than what we've found on PDMFC's site. I used it for this article, but that doesn't mean you can't use the other alternatives, should you wish to, because I'm interested in the language more than the tools used for it.


To get your first sip of Tea, let's start with a simple "Hello, world!" example, though it may look a bit different than what you're used to if you're familiar with Java, Tcl, or Scheme:

<% template HelloWorld(ContentObject obj) %>
Hello <% obj.message %>!

All code regions are delimited by <% and %>, and text outside those regions is printed as-is. That means another way to write this, if we wanted to use only one pair of delimiters, would be

<% template HelloWorld(ContentObject obj)
"Hello " obj.message

Tea's lexical structure is almost entirely based on Java's. Here's an example that would look familiar to developers that embed ASP or JSP code in HTML, and that illustrates how text and Tea code regions get mixed:

<% template MyTemplate(PageInfo page) %>
<html><head><title><% page.title %></title></head>
<h1><% page.heading %></h1>
<% foreach (item in page.list) { %>
<tr><td><% %></td><td><% item.desc %></td></tr>
<% } %>

Tea has just a few keywords. Its operators and separators will be familiar to those familiar with C or Java. For a complete reference, check the wiki on Github.

Practical Approaches

For a more practical demonstration of Tea's utility, let's start by declaring a template:

Template ::= TemplateDeclaration [StatementList]
TemplateDeclaration ::= template Identifier ( [FormalParameterList] ) [SubstitutionParameter]

Parameters must be delimited by commas, and each formal parameter requires a class name and a unique identifier. Object type names must be fully qualified except for those defined in the java.lang and java.util packages. The type declaration may define an array (or an array of arrays) just as in Java, using [ and ] symbols.

Templates have some resemblance to functions, in that they can return a value, and they can invoke other templates. Let's take SimpPage.tea as a first example of a template, then see how CompPage.tea calls it:

<% template SimplePage(String title, String color) { ... }
'<html><head><title>' title '</title></head>'
if (color == null) {
else {
'<body bgcolor="' & color & '">'

<% template NewsPage( story)
// Pass a title and a substitution block to SimplePage
call SimplePage(story.title, "#ffffff") {
'<h1>' story.headline '</h1>'
foreach (paragraph in story.body) {
'<p>' paragraph.body

Tea creates loops using the keywords foreach, break, and continue, and you can, as usual in other languages, combine them with if blocks if you so need. Blocks are delimited by braces, C-style. If you're not clear about the foreach keyword, imagine you need to increment each member of a list by two. So for each of those members, you just add two:

foreach (item in my.list) {

//The functionality of 'for' is created like so:
foreach (count in 1..10) {
"Count is " & count

//Same, but in reverse
foreach (count in 1..10 reverse) {
"Count is " & count

Assignments are made easy for the developer, so they don't have to worry too much about type compatibilities. Here are some examples:

Hello = "Hello, this is a string"
value = 20
newval = value + 10
newval = value + 10 as Integer

//Any text that is not inside a code block is treated as pure text, so
"Hello, world!"
print("Hello, world!")
//are equivalent

IDE support

There used to be a Kettle IDE suggested on the project's old SourceForge page, but the PDF documenting it, as all the site it seems, stopped receiving updates somewhere around 2001. I downloaded Kettle and tried to start with the .jar file. It seems it's made to work with Java 1.3, so I didn't stand a chance with the implementation that I have installed. I went looking for IDE alternatives, but Eclipse doesn't seem to directly support Tea, nor does NetBeans. In conclusion, folks, no Tea IDE for you, unless I really missed something, which is not impossible, since looking for such a common term on search engines is likely to give you more misses than interesting results.

Despite the lack of a working IDE, Tea has a pretty active community behind the language. It's interesting, easy to learn, and practical if you need a web programming language that lets you get started right away.

This work is licensed under a Creative Commons Attribution 3.0 Unported License
Creative Commons License.

This work is licensed under a Creative Commons Attribution 3.0 Unported License
Creative Commons License.


that superb points you have discussed about Original Programming Language, its really helpful for the new developers.
Posted @ Friday, March 15, 2013 2:03 AM by bahrain web development
These coding are very useful for web developers.
Posted @ Tuesday, January 21, 2014 4:25 AM by VideoJeeves
Very good stuff with good ideas and concepts, lots of great information and inspiration, both of which we all need, helpful iformation.
Posted @ Saturday, March 29, 2014 7:32 AM by
Post Comment
Website (optional)

Allowed tags: <a> link, <b> bold, <i> italics