Ruby, I should mention, is a real programming language, whereas PHP can only be used for dynamic pages and is usually just embedded into HTML. You can do this with Ruby too of course. You can create native programs (weasel word, but compiles to bytecode and similar things probably don't mean much to you).
In web programming, Ruby is often used as the backend for dynamic web sites in lieu of say, ASP.NET, Java EE or PHP (or Python, in Reddit's case).
Why? because Ruby is a really, really nice language! I haven't been as productive with other languages as I have with Ruby. And that goes for a lot of other people, too.
If you want to get started with programming, Ruby is probably your best bet. I'd highly recommend the TryRuby tutorial by Code School. Codecademy also offers 'learning by doing' exercises, though you have to sign up (it's completely free though, unlike Code School's more advanced exercises). Otherwise, pick up a good book on it. Your local library should have one, Ruby is one of the top ten programming languages for a reason (hint: it's awesome!).
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.
-5
u/[deleted] Feb 24 '13
Ruby, I should mention, is a real programming language, whereas PHP can only be used for dynamic pages and is usually just embedded into HTML. You can do this with Ruby too of course. You can create native programs (weasel word, but compiles to bytecode and similar things probably don't mean much to you).
In web programming, Ruby is often used as the backend for dynamic web sites in lieu of say, ASP.NET, Java EE or PHP (or Python, in Reddit's case).
Why? because Ruby is a really, really nice language! I haven't been as productive with other languages as I have with Ruby. And that goes for a lot of other people, too.
If you want to get started with programming, Ruby is probably your best bet. I'd highly recommend the TryRuby tutorial by Code School. Codecademy also offers 'learning by doing' exercises, though you have to sign up (it's completely free though, unlike Code School's more advanced exercises). Otherwise, pick up a good book on it. Your local library should have one, Ruby is one of the top ten programming languages for a reason (hint: it's awesome!).