PHP vs Ruby on Rails, Part 2
In part 1 we explained how PHP is just a language, yet we never really talked about Ruby, the language in which Rails is written. Ruby is a fun and interesting language in its own right; however, it has gotten a lot more spotlight these days, specifically because of Rails. So, if you are using Rails you’ll be writing Ruby code, and now it’s time to compare some aspects of Ruby to PHP. For me, the biggest difference between Ruby and PHP is that Ruby is an object-oriented language throughout, while PHP’s object model feels more like an afterthought. In Ruby everything is an object, while in PHP most everything is a native variable type.
I’ve been using object-oriented design exclusively for a few years now, and while I continue to model my PHP web applications with objects, they can be very awkward at times. When this happens I’m usually forced to jump back to procedural programming to do things like iterate over a collection of objects. Iterators, by the way, are very cool in Ruby. For example, in Ruby I can do something like:
employees.each {|employee| employee.give_raise}
That .each statement lets me iterate over the collection and then use the reference between the pipes as a way to perform actions onto the object. In this case, giving each employee a raise.
In PHP few things are objects by default, including collections. Instead, there is a native array type and a bunch of functions that you can pass an array to that do something of interest. For small scripts this doesn’t bother me, but for my bigger projects it’s a real pain. Early on I even considered writing my own array object. I quickly let the idea die when I came to realize I’d have to pass out native array types to the various tools (like Smarty and a number of other PEAR Objects) anyway, as that’s what they knew how to work with.
So those are some of the biggest reasons why I’m starting to prefer Ruby over PHP, but this comparison still has one more part: deployment. What good is an app if you can’t put it onto a production server? In the final installment of this comparison we’ll look at the differences in deploying a Rails app vs a PHP app. See you then.
Update: Part 3 is now online!
Posted on: December 26, 2005 – 3:42 pm


