Now let's note get carried away here. PHP has a perfectly capable standalone interpreter which allows you to do anything you would want in a scripting language. I've written some threading server apps in PHP for the hell of it, and my only complaints there were syntax related. There are even tools to compile PHP to bytecode.
Ruby is great if you want a language that's pretty simple to pick up, without too many caveats until you get really deep into the guts of the environment. It's not the most efficient language out there, but with support for C plugins even that can be addressed for most situations. I wouldn't use it for very performance critical operations, but it's a good choice for general coding, and particularly good for prototyping.
I'll see if I can find it, but this was a small proof of concept project I did years ago just to see if it was possible (Open multiple connections, then echo text typed in one to all the others), so it's probably in some archive in a deep corner of my backup drive.
More specifically, the program was actually multi-process, not multi-threaded. I remember abusing shared memory, and generally doing things that most would not associate with PHP in order to overcome the limitations of the language. I also recall that I had a busy loop for some reason, and that the server broke my networking if I didn't shut it down properly, though that was just me being lazy with connection management. These days I think they've implemented proper native threading in PHP, so I imagine you could do what I did back then with significantly less hackery.
It seems there is even a Windows release of PHP pthreads which likely relies on Windows threading. It's still not a good reason to build a serious cross-platform server app in PHP, but it's certainly possible.
I think the best distinction to draw is that Ruby is an object oriented programming language while PHP is a scripting language. Yes, you can do whatever you want in either, but each has its very distinct strengths. Ruby is closer in purpose to C/C++, upon which operating systems are built, than PHP, which lives in scriptland with shell scripting languages. You wouldn't usually pick PHP to write a back-end. Ruby, definitely. And with Rails, it can be your front-end too.
10
u/TikiTDO Feb 24 '13 edited Feb 24 '13
Now let's note get carried away here. PHP has a perfectly capable standalone interpreter which allows you to do anything you would want in a scripting language. I've written some threading server apps in PHP for the hell of it, and my only complaints there were syntax related. There are even tools to compile PHP to bytecode.
Ruby is great if you want a language that's pretty simple to pick up, without too many caveats until you get really deep into the guts of the environment. It's not the most efficient language out there, but with support for C plugins even that can be addressed for most situations. I wouldn't use it for very performance critical operations, but it's a good choice for general coding, and particularly good for prototyping.