PETAL and Perl, why must you suck?
In CSC 370 (Database Systems), our current assignment is to write a bunch of UDFs for accessing our local IMDB database, then write programs in 2 languages that display all of the information available about a single production, in HTML. This (like all assignments in this course) is a group assignment.
I chose Python, because it's what I've been using most recently and therefore it would be the easiest to write code quickly in.
One of my team members chose Perl. Ouch, but at least I'm not writing it!
I finished mine last week. I used Python, psycopg2 for PostgreSQL access, and SimpleTAL for templating (again, since TAL is what I've been using most recently and therefore would be fastest to get the job done - but also because TAL is sweet). The program is short and sweet.
In a meeting last week I demoed the program to the group. The fellow using Perl liked the TAL template made and we agreed it would be cool to reuse it for his solution. After all, PETAL is a Perl port of TAL, so why not.
He was having a lot of trouble getting PETAL to accept the data he was giving it. I decided to help him out, even though I haven't written Perl in years, 2 heads may be better than 1.
First of all: After all these years, I still hate Perl! I've never understood how people enjoy writing software with it. Then there's PETAL. I'm sorry to be rude (porting TAL to another platform is a nice thing to do), but what the hell were they smoking when they decided to change the TAL namespace from "tal" to "petal"?
Instead of the standard tal:content, tal:repeat, tal:condition, etc., as the TAL specification states, PETAL uses petal:content, petal:repeat, petal:condition! Now we need two versions of the template - one that uses tal: attributes for SimpleTAL, and one that uses petal: attributes for PETAL. A key advantage of TAL's design is being language neutral, and PETAL threw it out.
Also, the documentation and cookbooks we could find did NOT help us get the damn thing working. All we wanted to do was pass it hashes and arrays of hashes with data from SQL queries executed with DBI. But no matter which combination of stupid variable prefixes we used, it wouldn't work. How hard should it be to pass a hash containing keys to things like arrays of hashes, hashes and other simple values? In Python it's dead simple. It just works.
We ended up having to scour Google for some sample code to figure out what actually works. After a while I finally found this message to a mailing list with some DBI and PETAL code. After adapting our program to use the syntax used in that message, we got it working.
Today's lesson: Perl sucks, so I shouldn't be so surprised when Perl-based libraries don't improve the situation.