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.


19a98812-f823-48dc-841e-bf029c63c6d7

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>
<body>
<h1><% page.heading %></h1>
<table>
<% foreach (item in page.list) { %>
<tr><td><% item.name %></td><td><% item.desc %></td></tr>
<% } %>
</table>
</body>
</html>


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:




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

//CompPage.tea
<% template NewsPage(org.news.NewsStory 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) {
item+=2
}

//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!"
//and
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.

Comments

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 http://11lv.co.uk
Hi . . . I like your commenting platform really I like your work with deeply, Thanks for providing us these unique guidelines it's actually helpful for each person. This website is excellent. 
Online GED Diploma
Posted @ Monday, August 18, 2014 5:58 AM by Accredited GED Diploma
I like your commenting platform really I like your work with deeply replica watches
Posted @ Wednesday, September 03, 2014 10:50 PM by klaos
true religion jeans men 
ralph lauren 
fitflop outlet 
coach factory outlet 
fitflop footwear 
ralph lauren outlet 
louis vuitton bags 
prada shoes 
louis vuitton handbags 
michael kors bags 
fitflops clearance 
louis vuitton speedy 
cheap jerseys from china 
cheap louis vuitton 
air jordan shoes 
christian louboutin sale 
tory burch flats 
hollister outlet 
red bottom shoes 
louis vuitton outlet store 
fendi purses 
joe abercrombie 
cheap jerseys 
louis vuitton purses 
michael kors outlet 
oakley sunglasses wholesale 
louis vuitton purses 
celine bag price 
louis vuitton belt 
louboutin shoes 
jordan for women 
louis vuitton 
gucci outlet store 
mont blanc pens 
abercrombie 
coach outlet store online 
crossfit workouts 
ab workouts 
ray ban sunglasses wholesale 
louis vuitton shoes 
jordan 13 
coach factory online 
louis vuitton outlet 
coach factory outlet online 
jordans for sale 
burberry scarf 
true religion sale 
kate spade outlet 
oakley sunglasses wholesale 
kate spade handbags 
ray ban sunglasses outlet 
toms outlet 
fitflop footwear 
louis vuitton outlet 
jordan shoes 
tory burch outlet 
michael kors outlet stores 
jordan retro 
toms shoes 
jordan shoes 
louis vuitton 
mont blanc legend 
hollister clothing 
toms sale 
prda outlet 
fitflop outlet 
toms shoes outlet 
celine handbags 
coach factory outlet 
chi flat iron 
juicy couture outlet 
fendi 
toms wedges 
michael kors outlet online 
coach factory online 
coach outlet stores 
louis vuitton belts 
louis vuitton outlet 
ray ban glasses 
louis vuitton sunglasses 
nfl jerseys 
prada bags 
juicy couture perfume 
gucci shoes 
kate spade 
toms shoes 
abercrombie and fitch 
coach factory outlet 
ray ban sunglasses 
bottega veneta bags 
michael kors outlet online 
trye religion outlet 
cheap ray bans 
juicy couture 
michael kors handbags 
louis vuitton wallet 
burberry handbags 
louis vuitton usa 
louis vuitton speedy 
tory burch outlet online 
michael kors handbasg 
p90x workout schedule 
tory burch shoes 
fitflops online 
coach outlet store online 
toms shoes sale 
michael kors backpack 
coach factory online 
hair dryer 
true religion outlet 
chanel online shop 
hermes birkin 
mont blanc fountain pen 
true religion 
fitflop shoes 
gucci handbags 
jordan shoes 
nfl jerseys wholesale 
marc jacobs 
red heels 
chanel handbags 
michaelkors outlet store 
hermes belt 
christian louboutin  
workout plans 
coach outlet 
coach factory outlet 
louis vuitton handbags 
coach factory outlet 
oakley suglasses cheap 
polo ralph lauren 
ray ban outlet 
workout routines 
louis vuitton purses 
louis vuitton handbags 
ray ban aviators 
michael kors handbags 
hollister co 
coach outlet store online 
true religion 
fitflops clearance 
mont blanc pens 
kate spade purses 
christian louboutin outlet 
christian louboutin outlet 
ray bans 
michael kors outlet store 
kate spade factory outlet 
gucci outlet 
oakley sunglasses 
fitflops 
oakley outlet 
kate spade outlet online 
cheap jordans 
red shoes 
red bottoms 
bottega veneta handbags 
chanel bags 
true religion jeans outlet 
jordan sneakers 
official coach factory outlet 
celine paris 
christian louboutin shoes 
louis vuitton purses 
coach outlet 
nfl jerseys 
louis vuitton outlet 
christian louboutin 
celine outlet 
fendi bags 
cheap toms 
hermes bracelet 
coach factory 
michael kors outlet 
burberry bags 
true religion jeans 
louis vuitton officail website 
cheap nfl jerseys 
gucci bags 
michael kors outlet online 
burberry outlet 
true religion outlet 
cheap jordan for sale 
bottega veneta 
true religion jeans 
cheap jordans 
tory burch outlet 
mont blanc legend 
true religion jeans outlet 
michael kors outlet 
viva la juicy 
ray ban wayfarer 
mont blanc mountain 
toms promo code 
nfl football jerseys 
insanity workout 
abercrombie fitch 
louis vuitton outlet 
louis vuitton handbags 
louisvuitton 
tory burch handbags 
hollister promo code 
tory burch outlet online 
fitflop shoes 
true religion jeans 
celine luggage tote 
louis vuitton 
michael kors purses 
hermes outlet 
oakley sunglasses 
ray ban outlet stores 
fitflop sale 
louis vuitton outlet 
louis vuitton handbags 
louis vuitton bags 
michael kors factory outlet 
chanel outlet 
cheap jerseys 
hermes delivery 
michael kors outlet stores 
louis vuitton backpack 
coach factory online 
ray bans 
louis vuitton outlet 
louis vuitton outlet 
tory burch shoes 
louboutin 
ray ban sunglasses 
chi straightener 
coach factory outlet online 
kate spade handbags 
louis vuitton neverfull 
coach outlet 
coach outlet store online 
hair straightener 
coach factory outlet 
kate spade 
marc jacobs handbags 
louis vuitton purses 
coach outlet 
ray ban sunglasses 
cheap ray ban sunglasses 
used louis vuitton 
louis vuitton handbags 
trye religion outlet 
louis vuitton bags 
louis vuitton outlet stores 
louis vuitton uk 
coach outlet 
official coach factory outlet online  
fendi outlet 
louis vuitton outlet 
ray ban outlet 
oakley outlet 
prada handbags 
cheap oakley sunglasses 
toms outlet 
marc jacobs outlet 
louis vuitton wallet 
louis vuitton 
oakley glasses 
kate spade outlet 
louis vuitton  
tory burch flats 
fitflop sandals 
jordan 11 
coach outlet 
hollister kids 
true religion outlet store 
cheap nfljerseys 
ralph lauren home 
coach factory online 
bottega veneta outlet online 
cheap oakleys 
www.louisvuitton.com 
mont blanc fountain pens 
football jersey 
michael kors outlet 
mont blanc pen 
trye religion outlet store 
christian louboutin shoes 
true religion jeans outlet 
christian louboutin sneakers 
michael kors handbags 
mont blanc pen 
louis vuitton outlet stores 
michael kors handbags 
jordan retro 
designer handbags 
louis vuitton outlet store 
coach factory  
coach factory 
fitflop sandals outlet 
bottega veneta outlet 
cheap true religion jeans 
fendi handbags 
kate spade outlet store 
abercrombie and kent 
michael kors outlet 
louis vuitton handbags 
marc by marc jacobs 
chi hair straightener 
true religion jeans 
cheap jordans 
louis vuitton purses 
fitflop outlet 
michael kors outlet online 
polo outlet 
louis vuitton bags 
Posted @ Thursday, September 11, 2014 9:39 PM by dongdong25
ralph polo outlet, michael kors outlet, louis vuitton online, juicy couture outlet, jordan 3, Ralph lauren Polo, iphone cases for 5S, louis vuitton online outlet, ralph lauren outlet, toms online, air jordan shoes, Tiffany co Bracelets, north face outlet, wholesale nfl, north face outlet, louis vuitton online store, ralph lauren outlet, ralph lauren polo outlet, toms outlet store, new york, Ralph lauren men, north face outlet, ralph lauren coupon, cheap nfl jersey, cheap toms, north face outlet, louis vuitton outlet online, louis vuitton outlet, toms on sale, wholesale jerseys nfl, ralph lauren outlets, north face outlet, ralph lauren clothes, toms outlet online, polo shirts for women, iphone cases for 5, abercrombie outlet, Hollister Online Shop, jordan 11, ralph lauren polo women, Cheap North Face, Hollister Jeans, tiffany wedding rings, mens ralph lauren, tiffany rings, tiffany lamps, outlet polo ralph lauren, toms outlet, ralph lauren for code, Ralph Polo, Seattle Seahawks outlet, Seattle Seahawks jersey, gucci outlet store, ralph lauren pony, polo shirts ralph lauren, gucci outlet, north face outlet, tiffany alvord, hollister california, michael kors outlet, louis vuitton outlet store, north face outlet, toms promo code, iphone cases for 5C, ralph lauren promo code, louis vuitton online, wholesale toms shoes, jordan outlet, north face outlet, ralph lauren outlet, north face denali, toms outlet, gucci outlet online, ralph lauren outlet online, iphone 5C cases, cheap ralph lauren polo, ralph lauren outlet, louis vuitton Mini, ralph lauren coupon, iphone cases 5, ralph outlet, nfl store, north face outlet, toms shoes online, polo sale, nfl shop, toms outlet, ugg outlet, ralph lauren t shirt, wedding jewelry, iphone cases, iphone cases, shop Ralph lauren, toms outlet, ralph outlet, north face outlet, ralph lauren cheap, toms on sale, nfl jersey, toms outlet, iphone cases 5, ralph outlet, toms shoes outlet, north face outlet, north face outlet, toms outlet, louis vuitton Damier, ralph lauren shop, north face sale, women polo shirts, uggs outlet, north face outlet, iphone cases 5S, toms coupon codes, Hollister Outlet, Tiffany co Bangles, jordan 4, ralph lauren black, nfl outlet, michael kors store, michael kors outlet, polo lauren outlet, michael kors outlet, tiffany outlet, iphone cases 5C, wholesale toms, iphone 4 cases, the north face outlet, toms wholesale, iphone 5 cases, tiffany outlet, clothing ralph lauren, ralph lauren outlet, louis vuitton Monogram, polo shirts for men, ralph lauren factory store, north face outlet, ralph lauren online, north face outlet, louis vuitton outlet, polo ralph lauren store, Ralph Lauren Outlet, polo online, north face outlet, louis vuitton Monogram, cheap ralph polo, tiffany engagement rings, michael kors online, polo shirts men, ralph lauren store, louis vuitton outlet online, north face for sale, nfl jersey sale, juicy couture outlet, tiffany jewelry, polo ralph lauren outlet, Ralph lauren women, ralph lauren for cheap, iphone cases 5S, iphone 5S cases, silver jewelry, ralph polo, louis vuitton Leather bags, polo outlet, ralph lauren outlet, iphone 5 cases, tiffany outlet, iphone 5 cases, gucci outlet, jordan 6, polo store, juicy couture outlet, polo lauren, uggs on sale, ralph lauren coupon code, Ralph Lauren Outlet, north face outlet, polo ralph lauren men, ralph polo, nfl jerseys, ralph lauren polo shirts, north face sale, iphone 5C cases, Hollister Clothing, ralph lauren home, iphone 5S cases, iphone cases for 5C, ralph lauren outlet, tiffany outlet, polo outlet online, louis vuitton store, Seattle Seahawks sale, buy nfl jersey, the north face outlet, north face outlet, iphone cases for 5, ugg boots on sale, Seattle Seahawks online, blue ralph lauren, toms online store, iphone cases 5C, iphone cases for 5S, north face outlet, north face outlet, wholesale nfl jerseys, toms outlet, tiffany necklace
Posted @ Wednesday, October 15, 2014 12:30 AM by aa
Good publish. I just became aware of your site and planned to claim of which I’ve really enjoyed surfing around your site threads. 
Posted @ Wednesday, October 22, 2014 7:45 AM by ThredUp Coupons
Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

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