seems like Ruby is fully object oriented
I’ll probably give it a try some day
seems like Ruby is fully object oriented
I’ll probably give it a try some day
I did not know you could make Ruby pages, I thought it had to be inside a Ruby-Framework?
If you are comparing RoR to PHP, then I think you have to compare it to an actual PHP framework, unless you are only comparing basic stuff. I’ve been toying with Python (Similar to Ruby I hear) and it’s a lot less code and somewhat cleaner than PHP in my opinion, so I can see why you like it!
You could make Ruby output html directly, just like you could with Python or Java, but you probably wouldn’t want to.
That’s true, I’m not comparing like with like. I’ve quite enjoyed codeigniter and building on top of wordpress is good if you need a certain result. Python is very nice, Django is cool.
Java is not fully object oriented. Primitives such as integers are not objects. Also, because it’s compiled, objects are not open, you can’t create methods dynamically for example. The only way you can extend an existing class is through inheritance which can rapidly get a little crazy if you don’t have someone good in charge of the team. There’s no multiple inheritance, no mixins, no monkeypatching, it’s great if you need something that’s locked down tight for developing in a large team of mixed ability programmers.
Python is great and a worthy rival for Ruby imo.
I’d been a PHP for years also, but after using Ruby, it’s impossible to go back; I only use PHP when I have to, such as to add features to existing PHP applications.
Ruby makes PHP look like a scrap heap. Everything in Ruby seems so well though out. The syntax, language constructs, API, methodologies, etc, where as PHP is more like play-do/clay/plasticine, with bits and pieces awkwardly pushed into place.
The only thing that makes PHP simpler to new comers, is because it has a basic web API built into it, where as Ruby doesn’t. By web API, I’m talking about the means to access request variables, set and get cookies, manage sessions, etc. PHP includes a lot of that stuff out of the box (it’s not very nice, but it’s there). Ruby however isn’t a language for the web per-say, so it doesn’t include such web-specific API’s or tools. This isn’t a con by any means, but it makes Ruby a little less accessible to complete noobs (which is probably a good thing). It just means Ruby depends on some kind of platform to be used for the web, whether it be a Ruby-based web server such as WEBrick or Mongrel, or a complete framework.
PHP also has really good documentation. The well-written online PHP manual with it’s comments facility makes it an extremely helpful resource.
Ruby beats PHP in practically every other area though
Heroku has absolutely changed the face of Ruby and Rails deployment. We will be seeing a lot of developers using ruby and rails in the coming years thanks to easier deployment.
I’d second Heroku, it’s awesome, though it is rather more elegant than most PHP developers may be used to.
Just tell Heroku about your Git repo, push, and it’s live. Within certain limitations it’s also free, you only pay when you start to scale, and this is done by dragging sliders. The downside is that the filesystem is read only, so if you’re doing image uploads you have to store them in the database, which is actually really no big deal.
Brightbox is also great. You install a gem and it handles your deployment for you via Capistrano, so for me to deploy now I just type: cap deploy, wait 5 minutes while it uploads the zip, and it’s live.
I use Capistrano for deployment and have always managed to get it working with any “regular” hosting provider that supports Ruby/Rails, so I don’t see the problem there. I even use Capistrano for multiple-environment and PHP projects such as Magento Commerce sites, with Railsless Deploy.
Whatever site I’m working on, it’s just a matter of setting up the recipe with the right paths and instructions (if any), and:
With SSH keys in place, no password, no nothing. It just works.
As for the issue of popularity among developers, and language vs language, just look at the origins of the two. I believe someone wrote something nice a few posts above. Though I like Ruby more than PHP these days, I’m not as much concerned about the programming language as I am with the client’s requirements.
The language is just a more or less important piece of the puzzle so stop obsessing about it and go write your client some good software. I mean it, go talk to your client, go figure stuff out—it’s time better spent than sitting here arguing why German is better than French and vice versa.
EDIT: If you despite what I just said still want to argue (of course you do since you are a human being behind a keyboard), I can argue that if you’re a good developer (meaning you are curious), Ruby will simply sooner or later refer to Rails, which refers to many good programming practices you can learn from. You can’t really read up on Rails without passing by TDD, DRY and so on. In my experience, more so than the PHP frameworks I’ve tried, such as CodeIgniter, Symphony2, Zend, Recess etc.
In the end, what does it matter anyway? Do your thing—do what your boss tells you or what you deep down in that “elitist Mac” heart of yours feel is right. If one language seems to be lagging behind the other, you’re still a programmer—if you’re good, it will take you a few hours to learn something else. Same goes for frameworks. The world, especially our world as web developers, is changing. If you’re any good, you adapt. If you’re mediocre, at least stay awake because if you really suck you might just fall asleep behind the wheels and it’s game over. It’s a metaphor but it happens.
The simple answer:
PHP is based on C and uses the pervasive C sytax, which is one of the two predominant syntaxes people learn to program in. Most schools teach Basic syntax languages (Ada, Pascal) for intro to programming classes, and transition students into the more abstract C syntax languages (Java, C, PHP) in more advanced courses.
Ruby is based on nothing, and uses a proprietary <snip /> syntax that no other language uses. Further, it’s unstructured, and flawed in concept, as its flexibility allows too wide a range of coding style to be adopted by any group of people in a uniform way (what this means is that it’s impossible for large companies to adopt). PHP is similarly flawed, but is evolving towards organization and structure, whereas Ruby is not.
Hmmm, yes, calling methods with -> and string concatenation with .
I would say Ruby is closer to the C family than PHP. There’s really very little in Ruby that’s odd or unfamiliar, once you understand it.
Technical issues seldom win the battle. For years, I fought the Oracle vs. Ingres vs. Sybase vs. Informix battles and Oracle came out the clear winner. Was/is it the better RDBMS for technical reasons? Not by a long shot then, and it still isn’t. Oracle won the battle through marketing - strategic ad placements, golf outings, “user” conferences, and loading MBA-types with the mantra: “no one ever got fired by recommending Oracle” (paraphrasing the old IBM adage). Projects cost more and took longer, but that only meant that the consulting companies made more profit, and the CTO/CIO could brag to his buddies at the country club how much that new system cost. If it failed, the consultant took the heat.
Who’s going to quote Ruby when a PHP framework takes longer and costs more? The customer won’t know and as long as it works, won’t care.
Ruby is good one, it is quick and easy.
But the PHP is an old programming language, everyone knows this that’s why it is more popular than Ruby.
Actually, Ruby turned 18 this year. Horray
Well if that is young compared to PHP, How old is PHP?
Difficult to install on Windows and Linux.
PHP 3 was released in June of 98. Prior to this (since 94) there had been PHP/FI & PHP/FI 2.0 but there not really anything like the PHP of today.
So, in actual fact. Ruby is a little older than PHP.
I’ve been using php for 5 or 6 years, and a couple of times tried to figure out how to install ruby on my windows dev machine. Both times was not successful. Ruby needs a one click install like xampp or wampserver, and it would probably be adopted a lot faster. Im still interested in learning ruby, but I feel like I can do everything I want to do with php, so maybe it’s just a waste of time? I don’t think php is going to go away anytime soon.
A quick rehash:
Age? No, they’re about the same age. Ruby is older than PHP, but there were no english language books on it until 2000, and not much interest until a year or two later.
Syntax? Not, really. Both descend from other languages in their syntax, and are fairly simple to use.
In a nutshell, the largest reason is mod_php. There was an attempt to get a mod_ruby rolling, but it was always extremely buggy and unreliable. Unlike mod_php, which was far more solid. So anyone writing code for the web in ruby had to settle for fastCGI, which was also buggy and unreliable. In these days of heroku and passenger, though, deploying a ruby app is no more difficult than deploying a php app.
A secondary issue for it was threading. The standard ruby interpreter didn’t really handle threads (in anything other than name only) until 1.9.x, and even now it’s not all that useful, as it can only utilize a single core of a multicore processor.
There is, however, no reason to trap yourself into only using the default ruby interpreter. Unlike PHP, there are several ruby interpreters in play, and jRuby (as well as IronRuby, if memory serves) both are quite capable of using multiple cores. The competition is leading to rapid improvement in all entries to the field.
MRI (Mats’s Ruby Interpreter, the default ruby) just isn’t very well designed. 1.9 was a big step forward, but it has a long way to go. I was really looking forward to MagLev’s release; coming from the smalltalk world, it had the benefit of long experience solving the issues MRI was facing, and there’s not all that big a difference between smalltalk and ruby languages. But it’s taken so long to get to alpha, I’m starting to lose patience.
But these days Ruby is catching up. More and more large sites are coming online using Ruby, even some of my clients who used to tremble in fear if I mentioned the R-word are now open to the idea of using it.
I’ve done both.
RoR is a heavy beast. In 2006 I deployed a RoR site on Windows 2003 on IIS 6.0 ( mongrel behind an ISAP_REWRITE reverse proxy - read that as we paid for ISAPI_REWRITE to get that functionality ).
Ruby was the 1.8 Windows All in one. On the same server I ran a ruby script that would parse an xml file, a mysql database and then output a particular formatted xml file for Adobe Indesign becuase AI had ‘special’ readability issues like carriage returns etc.
As for the syntax it is pretty petty to bicker over which one is better. As for rails I think a lot of people misrespresent rails and its conventions. It isn’t any easier to maintain a site using its conventions. It isn’t any easier to create a site. It is/was only easier for a particular dev or group of dev’s to learn the rails convention.
CodeIgniter is arguably just as easy to work with and maintain. Migrations aren’t the cat’s meow for many reasons… but the biggest one is legacy code. If you cannot start in the conventions then you soon find out the ‘agile’ nature of the framework isn’t as nice to play with as a start up would find.
Since they both work best in fast-cgi they also exist in Windows a lot better now especially in Vista/7 with IIS7+
Ruby also sucks vanilla. Enterprise Ruby or Jruby is where you want it. Ruby’s garbage collector is a leaky faucet. In Fast-CGI you better not be using a shared host. In fact, every con of hosting JSP (tomcat/jetty) applies to standard Ruby. IE… you better have a lot of memory.
Ruby also is best when used with Ruby Version Manager or you might as well start learning ‘make’ and ‘make install’ commands. Most ruby fans use Mac’s… where things seem to just work. But most of the time they work until you want to so something like memchache integration, certain db connectors etc. Then you have to either use rvm or ‘make’ just the same. Mac users are liars in full effect most of the time. I develop on my iMac and I have a complete custom environment to do things my Ubuntu dev environment takes for granted.
Which is better? Depends on who you work with, want to work with/for and what type of local resources are available to you. Ruby shines in JRuby environments… b/c of java’s garbage collector and threading.
PHP shines just as bright as Ruby and 5.3+ is very hard to beat in terms of speed, support and maintenance.
PS there are far more reference manuals that are relevant to this day in PHP. I’ve got 2 Rail books considered the rails bibles… and each revision essentially makes the prior completely useless unless talking about patterns and basic syntax.
I think Ruby on Rails isn’t popular yet, I’m a PHP guy for almost 2 years and I’m having fun on it.