I am creating a web application which requires threading and I am trying to figure out which langauge between PHP and Ruby has better threading functionality and better performance.
Even if not in built, some easy work arounds or add-ons.
I am creating a web application which requires threading and I am trying to figure out which langauge between PHP and Ruby has better threading functionality and better performance.
Even if not in built, some easy work arounds or add-ons.
I would have to say Ruby, since Ruby actually supports it. PHP does not.
With PHP, you can create new processes (which is a bad idea) or write multiple web services and use curl_multi_* functions to accomplish some things, but threading is not a feature of PHP.
PHP does not have threading (good thing IMO).
Ruby has, but in 1.8 it has green threads, where in 1.9 it has a GIL. What this means (in the case of MRI and YARV - the 1.8 and 1.9 main Ruby implementations) is that 2 threads cannot run at the same time (in both cases) and you can't take advantage of multi-core processors.
You can use processes in both languages to overcome those limitations.
PHP currently has no support for the explicit use of threads; your PHP server may or may not use threads to serve different HTTP request ( the Zend engine does, I believe), but there are no facilities to create or coordinate threads via PHP code.
These are probably the two worst languages to choose if you want threading, but if you really want one of these two, I guess Ruby can do it. Better go with JRuby, though. The JVM does very excellent threading.
(Or go with Groovy, which is basically Java with lots of Rubyisms.)