-
Website
http://developingwithstyle.com/ -
Original page
http://developingwithstyle.com/articles/2009/05/21/10-reasons-why-ruby-is-better-than-php-reason-2.html -
Subscribe
All Comments -
Community
-
Top Commenters
-
Hallison Batista
1 comment · 1 points
-
eberfreitas
1 comment · 1 points
-
daveporter9
1 comment · 1 points
-
tefflox
1 comment · 1 points
-
Rytis Lukoševičius
1 comment · 3 points
-
-
Popular Threads
-
Goodbye Wordpress, Hello Jekyll // Developing With Style
4 weeks ago · 1 comment
-
Goodbye Wordpress, Hello Jekyll // Developing With Style
The "everything is an object" paradigm that Ruby (and Python as far as I can tell) supports does lead to some very elegant code.
To argue the term "better" with "evidence" like yours is sort of misguided.
The lack of a [return] statement hardly makes a language better. Don't get me wrong, I think that Ruby is better than PHP, but your reasons leave a lot to be desired and may be misleading.
eg. I hate the lack of braces in Ruby; does that mean I think PHP is "better"? Based on your arguments (so far) C == PHP because you're focusing on syntax.
Hey, I'm just saying...
At work, we're making the transition from C++ (and sprinkling of VB, ugh) to C# and it's just been heavenly so far.
If I don't have to type "return" to return a value, then surely that is a good thing.
Also, if every keystroke is so important for you, you forgot to mention that rb file extension is also much much shorter then php (just kidding, and looking forward for your reason #3).
1st: RETURN in PHP. If I don't want to return anything, I can leave it with no return. However the last statement on ruby will be returned. What if it wasn't supposed to return anything. C'mon. You have program, not guessing. Step by step.
2nd: Cannot redeclare a class in PHP. That is right. If you want to do extra stuff with a class, you can extend it. Class name1 extends name2{}. I don't care if you think it's easier the ruby way, but you have to make everything to have a purpose. Override a loaded class can cause confusion while you are coding. You may have wanted something else, and bam ended up with whatever you did on the loaded class. And if you really need to change something, just create another class, is that hard to do?
3rd: :ALPHANUM: characters make sense in PHP because other characters have other stuff to do ? :, etc. But doing 3.odd?, well seriously is it hard in php-> isOdd(3) ? For readability purposes, php seems more understandable. But hey, this one is more of how you like it.
In conclusion, the author just doesn't like PHP, even though he stated that most of his work is in PHP. One answer, whatever! (lol, jk).
But on some serious note, you failed to give a valid point on reason #2 why ruby is better than PHP. like @kevin lloyd said: "your post would be: “10 reasons why [I] like Ruby better than PHP.”"
But so far PHP is looking good based on your arguments, only rookies and frameworkers can fall for your "reasoning". No offense, I'm just a die hard PHP programmer, you won't put my language down like that. You want to compare, try Ruby and Python. Since they kinda follow the same syntax.... yeahhhh
PHP 4 Life!
In PHP, if I want to redefine a method from ClassA, I either have to modift that method directly, or create a whole new class with a different name, perhaps called ClassB. Then "ClassB extends ClassA". And now I also have to change all my scripts so that they reference ClassB so as to include the redefined method.
In ruby, I literally redefine the class and method. That's it!
the "return" vs "no return" is just a matter of taste, I prefer the return as it gives me an explicit return point in methods that is easy to locate when you read through the code.
about reopening classes, it's just a way to achieve something which can be done a hundred different ways. Unless you really know what you're doing, reopening classes will mostly cause you a lot of headaches - and considering that ruby is a dynamic language (well all parts except the built in objects / c modules) you could just edit the original source and get the exact same effect, or just extend the class and allow the user of whatever you're writing to switch out which class is used. Yes it can be nice to have, at times... but it's hardly a killer feature that makes ruby stomp php.
About allowing ! and ? in method names, well then I guess Haskell or Lips must be even better languages since they allow pretty much (almost) any character in function names. Please.
I think the problem is that coders are generally very protective about their language of choice, which makes them very closed minded when it comes to other languages.
You really won't know for sure if something is better for you, until you really try it. Just try coding without having to using the 'return' keyword, or without having to extend classes all the time, when you can reopen them instead.
And I never agreed with being allowed to re-open classes either, since it leads to very hard-to-track-down bugs if you use it unwisely.
And Joel, your last post basically says "everyone that doesn't like ruby is closed minded and stupid". I have tried Ruby, a lot (I even used it before the whole Rails-era started) - and I still don't like how a lot of stuff is implicit instead of explicit in it.
And about this quote "I think the problem is that coders are generally very protective about their language of choice" - I don't know of a single professional (note: professional) programmer that has a "language of choice". You use the language best suited for your problem, be it Ruby, C, Java, Lisp or something else.
I enjoy using most languages, and to be honest enjoy C++ over all of them. However, due to quick time production, I use ruby quite often because of its "efficiency".
C'mon... not to be disrespectful... but do you really have 10 reasons, or you just going rogue against PHP and now can't find any good reasons?
Well, I'm still waiting for the reason #3.
BTW, I checked your blog twice a day to make sure reason #3 is there.... still waiting...
Peace out!
If you following the whole design pattern movement, the proper way to create objects is to use a factor method anyway, so I'm not sure if I see the point of this particular feature.