HTML-Blitz

 view release on metacpan or  search on metacpan

lib/HTML/Blitz.pm  view on Meta::CPAN

=over

=item *

L<HTML::Zoom> is slooooooow. Using it in anything but the most simple cases has
a noticeable impact on performance.

=item *

HTML::Blitz is orders of magnitude faster. It can easily outperform
L<HTML::Zoom> by a factor of 200 or 300. A dataset that might take HTML::Blitz
20 milliseconds to zip through would lock up L<HTML::Zoom> for over 5 seconds.

=item *

HTML::Blitz and L<Mojo::Template> are faster than hand-written code. This is
probably because the hand-written code appends each line separately to the
output string and escapes each template parameter by calling
L<C<HTML::Entities::encode_entities>|HTML::Entities/encode_entities( $string )>
– whereas HTML::Blitz and L<Mojo::Template> fold all adjacent constant HTML
pieces into one big string in advance and use their own optimized HTML escape
routine.

=item *

HTML::Blitz can, depending on your workload, run faster than
L<HTML::Template::Pro>, which is written in C for speed.

=item *

In this comparison, the only system that beats HTML::Blitz in terms of raw
speed is the XS version of L<Text::Xslate> (by a factor of about 2). The only
downsides are that it requires a C compiler and pulls in an entire object
system as a dependency (L<Mouse>). (Without a C compiler it will still run, but
the performance of its pure Perl backend is not competitive, reaching only
about two thirds of the speed of L<HTML::Blitz::Builder>.)

=back

=head1 WHY THE NAME

I'm German, and I<Blitz> is the German word for "lightning" or "flash" (or
"thunderbolt"). Because the main motivation behind this module is performance,
I wanted something that represents speed. Something I<lightning-fast>, in fact
(that's I<blitzschnell> in German). I didn't want to use the English name
"Flash" because that name is already taken by the infamous "Flash Player"
browser plugin (even if it is currently dead).

The second reason is also connected to speed: I wanted a template system that
assembles pages as effortlessly and efficiently as copying around blocks of
memory, with minimal additional computation. Something roughly like a
L<bit blit|https://en.wikipedia.org/wiki/Bit_blit> ("bit block transfer")
operation. HTML::Blitz "blits" in the sense that it efficiently transfers
blocks of HTML.

The third reason relates to my frustration with L<HTML::Zoom>'s performance.
When I was struggling with L<HTML::Zoom>, fruitlessly trying to come up with
ways to optimize or work around its code, I remembered a funny coincidence: It
just so happens that (Professor) Zoom is the name of a supervillain in the
superhero comic books published by DC Comics. He is the archenemy of the Flash
("the fastest man alive"), whose main ability is super-speed. When the Flash
comics were published in Germany in the 1970s and 1980s, his name was
translated as I<der Rote Blitz> ("the Red Flash"). Thus: "Blitz" is the hero
that triumphs over "Zoom" through superior speed. :-)

=head1 AUTHOR

Lukas Mai, C<< <lmai at web.de> >>

=head1 COPYRIGHT & LICENSE

Copyright 2022-2023 Lukas Mai.

This module is free software: you can redistribute it and/or modify it under
the terms of the L<GNU General Public License|https://www.gnu.org/licenses/gpl-3.0.html>
as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.

=head1 SEE ALSO

L<HTML::Blitz::Template>,
L<HTML::Blitz::Builder>



( run in 0.678 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )