Archive for February, 2006

Template-Lite

Sort of linked to my last entry, the guys over at Smarty have stirred something up of a hornet’s nest with their trademarking of the “Smarty” name. As an open source project its fine for them to do so, but of course we free loading lovers don’t like the thought. More relevantly the developer of Smarty-Lite was recently forced as a result to stop using the term “Smarty” in their library.

One day I’m going to find a trademark database and figure out how a common use phrase evaded trademarking before now… I could have sworn it was a registered trademark at the very least in the US and for a non-related company. One assumes the Smarty copyright holders did perform a database search.

Anyways, in one of those obscure lengthy possibly illegible blog posts (just kidding), Panama Jack got around to posting a link to the Smarty-Lite followup renamed Template-Lite that he will be developing. The Template-Lite website announces the release of version 1.0.0 since February 17th. Really someone should have blogged this earlier! Main point is it uses around half the memory of Smarty and operates faster as a result.

I haven’t tested it myself, just got curious and poked around in the code. A few items of note. It’s a put together very well, so little wonder its using less memory – most of the Smarty bloat has been excised. I did note it was missing the “assign_by_ref()” method, and escapes using htmlspecialchars() – not htmlentities(‘string’, ENT_QUOTES, ‘UTF-8′) as is best practice (charset being variable obviously).

The first is likely an easy addition – would be a good one too since I do a spot of referencing in my View layer for QSE, and developers with dangerously large arrays don’t like copying them all over the place. I don’t use Smarty’s escaping mechanism so it doesn’t bother me – template designers however will. Not entirely certain what Smarty does for escaping…

I think I’ll try this out over the next few days and figure out how much memory it actually saves me.

An aside:

Just on the Smarty trademark notices and copyrights in general. Whoever wrote that crap should buy an English dictionary and look up the the term “clarity” before touching a keyboard again. Most of the terms are vague and one talks about limiting permissions covered by Fair Use (it reads that way at least). Whole page stinks of corporate bluster. I think I see what may irk people…

What in God’s name does this mean? Have I broken copyright law by opening their homepage? Is the public banned from viewing graphical and layout elements? C’mon guys, at least hire a lawyer to write this stuff.

The rights specified above to view, download and print the documents and information available on this Site are not applicable to the graphical elements, design or layout of this Site.

Go hop, I own a printer and you let me download your pages. Bleh.

ADOdb Lite

Last September I decided to make a switch from the ADOdb Database Abstraction library to a smaller more memory efficient alternative. Of course, I’m talking about ADOdb-Lite created by Panama Jack (the guy in charge of Alien Assault Trader’s development). Making the switch was not done lightly. ADOdb is an extremely popular abstraction package with a lot of solid support and features. On the switch side it hogs memory. ADOdb-Lite‘s claims to reduce the memory usage substantially while still offering a similar (though reduced) feature set was very attractive.

The switchover overall has been worthwhile. Its worth noting that at the time ADOdb-Lite was a very new library so it took some time to settle down into a stable form. Since that time I’ve reported two bugs and requested one function change, and seen other issues like the unexpected return of full arrays not associated arrays (no numeral keys) a few versions back resolved.

Some ADOdb features are yet missing. There are no Caching functions, which removes the possibility of caching results to file. Now PanamaJack justifies this by noting in-memory caching features of MySQL – incidentally Postgres has something similar. Lets talk DBMS’s in general before justifying everything with MySQL. I rarely even use MySQL. But at the moment its not a concern for me – to be honest the library is open source, so if I do need it I’ll hack it in there with the nifty module system.

Also missing is the Performance Monitor offered by ADOdb. Again this is one of those extra rarely used features. It is quite useful, but I’m not certain how in-depth this was originally integrated into ADOdb. This doesn’t particularly bother me since I use ADOdb-Lite as the abstraction layer in a Data Access object – I can fit in a perfmon clone without touching the ADOdb-Lite source code. Of course it’s pointless at the moment given a DAO does not necessitate optimised SQL. Unfortunately its a complex item to add to a clearly defined DAO-TransferObject or ActiveRecord setup without turning the DAO into a collection of transaction scripts…

Another small niggle in the system are the potential typo-style errors. ADOdb-Lite was either developed on a plain text editor, or a non error reporting IDE. Eclipse still complains a lot about ADOdb-Lite having notice level errors, and in earlier versions potential parse errors. Small niggle, I have a preference for IDE quality assurance as a first line error pickup mechanism. The library does ship with tests, which although not Unit Tests do a fair job of exercising the Library. They’re imperfect however for a full test suite – they can’t cover all DBMS’s supported at one session. Hardly the developer’s fault – it’s just the nature of an abstraction library.

Overall ADOdb-Lite is definitely worth a look at. It does a fantastic job of reducing memory usage, enough that it makes up a substantial percentage of QSE’s memory use reduction over QS2. It’s matured over the last half year to a stable dependable library. It lacks some features of ADOdb, but these tend to be small-use features most developers wouldn’t even touch. Of course that may be a bitter pill for some developers to swallow. A good trend is a steady pickup of ADOdb-Lite – I’ve seen a few projects make the conversion recently.

In summary, if you’re expecting to develop an application for public consumption in enviroments that may include non-accelerator enabled shared hosts then ADOdb-Lite is a solid alternative to ADOdb. It’s still maturing, and has some small issues but for most common use-cases it’s worth looking at.