#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    57
    Rep Power
    12

    Is PHP worthwhile?


    [[

    This thread (itself split from another thread) has been heavily edited. There's a difference between voicing an opinion that PHP isn't a good programming language and telling people not to use it and to go to something else instead. Same way there's a difference between making a (counter-)argument and simply saying they're wrong.

    Remaining is roughly half of the thread's content, edited for staying on-topic (no need to explain how to do singletons in Ruby) and staying civil (insults are not appreciated). Background story in a nutshell: Jacques3 does not like PHP and has told people a couple times to stop using it, while ManiacDan has taken offense at that and risen to the perceived challenge.

    Moral of the story is that telling people to stop using PHP while in the PHP forum isn't a reasonable reply to a poster's problem. That goes for other languages and subject matters too. I myself don't mind if someone wants to compare PHP to something else and demonstrate PHP's pitfalls - of which it certainly has a few - but do so calmly, rationally, and in such a way that OP still gets the advice s/he needs. Likewise if someone wants to counter that argument then do not elevate the conversation to a fight. Anything more than a civil debate will not fly around here.

    As usual you are free to discuss this, or any actions I take as a moderator, with me over PM.

    --requinix

    ]]


    Thread split from here



    Originally Posted by zxcvbnm
    Declared the class static? I understand to how declare properties or methods static, but how can I declare a class static? We obviously can't say class static test_static. I wonder what you mean by that.
    Me too.



    Originally Posted by zxcvbnm
    About Constructor , I wasn't sure if it is neccessary to make is static.
    Please (re)read my reply. A non-static factory method (this is not to be confused with the constructor) doesn't make any sense whatsoever. When you want to get an instance of the singleton, you obviously don't have it yet. All you have is the class. So the factory method is necessarily static (that is, it belongs to the class).

    If you're not sure about that yet, just think about how you would implement a non-static factory method. What would that do? It must not create an instance of the singleton, because we already have one. So all it could do is return the object itself -- and that's completely useless. And it has nothing to do with the Singleton pattern.



    Originally Posted by zxcvbnm
    I had another go with this code I wrote and it works ok:
    Now it's correct, because now you've actually declared the factory method as static.

    Comments on this post

    • ManiacDan disagrees : You're playing the disagree game with someone with 500 times as many points as you?
    Last edited by requinix; October 17th, 2012 at 05:17 PM.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,690
    Rep Power
    6351
    "Declaring the class static" was me thinking of the wrong language, and having too much beer.

    Comments on this post

    • Jacques3 disagrees : factual errors regarding Ruby and questionable advice
    Last edited by requinix; October 17th, 2012 at 04:59 PM.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    57
    Rep Power
    12
    Originally Posted by ManiacDan
    PHP is very popular for leaning specifically because it's forgiving. This example, as you pointed out, would throw an error if you set the error_reporting high enough.
    This thread shows how "being forgiving" works in practice: not at all. zxcvbnm explicitly set the error reporting to E_ALL, which he (and probably everybody else who doesn't read PHP's changelog) thought would show all error messages and warnings. And what does PHP do? Since it thinks this severe mistake is only worth a "strict standards" warning and PHP doesn't include E_STRICT in E_ALL up to version 5.4.0, it stays silent -- which left zxcvbnm so confused that he opened a thread.
    Last edited by requinix; October 17th, 2012 at 05:00 PM.
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,690
    Rep Power
    6351
    PHP doesn't include E_STRICT in E_ALL up to version 5.4.0, it stays silent
    As you so eloquently pointed out, this is fixed already. Also, this is not an error, it shouldn't even really throw a warning, so strict alerts are fine for this.

    When I'm learning something, I want as much strictness as possible. No mistake should be left unnoticed.
    That's usually counter productive. "Close enough" is what new users should be going for, and refine their craft as they get more experienced. That's how learning works. My daughter is just learning how to stack blocks and play with Lego. Should I yell at her when she doesn't make the base perfectly, or will she eventually get to that point? Loose standards help you get to a point where something is happening.

    Which is why schools and universities use Java, Python, maybe Pascal -- but not PHP.
    My college is consistently in the top 20 for IT and engineering, and they taught me PHP.

    The only thing that's "object oriented" about PHP is that you can use custom classes.
    This is what's the opinion statement: The only thing that's object oriented about the language is its extensive object model. You don't think an extensive object model counts. I do. That's our opinions.
    Last edited by requinix; October 17th, 2012 at 05:01 PM.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    57
    Rep Power
    12
    Originally Posted by ManiacDan
    As you so eloquently pointed out, this is fixed already. Also, this is not an error, it shouldn't even really throw a warning, so strict alerts are fine for this.
    Seriously: Wouldn't it rather make sense to get an error (I mean an actual one) at the cause of the problem instead of hundred lines later at the next $this?

    There was actually a thread about this some time ago. It took us quite a while until we figured out why the hell $this was undefined (which I never thought is even possible).



    Originally Posted by ManiacDan
    That's usually counter productive. "Close enough" is what new users should be going for, and refine their craft as they get more experienced. That's how learning works. My daughter is just learning how to stack blocks and play with Lego. Should I yell at her when she doesn't make the base perfectly, or will she eventually get to that point? Loose standards help you get to a point where something is happening.
    I know this theory is very popular amongst PHP users. And there's actually something to it. Sometimes it's certainly better to display only half of the page instead of frustrating the user with error messages. Sloppiness is good when you're playing around with your very first programs or you just want to get your home page online, no matter if it actually works.

    But learning? Learning to me means that you actually want to understand what you're doing and do it correctly, not write your programs using "trial and error" (and maybe not even realize that you've done something wrong).

    And writing a small program isn't rocket science, right? With a basic understand of the language and a decent IDE, it's not impossible to get correct code.

    Let me phrase it like this: Sloppiness is good for a certain group of users for a certain amount of time. But after that, it's just bad. It let's you run into indirect errors and strange behaviour instead of plainly telling you what's wrong (so that you can correct it and not do it next time). Even if you want strictness, you have to work you way through the overly complex error reporting system.

    So you end up with confused users who wonder why the header of their website isn't displayed correctly. If they had used Java or something, they would have gotten a concrete error message to look up.



    Originally Posted by ManiacDan
    My college is consistently in the top 20 for IT and engineering, and they taught me PHP. You're like the Fox News of hating PHP.
    Does your college teach PHP as the main language in regular IT courses? I mean outside of "How to build a home page" excursions. That would actually surprise me.

    But I can tell you that's not usual.



    Originally Posted by ManiacDan
    This is what's the opinion statement: The only thing that's object oriented about the language is its extensive object model. You don't think an extensive object model counts. I do. That's our opinions.
    Yes, PHP does have a fully-featured object model in the newer versions. But the whole language with all its entities (arrays, strings, ...) and functionalities and error mechanisms is purely procedural. The only objects you'll ever come accross are your own (sorry, I forgot DateTime and some others).

    I mean, to realize this you don't even have to go as far as Java. Just take JavaScript as an example for an object oriented language.

    And not being object oriented isn't bad! I'm not saying that PHP is bad because it's procedural.



    Originally Posted by ManiacDan
    And by your own admission, Ruby has exotic syntax. There is no perfect language. PHP is a lot stronger than you think. Plus, this is the PHP forum with a question about PHP
    The fact that there's no perfect language doesn't mean that all languages are equally good. I'd rank PHP at the very bottom of (web) programming languages -- but maybe above Perl.
    Last edited by requinix; October 17th, 2012 at 05:03 PM.
  10. #6
  11. Moderator Emeritus
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Location
    Austin, TX
    Posts
    7,183
    Rep Power
    2220
    Jacques3,

    First, I want to state that myself and the folks at Devshed appreciate your participation, your membership, and the assistance you provide to our users and our community.

    Second, I'd like to point out that I'm the most senior Moderator of the PHP forum, and far too busy with my day job to spend as much time here as I'd like. I mention this not to throw my weight around, but more to highlight that, in order for me to jump into a conversation and add my $.02, something pretty drastic has to have occurred.


    What I'd like to say is this: PHP is open source.

    Those of us (like myself) who absolutely love to code in PHP do two things - we learn to live with it's idiosyncrasies, and we participate in fixing the underlying engine, so the next release is even better.

    That's the spirit of open source - if you don't like something, you don't have to suffer at the mercy of some faceless company that made the buggy software. You have access to the code. You can fix it.

    Fixing the problems in PHP - or any open source language, software, operating system, etc - can mean a lot of things.

    You can contribute code. You can test other folks' code, or submit useful, targeted bug reports. You can help write unit tests, or automated regression testing scripts. You can participate with the open source group managing the software or language in question and participate in road-mapping sessions for future releases.

    What we don't do, however, is complain about open source software, and not contribute to fixing it in some constructive manner.

    PHP is flawed, but it's also powerful. Some of the world's largest, most popular and/or most profitable companies rely on PHP. Facebook. Wikipedia. Digg. The list goes on and on and on. I personally have spent the last 3 years writing over 50,000 lines of PHP code - it works flawlessly, the software runs extremely fast, and (knowing PHP as well as I do) PHP allows me to do things that I simply cannot do in other languages, no matter how cleaner their syntax is, or how "less buggy" they are. But, again, I love PHP, and have learned to live with its craziness.

    We all get that PHP has issues. No one here will begrudge the issues that you've highlighted with PHP. We've all encountered them.

    However, the difference is this: When I run into an issue with PHP, I don't complain about it to random people on Devshed, and then point them to another language. When I find a problem with PHP, I tell Devshed users how to work around it, and I work with the PHP.net team to get that bug fixed.

    Frankly - and I think we can all agree - complaining about something, and not offering any concrete solutions, is just a huge waste of everyone's time and energy.

    If you dig another language more than PHP, that's awesome. Find a forum on Devshed (or any other online community) and make positive contributions to other users who love that language.

    If you really do dig PHP, that's awesome too - keep helping Devshed's PHP users.

    If you have complaints about PHP, that's fine too - but it can't stop at just complaining. Tell users how to write workarounds for those issues. Submit a bug report on PHP.net. Post on Devshed when your bug report gets fixed. If you're a C/C++ coder, crack open the source for the PHP engine, and fix the bug yourself. Help the PHP team test new engine releases.

    Offer solutions, not just problems. Don't complain; contribute.

    That's the spirit of open source. That's the reason why people come to Devshed. To learn, to share, and to contribute.


    Warm regards,


    DrGroove

    Comments on this post

    • Nilpo agrees
    DrGroove, Devshed Moderator | New to Devshed? Read the User Guide | Connect with me on LinkedIn

IMN logo majestic logo threadwatch logo seochat tools logo