-1

Looking for a fast back end language to run algorithms with lots of loops and regex. Application is running php (Zend framework), would like to move the core functionality further back to get better memory usage and speed. So far thinking perl (after some googling), would like to make sure that is the best option

Thanks for your help

Aurelio De Rosa
  • 21,856
  • 8
  • 48
  • 71
Shaked KO
  • 399
  • 2
  • 11
  • 2
    First improve your regexes or replace it with simpler string operations. A complicated regex will be slow regardless of the language you use to call the C library that evaluates said regex. –  Nov 13 '11 at 21:19
  • 6
    Improving the algorithms might be better than switching the language. – schnaader Nov 13 '11 at 21:19
  • 1
    Are you already familiar with Perl? When *I'm* looking for ways to improve performance, rewriting my app in a language I don't know isn't the first option that springs to mind. ;) – Alan Moore Nov 13 '11 at 23:58
  • See [best-language-for-string-manipulation](http://stackoverflow.com/questions/635155/best-language-for-string-manipulation) – nawfal Jul 21 '14 at 21:29

2 Answers2

2

Perl was designed for just this kind of purpose. It was the first to really do regex and most other languages copy syntax, if nothing else, from perl. However, I have not really seen any performance benchmarks to confirm this.

Here is one benchmark comparing perl/python/ruby. It seems to confirm that perl is fastest. Again, that wouldn't surprise me as that is what it was designed to do.

And here is one more article, which I would recommend reading on this subject. It points out that perl may be slower than java, but for a good reason.

Lucas
  • 14,227
  • 9
  • 74
  • 124
1

You will most likely need to use a compiled RegExp in this case. See this question for more information about using compiled RegExps in PHP.

Community
  • 1
  • 1
Alexander Galkin
  • 12,086
  • 12
  • 63
  • 115
  • "Compiling" in this context just means creating a reference to the regex and holding it in scope, as opposed to relying on PHP's built-in regex cache; the regex itself runs just as quickly either way. But yes, this is one of many things the OP should consider before abandoning PHP. – Alan Moore Nov 13 '11 at 23:48