62 Comments
Hi Mike I think your there is some point in your post which seems a littel wrong to me : first off all that Iteration example : as PHP 5 you can iterate objects just like an array check the manual
and the other subject you miss here is : ruby has completly new syntax which is most of us are not familier with and something with C like notation (my faivorate PHP)
and somthing else : while you are comparing thing they sould be in same context ,it’s is reasonable to compare two languages or two frameworks but a framework and a language I don’t think so. by the way there is too many good PHP frameworks out thare ,some like struts and some like rails and some with other approaches.
sorry for my poor english Regards Arash Mikaeili
Correction to my previous post
the second paragraph is broken : and the other subject you miss here is : ruby has completly new syntax which is most of us are not familier with and something with C like notation (my faivorate PHP)
Correction:
and the other subject you miss here is : ruby has completely new syntax which is most of us are not familier with and something with C like notation (my faivorate PHP) is preferable for us to learn and do things with when it can satisfy our needs(programming ones ;-) )
Hi Arash. The manual link your provided does offer some type of iteration, but it’s not exactly what I was trying to demonstrate. In your link, it talks about how you can iterate through the public variables inside of an object. It then goes on to show how you can create your own iterator for objects or use a prebuilt one. This is useful, but not exactly what I was demonstrating within Ruby. In Ruby your can call methods on the array object to iterate through the objects contained in the array. For me it’s the fact that iterators are attached to collection object that makes it so convient. It’s subtle — but if you like OO-programming, it’s really nice.
As for Ruby having a different syntax, I don’t consider that a valid barrier to entry. As a web developer you need to be agile in learning and using different syntax on a regular basis (HTML, CSS, JavaScript, XML, SQL, and so on…).
Your point about PHP having lots of good frameworks is a valid one. PHP has many, but personally (and this is after a personal exploration of the big differences for me) I find Rails to be much more convenient and powerful.
Finally, you make a point that it’s a little goofy to be comparing languages and frameworks, and to that I agree. I’m writing it this way however because that’s how it’s being asked to me from friends and clients. Maybe it’s better to think of it as comparing development inside of the PHP world and a Rails world.
Hi Mike in php it’s possible to impeloment a costume array object with the same functionality you mentioned, so it’s not a big deal when we need such object.
about the syntax : I like to do my programming with languages which are familiar to me not because i’m afraid to learn new languages ,because in that way I can focus on other aspects of programming rather spend a lot of time to learn a hole new syntax while the new lang can do the job ,each of (HTML, CSS, JavaScript, XML, SQL, and so on…) you mentioned are in diferent areas and none of them can do the others job, but PHP and Ruby are in the same area and both of them can do the same things so I prefer to learn the one which take less time to learn.
Finally, I think it is our resposibility to tell our costumer Rails is a great Framework and based on Ruby and PHP is a great scripting language and they are two diferent things and then tell them Ruby is more powerfull than any PHP Framewok is available.
thank you for your notes.
What an entirely biased article…
And what is wrong with iteration in PHP?
I can do: foreach($employees as $employee) $employee->give_raise();
This series of articles was instrumental in my decision to finally and permanently abandon PHP as a primary development platform. Yes, technically, it is strange to compare a framework and a language—-but really now—-who wants to continue manually writing every little detail by hand any more? As web developers we’ve suffered through enough language changes and technological difficulties to kill a proverbial horse. We’re tired of solving the same problems over and over and over and over and over. Yes, Ruby has its flaws but it’s time to face the facts: procedural, manual programming for the web is dead. To quote Stage Beauty, “my astronomers tell me that the light you see in the sky is from distant stars which are already dead. Stars who are already dead but do not know it.” (from memory, may be way off :-).
The primary reason I haven’t switched to Java or Ruby is the tendency towards saying a lot and not having much to show for it. I have to take training classes to learn Java, I have to spend money to learn Java. Ruby looks like a Java replicant, more complexity, more training classes, etc..
PHP takes very little to get up and started. I feel like underneath all this is some sort of coder-gnosticism. That its more politics than proof.. I use PHP because when I have an itch in my head I can got to php.net and there will be the answers waiting for me.. But when I go to get Ruby installed it looks like a bunch of hurdles and hype..
This is just like Java..
Hey why did Sun purchase the Zend team and not Ruby.. Hey why does PHP 5 have Java like features?
Hey why is Java 1.3 incompatible with Java 1.1?
Hey wasn’t Java supposed to be backward/forward comptaible by virtue of interface inheritance?
Why do applications have to be compiled if fundamentally Java is interpretive?
Why are we using XML and libraries instead of using CORBA?
I think underneath all this is the desire to sell software working against the grain of good and useful designs.. And the best communication is not hype, but to create better documentation. More documentation = better support = more interest. The more you hype something that is poorly documented, the faster it will be dropped.
And Kicked
I realy don’t understand why there is a need to compare two different languages i.e (PHP and Ruby)?? As far as my personal experience is concered i would love to work in PHP only. and yes rest we will have to see where Ruby leads us if we opt it. Its really big quenstion!!!!
Learning PHP is very simple and one can learn it very quickly due to having c,c++ like syntax. anyone who has learned c can go for it whereas ruby is concered its like SANSKRIT :) one has to read first and interpret then…
Anyways best of luck to Ruby Drivers!
I had heard for a few weeks that Leo Laporte was on the Ruby bandwagon, then fell off of it and wondered what had hit him. In a some other podcasts, someone made the discovery that most all of the best ruby applications came from one particular company, and it seems they are the only ones that really know how to use it (I can’t recall the company).
BTW computers can also do math (considering the reasoning test in the message area, I’ve written php code that reads and submits forms).
Kiernan, you’re probably thinking of a company called 37signals?
More biased articles. When will people learn??
It’s funny, I’m having the same experience. I went out and learned Rails, only to be completely discouraged by its complexity, lack of performace, lack of features, difficulty to maintain, etc., etc… (see my previous comment above). I decided to abandon PHP and I did this whole-heartedly. Now I’ve gone back. I feel like the idiot in high school who replaced his Mac with a PC and then decided he’d made the wrong decision.
Ruby allows one to build one type of website very well, and many others poorly. PHP allows one to build or extend any web site, poorly or well. I choose freedom and a lot more flexibility.
I used to work with languages like Ruby in the past, and probably will again, in the future. In the meantime, I suggest everyone give kudos to Ruby’s creator and continue/learn to use PHP as a smart, effective and constantly-improving language of the future.
I agree with Ron. This whole thing is completely biased.
And Matt is right too, you can iterate through objects just as easily in PHP.
And Arash’s point is perfectly valid. If you want to express the differences to clients or friends, compare Ruby and PHP, then break it down to talk about frameworks.
Lastly, you can’t beat PHP’s code maturity. Rails is about 3 years old, while Ruby is about 11, and PHP is about 12. With that many years specializing in web technologies, while Ruby’s focus has never been “just that”, how can you argue?
If your going to write a review like this, you need to do A LOT of research.
However, personally I think Ruby is just as lame as Lua, only with a few more wrinkles… :P
If syntax is what Ruby authors are after, then take Mike’s example, and rewrite it in PHP like so:
foreach ($employees as $employee) $employee->give_raise();…it looks very similar to his original example:
employees.each {|employee| employee.give_raise}The nicest features of Rails are the scaffolding and the actionPack constraints/AJAX integration, but they are certainly not unavailable in PHP.
Hi, nice article, but there are some more features I think are very important:
What a lot of people don’t seem to understand is that Rails was primarily built for creating web applications, which means database-driven, highly dynamic and interactive websites. It doesn’t really give you that much for standard webpages which only need a few contact forms or something.
I’d also like to address some points some of you PHP fanboys made:
Overall I get the feeling that most people who worship PHP didn’t ever really use anything else, and also didn’t do much coding besides websites. But “real” programmers tend to use real programming languages like Java, C#, Python, Ruby, etc. and are also sane enough to use a suitable framework (which exist for ALL of these languages, and are often better designed than your typical PHP framework).
@toupeira Well said toupeira, I’ve met to much php worshiper that have the ‘my stuff the best, everything else suck’ attitude.
*** Well said toupeira, I’ve met to much php worshiper that have the ‘my stuff the best, everything else suck’ attitude. ***
Most of them out of necessity, since most of them aren’t real programmers, but web hackers that probably haven’t used much of anything else. If you don’t know anything you can’t make a meaningful comment, so you just have to post how the article is “biased.” Or else you can post something like the really loopy anti-Java comments above, which have absolutely nothing to do with anything.
*** Why do applications have to be compiled if fundamentally Java is interpretive? ***
The article was about Ruby. It had nothing to do with Java. The only thing Ruby and Java have in common is that you don’t know the first thing about either of them.
Java is not “fundamentally interpretive.” It is, in fact, not interpretive any any way shape or form. The source is compiled into byte code. The byte code is compiled on an as-needed basis into machine code. This makes it enormously faster than interpretive languages. Got it?
Let me ask all you “ROR fanboys” a question:
What make ruby on rails so much better than what php is capable of doing? What can I do in Ruby on Rails that PHP is not able to do no matter what I try.
How about another question:
If rails did not exist, would you use Ruby or PHP?
I would never pick a language to build an application on based on a framework(especially one where the lead developer and core team has the additude of “We built Rails for us, not you so Fuck Off”). Now this is a comment that really pisses me off
“Most of them out of necessity, since most of them aren’t real programmers, but web hackers that probably haven’t used much of anything else”
Now while there are quite a bit of PHP developers that don’t know a lot about programming like object for instance, I think a lot of PHP developers do. The reason that there are a lot of PHP developers is because PHP is very easy to pick up, which in turn gives a lot of very good PHP developers a bad name.
One reason I am not going to give ruby a chance at this point is because of all things i hear about speed. I mean where I work, there are parts of the year where we take in millions of dollars over the website per day and i think that ruby might not be able to handle that as well as php, I don’t think Rail/Ruby(which every is the real underlying issue) is ready to be deployed as that level. Another reason is what is the point of switching to Ruby when all of our code is already in PHP? Like I asked before, what can Ruby do that PHP can’t? I have yet to find anything and until i do, and it is something that i can’t live without or don’t want to live with out, I don’t see any real point in learning another language in which i would have very little use for right now.
Also I have the mind set that building something yourself is usually better than use a pre-built package if you know how to do what the pre-built package does or what to learn how to do what it does. I mean for example I come from a c++ background and I would never think about build my own graphics API since i don’t have a single clue on how to do it and the time to learn about it would not be worthwhile(I would never be able to write something as good as OpenGL or DirectX). However i would be interested in building a game engine from scratch since it would be interesting in learning the innerworkings of it and the experience would be worthwhile. I have this same additude when it comes to web frameworks. I am currently building my own web framework with PHP. Why? Of coarse I could use one of the existing frameworks out there and I don’t really like being forced to code a certain way. Also another thing about why i would not use ruby on rails(at least at work) is the conventions over configuration. While convention is indeed a good thing, I think configuration is also very powerful. For example it would require a complete database rewrite in order to use if i want to make sure things are consistent like making sure the id is aways the primary key of the table for a object(right now we have table the use TableID, TID, id, company_infoID, etc…). I am not sure if this is possible in Rails(I would hope that it is which would make my previous statement false) All i have to do it setup the data map from the object members and the database table names.
@mike s: I don’t consider myself a fanboy, but I’ll answer you anyway: the question “what can you do with X that you can’t do in Y” is pretty meaningless when talking about Turing-complete programming languages, everything you can do in Rails you could also do in Brainfuck, it’s a question of using the right tool for the job. If PHP suits you, that’s perfectly fine, but myself, I consider it a horrible piece of shit which has caused me enough headaches to just stop using it (unless I’m forced to at work). And Ruby is just way more powerful, readable and pleasant.
If you want a list of what you can’t really do in PHP:
Please correct me if I’m wrong, I’d love to hear a good solution for any of these.
If Rails did not exist, I would have probably taken a closer look at all the web frameworks available for Python, such as Django and TurboGears.
“The reason that there are a lot of PHP developers is because PHP is very easy to pick up, which in turn gives a lot of very good PHP developers a bad name.”
I think the reason there are a lot of bad PHP developers is because PHP is designed for newbies, encourages bad practices, and makes advanced stuff awkward. Of course there are exceptions, but we already established that.
Speed can be an issue with Ruby, but PHP isn’t really that fast either, you know. And you have to keep in mind that Rails does a lot of stuff in the background, if you would implement all of that in a PHP framework it would also be noticably slower than the usual hacked-together website script. Also, in a month the release of Ruby 1.9 may even eliminate this problem entirely.
“Also another thing about why i would not use ruby on rails(at least at work) is the conventions over configuration.”
Most of the “conventions” in Rails are just default configurations and can be easily changed, in your case take a look at http://wiki.rubyonrails.org/rails/pages/HowToUseLegacySchemas. Also, most people using Rails use it for new projects, where you can easily follow the conventions from the beginning and save a lot of time.
namespaces: True there is no namespace in PHP5 but that does not limit me in any ways or make my code look ugly. multiple inheritance: Again true but i have been able to do everything i needed without it anonymous functions (createfunction() is an ugly hack): I would agree that createfunction is quite ugly but i have never needed a function not be tied to a name. real class methods (self doesn’t work with inheritance): Um, I have no idea what you are talking about. self does work in classes and will look for that method inside that class only. maybe you can give me an example of what you are talking about. Also, are you talking about PHP4 or PHP5(I know PHP4 classes were quite basic)? a real object system (everything is an object): I prefer not having everything as an object, I think a mixed of OO and Procedural Programming is better than being forced to do everything in objects. consistent exception handling (most standard functions don’t use them): I think this allows the programmer to decide how to do exception handle, I don’t think the language it self should do any exception handle, only provide way to do it which is does or you can define your own. any kind of meta-programming: Again true but i have been able to do everything i needed without it.
I will say that php has its own problems and i am sure ruby itself might be a good language but coming from a C++ background(which i am surprised you did not put as a real language but you put ruby and a real language even tho it is really a scripting language more than a “real” programming language), the syntax looks very odd to me and probably take me a little to pick up. One issue i have with php is the non standard way to thier function. For instance some string functions take the sting first, some take it last, same thing with array functions. String and Array are 2 variables that i think really should be objects.
(I’m talking about PHP5)
namespaces are just a nice thing to have, especially when you’re used to them in other languages. And I think it’s just ridiculous that PHP still doesn’t support them. I once read somewhere that it has something to do with their syntax parser, which is already full of special cases.
same with anonymous functions, you can write just more elegant code with them.
self with inheritance: see http://maetl.coretxt.net.nz/static-late-binding for a description of this problem, but in fact I just found out that this will be finally resolved in PHP 5.3 (although in a kludgy way), see http://livedocs.phpdoc.info/manual/en/language.oop5.late-static-bindings.php
exception handling: I think you misunderstood me, I wasn’t saying the language itself should handle exceptions, it’s just impossible to catch all errors with exceptions only, because most of the standard library doesn’t use them. One simple solution would be a configuration setting to turn all fatal errors into exceptions.
I certainly consider C++ a real language, I just didn’t mention it because it’s not really suited for web development, also I only have limited experience with it.
I fully agree with your last point, the inconsistent function names and argument orders are one of the most annoying things with PHP.
I don’t this the namespaces make my code less elegant and same with anonymous function(since i have need had the need where it had to be an anonymous function in order to work. Ok, I see your point with self with inheritance and the fix they have in 5.3 may not be the best but i think it looks ok and will work fine. I see your point with fatal error and any type of fatal error i have ever seen has been because of a programming error and should be caugth during test.
I just don’t like some of the people i have talked to who say “ROR is the future of web programming”. Who know what PHP 6 will bring(i hear they are going to have namespaces). A lot of these people that says “ROR is the future or web programming” as say that i should use ROR whenever i can and not PHP(you have not said that). I also hate people who say PHP is a piece of shit(you have said that). PHP is not a piece of shit, it might be akward, but not a piece of shit. I mean i think ruby is akward, so i guess it must be a piece of shit(which i do not think). I think anyone who know PHP has no real reason to switch to Ruby and i would still recommend that new users go with PHP.
I personally don’t have very high hopes for PHP6, the language is just too fucked up ;) I don’t understand why you don’t like people for saying PHP is a piece of shit, when they can give valid reasons? There’s also valid criticism of Ruby and other languages, but PHP is really one of the worst out there (I think even Visual Basic is more coherent).
Also, I think most people saying “Rails is the future of the web” are just the ones who never used a framework before, and what they really should say is frameworks are the future, which is certainly true. Even the inexperienced PHP programmers keep some generic functions around and reuse them in every website, which is also a basic form of a framework. But why reinvent the wheel yourself? Well-engineered frameworks like Rails and the others I mentioned can give you a lot of power.
Bare PHP is nice for learning the basics of web development, and also for mostly static pages, but I would recommend using/building a framework for anything more serious. And because web developers are in fact programmers, I would also recommend to learn more languages and programming paradigms.
Well maybe my questions should have been what are the major downfalls with PHP that is not in Ruby instead of what can’t php do that ruby can’t. I will agree that Frameworks are really needed for high level web applications. “But why reinvent the wheel yourself?” Because I can. I am the type of person that does not just like to download open source code and just use it knowing that is works. For instance I could have just used the PEAR Database class but instead i built my own the fully supports MySQL(and has been tested) and mostly support MSSQL/PostgreSQL(still have a little work to do). This has helped me understand the inner workings and just give me a little extra in my programming skill sets. I think the same thing about building and understand my own framework will also be very helpful for my own projects. I am also almost always going to push for custom made code because when you build something, you will always understand better and be able to modify it a little easier. For instance my framework using phpmailer because that is something that I have no experience in and don’t think it will help me greatly and not really interested in knowing the inner workings of that. I also understand that when there are deadlines and you need something, then you have to get it down however you can, even if that means working with open source code(which i do a lot at work). I just like building custom code for my personal projects because i have no deadlines. I also think that learning extra languages as a programming is good and after i build my PHP framework and build my project management system, I will then take a look at ruby and if i feel it has a future in web development, I might try to port my framework and project management tool to ruby.
Well the major downfall with PHP is the language, which a lot of people simply don’t like, for the reasons given above.
I agree that developing your own framework is a very enlightening experience, by the way I’m also currently writing yet another mini-framework myself (in PHP, no less… ;), mainly because I have to do a big PHP project at work soon and I’m not really satisfied with the existing frameworks, but also because I wanted to give PHP another chance, or finally prove to myself that it really does suck ;) So far I encountered many situations where I realized that the language is holding me back, and made it impossible to implement certain things in an elegant way.
It’s definitely easier to maintain code you wrote yourself, but you also have to consider that if other people take over they first have to learn your framework, whereas if you’d used a common framework (which Rails probably isn’t yet) they’re already experienced in they could immediately jump to the actual problem. Of course this doesn’t apply for personal projects.
The thing with Rails though is that it just does a lot of things right, which most people wouldn’t do when they build their own framework because they lack the experience. I’m not saying you do, from the sound of it you seem to know your stuff ;) And I guess Ruby can be pretty awkward if you’re used to mainly procedural languages like C++, because it’s heavily influenced by functional programming languages which I guess can be considered the future of programming itself.
“So far I encountered many situations where I realized that the language is holding me back, and made it impossible to implement certain things in an elegant way.”
That is one point of a framework(at least to me). No language is going to do everything is the most elegant way to you, that is why you can wrap that ulgy code into your own function/class and then you can use your way of doing thing where you think it is better.
Agreed, I think what I really meant to say is that even though I tried to abstract as much as possible into the framework, the actual application code still feels much too verbose and cluttered for my taste. But I guess the real problem is that I’m just too spoiled with Ruby ;)
Hey, toupeira, you’ve emphasized multiple inheiritance in RoR. Are you sure that’s really an advantage? Any really useful example? After all, C++ has this feature since its creation, but developers later on found out to be more damaging to the project than a benefit. Even nowadays, multiple inheritance is considered bad design. Java creators, for instance, decided Java should not have multiple inheritance for a lot of reasons.
Is RoR reinventing the wheel and repeating the mistakes?
Another example is the “Everything is an Object” that you pointed. Well, the Java community was having problems with this feature so they were forced to introduce Generics as a way to reduce the problem when developers assume an object is a certain type and its not. By the way, this problem is something that PHP and I guess RoR “solve” by simply returning a null value (I called “silent failing”) which might be something really bad for most projects.
Changing completely the subject now, what are the real new benefits introduced by RoR? Cause when the first programming language was introduced, it solved it’s goal freeing developers to work with machine code. Somehow it started solving portability issues. After that, Object Orientation solved developers problems about having a big/name conflicting/spagetti code. Then, the next major change was introduced by automatic garbage collection, a feature that combined with all the others I just mentioned made Java so popular. Now the Java community is attempting with Hibernate to set a standard for persistence, and free developers from coding rdbms issues, which I think is the next step needed for development.
Is there any new benefit for going to RoR? I’m asking it of course expecting an answer considering best programming techniques, not newbie or misoriented ones.
@Cleber Zarate: interesting name, where do you come from? And which one is your first name? ;)
(we should stop confusing Ruby the language with Rails the framework, because those are two very different discussions…)
Ruby doesn’t actually have multiple inheritance, but “mixins” which solve the same problem in a much cleaner way. You can still only inherit from one parent class, but can also include “modules” (which classes are a special kind of) inside another class. I think the problem with multiple inheritance as implemented in C++ is that it can get confusing really fast, but at least from my experience with Ruby/Rails mixins nicely avoid this. And it definitely allows for very flexible and reusable code, e.g. the plugin system in Rails depends heavily on this.
I only have a basic understanding of generics / templates in C++, but from what I gather this problem isn’t really relevant in dynamically typed languages like Ruby. One difference between PHP and Ruby though is that PHP has weak typing, whereas Ruby has strong typing, so certain types of errors you get in PHP (such as the infamous “0” == null) don’t exist in Ruby. I would also say in most cases where you’d think Ruby would return null (which is called nil in Ruby btw) it will actually throw an exception. Also, nil in Ruby is very different than null in other languages, because it too is an object.
The main benefit from Ruby for me is that’s it’s very fun to write in (and I really can’t explain this if you haven’t used Ruby yet), and also the whole language / object system seems very consistent, following the “principle of least surprise”. It also offers a nice mix of object-oriented, procedural and functional language features. What won me over to learning Ruby wasn’t actually Rails, but a truly awesome tutorial called… hmm… I just realized I mentioned it already in my first comment here ;) (it’s at http://poignantguide.net)
I think the main benefit from Rails is that it brings a lot of good design patterns (MVC, ORM, Observers) and mantras (like “DRY” / “Don’t repeat yourself” and “convention over configuration”) together into a solid framework. I don’t know enough about Hibernate to comment on it, but I think Java is overrated anyway and wouldn’t really matter that much today if Sun didn’t push it so hard. I’m not sure if anything will replace RDBMS soon, object-oriented databses have been around for a while now but don’t seem to really catch on, but I guess this is more about the matureness of RDBMS than its technical merits.
But I’d like to repeat my belief that the next big step will be the switch to functional languages, which seem to build the next layer of abstraction over object-oriented languages.
Hmm… I’m adding my two cents to Ruby now. I didn’t know it was stronged typed, just for this I think it adds 90% of what PHP lacks (of course if you ignore syntax completely). ‘0’ == null and other kinds of bug sources are really what kills PHP in my opinion.
About the Generics in java, they’re different from C++ templates since it’s introduction, but the whole point here is that they’ve been introduced exactly to prevent situations like having an heterogeneous array. Of course one can say this is unlikely to happen if the programming team is very very smart and very conscious about that, but unfortunately even the hardest languages can have the dumbest coders…
About multiple inheritance in C++, yes, they introduce a mess in code since it’s hard to know which method you’re calling (ambiguity). Other problems involves constructor call orders, which are not guaranteed. Same thing for destructors.
I’m gonna give a try in the tutorials now that my “scary thoughts” are gone.
Btw, I’m from Brazil, my name (as far as I know) is common only there. Found one in Google once, but that was the only one. I think he was not Brazilian since the page was in Spanish. Who knows. First name Cleber, last Zarate, plus a bunch of middle names that never fit any form (varchar(50) doesn’t work for everyone)…
“‘0’ == null and other kinds of bug sources are really what kills PHP in my opinion.”
WOW you guys are picky, i mean ‘0’ === null is so much hard to write, remember and not to mention the code no look like the bigest piece of shit.
PS. If you did not catch it, I was being sarcastic.
@mike s: you’re missing the point, with strong typing you don’t even have to worry about this and similar errors. Also, in the real world you have something like $foo == $bar where this isn’t as obvious.
I have to agree with mike s. While having the “===” may not be very natural or elegant, i does not hurt me in any way. I just think that is a poor excuse to call php crappy(which according to Cleber Zarate is 90% of what php lacks, LOL).
you don’t seem to understand the difference and implications of strong vs. weak typing
Well then what are the other difference and implications of strong vs. weak typing besided not having to worry about those mistakes.
not having to worry about those mistakes is a big part of it, but for more information you might want to consult the internets. this is a big topic and I really don’t want to explain it to you here. just be aware that a lot of people confuse strong/weak typing with static/dynamic typing. for a start check out http://c2.com/cgi/wiki?TypesOfTyping
Well if strong type variables is a big reason for going with ruby and not PHP than you guys are really really really picky about how you code. I like when the language gives you more power, it is trusting you that you know what you are doing. It also seem like a lot of the other stuff you said also has to deal with how the code looks which should be hidden anyways. I Rails and also another big reason why people say to use Ruby which is also another retarded reason because I can grantee someone could make an almost exact port of it to php(I think there is already one).
I wouldn’t call it a “big” reason, and I agree with Celeb that the syntax makes the biggest difference for me. I looked at several PHP Rails clones, and while most of them seem pretty nice they still are in PHP and will never achieve the cleanness of Ruby code. All those ===’s, $this->’s, array()’s, {’s, }’s and $’s quickly add up to lots of unnecessary noise, and because PHP lacks some high-level constructs like blocks, iterators and metaclasses (which you use in Rails all the time without even noticing it) a lot of nice shortcuts in Ruby aren’t possible with PHP, leading to more verbose code. This really makes a big difference, especially with web applications where you have lots of short, concise actions. Another point of course is that none of these frameworks has as big a community as Rails has (note I’m talking about the PHP frameworks, not PHP itself).
Also, I really don’t think of weak-typing as “giving you more power”, just a possibility to create lots of unexpected bugs and behaviour with few benefits.
I will admit that $ is a little retard but i am used to it by now. I also LOVE {}. I love them in C++ too. That make it so much more clearer then typing “end”. $this is also a little annoying but again i am used to it. I also don’t think a pure OOP languages are better than OOP/procedural, you get th best of both worlds if you have support for procedural programming(and i have yet run into an issue where php does not support a particular OOP functionality yet except the issue you mention about self and inheritance which is going to be fixed). It still amazes me how some people can be so picky about there code(I could you that you would not last one day at my job cause the legacy code i have to deal with is the biggest piece of shit you have ever seen).
I sincerely doubt I’d have problems at your work place, I deal with horrible code all the time too ;)
Ruby does procedural at least as well as PHP, does object-oriented far better and can even do some functional! Of course the syntax is just a matter of taste in the end, but at least from my experience cleaner syntax automatically leads to cleaner/more advanced code, this really has nothing to do with being “picky”.
If we forget the syntax for a moment, we could also compare the standard library of both languages: PHP’s is mostly procedural, extremely inconsistent and cluttered, whereas the C++, Java, NET, Ruby, Python etc. standard libraries are completely OO and very well organized. For me this is even a bigger reason to hate PHP than the syntax. If you don’t feel bothered by PHP’s syntax and standard library that’s perfectly fine with me, I’m not trying to convert anybody here. I just think that PHP is technically inferior to the other mentioned languages in just about any way.
Correction: I just found out that PHP5 does indeed have iterators, though they look fairly limited. There’s also the beginnings of an object-oriented standard library called the SPL, but it currently only offers a few generic iterator classes.
And i know your are not trying to convert me. I just don’t like when people say that PHP is inferior to ruby/asp/python/etc… because it is not if you know what you are doing. Just because the language lets you be a dumb ass does not mean that the language is inferior(but I am in no way saying that it is perfect or better than ruby/asp/python/etc…). If php way so inferior it would not be as popular as it is today(Ruby and PHP have been around for at least the past 10 years and only now ruby is getting some hype because of rails).
and when i say “bnow” I mean the past 2 years or so.
Hmm… so you don’t like when I say that ruby/asp/python/etc. are better than PHP, even though you agree? ;)
ok, i lied, i do think php is slighty better than ruby has it is easier to setup from what i hear and a bit faster. All i was trying to say is that php and ruby can basically do that same thing, just in a different way(and i happen to like php’s way better). Just because someone likes doing something a different way does nto mean it is better, it is just better for them. I mean some people like coding like:
function doSomethingHere ( $var ) { if ( $var === false ) { //do something } }
and others like:
function dosomethinghere($variable) { if($variable === false) { //do something } }
but it does not mean one way it better general, just depends on the person.
sorry forget to add tags.
function doSomethingHere ( $var ) { if ( $var === false ) { //do something } }function dosomethinghere($variable) { if($variable === false) { //do something } }one more correct
dosomethinghere
well well well !
arguments over facts and fictions… come on what is going on here :P
just one real fact :
go to hotscripts dot com and look at the number of scripts published for any given language and you will find out why PHP rules the web. PHP has the highest number of scripts i.e. 14,939 ( the one on number 2 here holds 4374 scripts ) so PHP is ahead by 10565 scripts even from its nearest neighborhood i.e. CGI and Perl…
AND and Ruby on Rails is at the LAST spot with only 70 scripts in its bag.
so here goes the saying —> don’t sing it just bring it <—-
the real fact is that PHP is a practical language for webmaster. the real fact is that PHP is easy to learn and deploy. the real fact is that PHP rules the web todays. and it did not happen by shouting that PHP is a better language than others, but people found it suitable to their needs and that’s where the word ‘practical language’ comes.
i am not against any other languages. i have just shown the real facts and figures.
also i do not believe that calling something ‘a piece of shit’ is the way to convince others. also i do not believe that any framework, be it anything, which binds people to do it in its own way can survive the test of time..
Go to project search in sourceforge. http://sourceforge.net/search/ and type “Java”, on “any words”. “Searching projects gives 15279 results”
Then type “PHP” : “Searching projects gives 11241 results”
Is this a real fact that Java dominates? I don’t think so. hotscripts.com is more popular among PHP developers. Study better your statistics before taking them as facts.
But I agree that we shouldn’t call languages a piece of shit.
Ohhhh.
I really don’t understand why RoR guys say “PHP is a piece of shit”????? Why don’t they list out what ror does which PHP can’t???
PHP is very good and easy to learn language but Ruby seems a language developed by an idiot.
I would recommend that new users go with PHP only.
I agree with Romy. Ror is bullshit.
I am with Romy…..Ror is bullshit.
please, learn to read. I already explained my opinion (and it’s really just that, a fucking opinion) in excruciating length, if you don’t want to argue my points or bring in some arguments of your own, why the fuck are you even posting here?
Ok, I read about half of the comments here and didn’t see anything new. I am a PHP developer. I would LOVE to try and learn ruby (even though my host does not support it). Here is the problem though. I can go and download any number of programs already written in PHP and get an idea of how it works. I have yet to find an open source program written in Ruby that I can open up and take a look at. Any suggestions?
I assume you mean Rails applications? Because there are thousands of Open Source Ruby applications out there. Take a look at http://wiki.rubyonrails.org/rails/pages/OpenSourceProjects for some projects based on Rails.
I’m developping web applications and sites for clients with php5.
There are a lot of CMS based on the php language like Joomla, Drupal,
Typo3. So the best approach in comparing web site creation should be
to compare how Rails can be better than thoses others CMS.
You cannot just compare a framework with a language !
I just did a Ruby tutorial, not Rails, and found it simple at
glance. I will learn a little Ruby and Rails then compare it with
others PHP frameworks or CMS. I think thats the best to see the
differences.
What I see about RR all around the web is just one thing, it seems like a battle between users and programmers, RR as a development framework is great, it is and will be the users programming language, just to say something, and of course, always will be millions of users like those, like users have blogs and BBs, while PHP is and will be the programmers development language. In conclusion, you can do with PHP what you can do with RR, but you can not do with RR what you can do with PHP. Why do I say this?, because with RR you can do only what the framework can do (simple and attractive things) but if you need more, you will need to learn Ruby (not Rails), and to learn Ruby and be proficient with it, it is not an easy matter, Why nobody ask about Ruby itself? Have you seen a PHP framework? there are some excellent ones, compare them to RR, and you will start talking about Ruby (not RR) and you will find the big difference between a user developer comment and a programmer developer comment. For a while, lets the millions of kids (users) play to web programmers game with RR.
you have no fucking clue what you’re talking about. seriously, with comments like these you can’t expect anyone to respond reasonably.
OK, somebody did a great job for you, He used Ruby language, and prepared everything for you for easy and productive use like a Gerber, called by everyone else a framework. So one guy, just one Einsteinian guy, not only created the framework for the future, but his message is that if PHP were what really is, he had been using it, but because all brains behind PHP are whatever they are, but not the real genius like the ones behind Ruby, he decided to make his MonaLisa in ruby? Anyway, Thanks for the freedom of speech at your site. Excuse me, I just cant imagine a whole world in the wrong way using PHP instead Ruby. In this page are some of the real problems with ruby http://en.wikipedia.org/wiki/Ruby(programminglanguage) and of course, rails is constructed over ruby. and most important the disgusting legal issues with the creator of rails. http://en.wikipedia.org/wiki/Rubyon_Rails
Besides all this, I have not found any mature application on Rails, if you know one, let me know please. The more complex one is Basecamp and is very buggy, and small compared to many open source and commercial applications done in PHP.
ROR sucks when updating to new version. Some part of code develop from old version can’t be use on new version.
Too slow when handling large process.
A lot of problem may arise when handling multiple different database type.
Post a Comment | Comment RSS feed