5 ms·
Perl could be nearly as fast as C/C++, depending on what your service does and how you wrote it. The early days of running a cgi script for every request had a
by DougWebb 8y ago
Perl could be nearly as fast as C/C++, depending on what your service does and how you wrote it.
The early days of running a cgi script for every request had awful performance, caused by the overhead of loading and compiling the Perl code before executing it. But there were ways to avoid that by pre-loading the code. One way was to use Mod_Perl on Apache, for example. I wrote a number of services that way, and also wrote my own pure-Perl standalone http server that could pre-load an entire web application.
The other key factor was to use canonical expressions when writing your Perl code. There was always "more than one way to do it", but there were only a few ways that the compiler would recognize and use optimized functions for. Once you learned to take advantage of that, you could get your code running mostly in hand-written C functions. It wasn't as fast as native C because of the way Perl variables were represented, but it could be pretty close.
- tannhaeuser 8y agoThe "trick" is to use HTTP caching (build right into the protocol) so that not every request needs to trigger full-page rebuilding. If you have eg. mod_cache (or external reverse caches) enabled, your page composition script could be as slow as it wants, it doesn't really matter.
- DougWebb 8y agoFor static or static-ish content, absolutely. But I was talking about (and writing) web applications and web services, where the responses generally aren't cachable.