Twig is hot at the moment.
It is part of Symphony and therefore CMS like Drupal use it.
However we choose TAL for several reasons.
So i wrapped up a test using themes/default/html/forums/viewtopic_body.xml
This is a more real example then "hello world" as it contains different things like traversal and conditions.
Asus P8Z77-V LX
Intel i5 3570
8Gb RAM Kingston HyperX KHX1600C9D3P1K2
PHP 7.0.4 (Fedora 22, remi repository)
ltime = load php files time
ptime = compile template time
Benchmark without cache: ltime ptime memory peak
TAL 0.00295 0.0115 355640 867232
Twig 0.00363 0.04623 3098440 3198912 Benchmark with cache: ltime ptime memory peak filesize
TAL 0.00288 0.00374 358360 750840 33376
Twig 0.00369 0.00343 705168 439496 80431
When caching is disabled/fails our TAL system is much faster then Twig.
On the other hand, with caching enabled Twig is slightly faster on ptime.
This is also due to the fact that the data put in is a multidimensional array without objects.
With objects (which is default) the outcome might slow down.
Since the differences with cache enabled are low, the real difference comes in use-case.
Which markup do you prefer?
What about invalid html errors?
What about template parse errors?
Although Twig does its best, this is my personal opinion about those questions
I like TAL more
TAL can be used in WYSIWYG editors without problems (the biggest benefit actually)
Our TAL is XML SAX based so it throws an error on incorrect XML, Twig doesn't. Take for example <div style="margin:5px 0;" style="foo>">
(notice the error on line 1 and 3)
Our TAL tries to exactly show on which line and column the error occures, Twig is more cryptic
I've attached the used templates so you can compare the template code.
Note: not all TAL is converted to Twig, so this might also be the reason Twig is faster.
Update: when running the opposite (first twig, then tal) the outcome is that TAL is faster. Odd but nice in our advantage. ltime ptime memory peak filesize
Twig 0.00547 0.00526 731360 849824 80885
TAL 0.0034 0.00454 353832 634296 33376
Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial
Last edited by DJ Maze on Mon Apr 11, 2016 10:55 pm; edited 1 time in total