Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Posts
    2,567
    Rep Power
    171

    Php vs python. Is this valid argument?


    I dont know about python but i like to know, does this make good sense?
    When developing web applications, I started working mostly in PHP because it was the easiest language to leverage, having many large open source applications and class libraries readily available.

    However, PHP has a number of serious flaws that make it substantially less productive than some of the alternatives. In short, PHP lacks namespaces and decent object support. This makes it hard to scale PHP applications effectively without a great deal of programmer discipline. It also means that when you import various PHP applications into your own application you often end up with problems.

    PHP5 introduces namespaces to PHP but the need for backward compatibility nerfs them to the point of absurdity. You can read why they are such a good idea in PHP - http://www.sitepoint.com/php-53-namespaces-basics/ - but you will be much better off using a language that supports them properly from the bottom up.

    Over the past four years, I've migrated steadily towards working mostly in Python. Unlike PHP, Python is an excellent language with very good object support and namespaces.

    It matters to my clients even though they don't care about computer languages; while PHP can create a simple website very quickly, its productivity is eclipsed by Python as soon as there are more than ~1,000 lines of code in the application. Before long, Python is literally ten times more productive which means I can build applications for my clients much faster with Python.

    FWIW, if you want to learn OOP quickly and easily, sign up for https://www.coursera.org/course/interactivepython which is free. Virtually all Python programming is object oriented and the course is well regarded.

    move on from PHP though - if you have any substantial jobs to do, you wont regret it.
    Last edited by English Breakfast Tea; August 20th, 2013 at 05:04 PM.
  2. #2
  3. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    501
    Rep Power
    127
    It sounds like someone drank the Kool-Aid.

    Namespaces and OOP in PHP5+ are quite powerful and becoming even more so.

    And...
    PHP5 introduces namespaces to PHP but the need for backward compatibility nerfs them to the point of absurdity.
    ... doesn't even make sense to me.

    If you think your application might go on a server with some old version of PHP then, sure.. you'd have to account for that. But in all my years of programming I've never had to deal with a version of PHP that's that old.

    Python came out when PHP did have some weaknesses, but those don't exist like they used to. Between PHP and Perl it's Python that I can't find a justification for. Even Perl is kind of antiquated and I do simple cli in PHP now, too.

    Comments on this post

    • Jacques1 disagrees : Gosh, are you on your period?
    LinkedIn: Dave Mittner
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,910
    Rep Power
    1045
    Hi,

    you know what? Instead of waiting for us to tell you what's right and wrong, why don't you grab a Python tutorial and see how you like it?

    Really, I don't think we need yet another "PHP vs. x" discussion. There are tons of articles explaining exactly what's wrong with PHP, and there are thousands of people who'll tell you that PHP is the greatest language ever (or at least not quite as bad).

    Check out Python, Ruby and maybe Perl. Weigh the advantages and disadvantages. Are you even willing to learn a new language, adopt new ideas, approach things in a different way? Will you be able to install the language everywhere you need it? etc.

    Then decide.

    Comments on this post

    • dmittner disagrees : Nothing wrong with a person asking advice of his peers, trolleo. Especially when questions like your last can be answered by others.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    6
    Rep Power
    0
    Personally from using both PHP and Python, and this is just my opinion, I've found PHP much easier to use. As for not working as wellwhen codes his 1000+ lines of code, if that were true then the majority of forum systems wouldn't work as they are usually all at least 5000+ lines once you include the multiple files.

    The simplest way to keep PHP file size down to a minimum is only include exactly what is needed, and frankly I've not really found anything PHP hasn't been able to manage when I've needed it to.

    As for python, I've found it slightly harder to learn, but similar to PHP in may ways. I prefer Python when I need something to run in the background of a server, such as an IRC bot, when I can't run it on my windows desktop all the time.

    As said before, everyone will have different opinions on what works best, and it is up to you to decide.
  8. #5
  9. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,745
    Rep Power
    9397
    Barring trolling, every single one of these "X > PHP" diatribes falls into one or more of the following categories (many of which apply to any "X vs Y" debate):

    1. The poster hates PHP because it is not X. That's all it comes down to. They believe that PHP is bad because it does things differently, or doesn't support the same features, or doesn't offer the same community, or doesn't have the same framework, or is otherwise not a super-set of X.
    Probably hasn't used PHP for more than a few days and sees no reason to try it again.

    2. The poster hates PHP because they've drummed up reasons to hate it. There is a large community of people who loathe it and for whatever reasons they can think of: loose typing is evil, interpreted code is evil, backwards compatibility is evil, irregularities in the language are evil, a language which has evolved over decades is evil, etc. Some arguments have merit, some do not. They are invariably eager to elaborate on particular issues and/or to enumerate their entire list of reasons.
    Probably hasn't used PHP for more than a few days and will never look back.

    3. The poster hates PHP because they've been told to hate it. They read that PHP is evil and they trust the sources enough to adopt their beliefs.
    Probably hasn't used PHP at all but has no real, personal, vested interest in avoiding it.

    4. The poster hates PHP because of the people who use it. PHP does have a low barrier to entry and lots of piss-poor programmers will pick it up and write piss-poor code very easily, but the fact is that they would write piss-poor code in any language they try.
    Probably hasn't used PHP at all but has been exposed to the aforementioned programmers. Infers that PHP must be bad because the programmers are bad and will thus stay away from it like the plague.

    5a. The poster is an evangelist for X. They love X and will argue against any other language.
    Probably has used PHP for a while, and may have built up a reasonable amount of experience with it, but discovered and ultimately converted to X. Sees X as the perfect language and cannot understand why anybody would use a different language.

    5b. The poster is an evangelist for X. They have a special grudge against PHP and will do what they believe to be a moral duty to convert PHP developers away from it.
    Probably has used PHP for a short time but had a frustrating experience that led them away from PHP and to X. Assuming many other people are having the same problem, they will proselytize for X.

    Comments on this post

    • ManiacDan agrees : You saved me a lot of time by just writing what I was already thinking
  10. #6
  11. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Posts
    2,567
    Rep Power
    171
    I really think dmittner and Jaques1 should get together and have a beer, I'll pay.

    Comments on this post

    • requinix agrees : THUNDERDOME
  12. #7
  13. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    501
    Rep Power
    127
    Originally Posted by Rayth
    Personally from using both PHP and Python, and this is just my opinion, I've found PHP much easier to use. As for not working as wellwhen codes his 1000+ lines of code, if that were true then the majority of forum systems wouldn't work as they are usually all at least 5000+ lines once you include the multiple files.
    Yep. My largest app is somewhere in the vicinity of 75k lines of code. With proper OO programming you shouldn't have much repetition, so minimal reason to have bloat at a certain line threshold.
    LinkedIn: Dave Mittner
  14. #8
  15. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,910
    Rep Power
    1045
    And that's exactly why I suggested not to go down that road.

    Does PHP suck so much that you immediately feel the need to apologize for using it?

    "But it's not that bad. I've written great apps in it!"
    "The people hating it have the wrong reasons for hating it!"
    "I like it much better than x!"

    Calm down. No need to feel ashamed for being a PHP programmer, especially not in a, um, PHP forum.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,865
    Rep Power
    368
    speaking of namespaces, (that link to sitepoint was brilliant btw). I have a question,

    I could have structure as:

    classes
    project_1
    project_2

    then in each project include appropriate folder?

    So my question is why is namespaces a better solution then doing this?
  18. #10
  19. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,660
    Rep Power
    4123
    Originally Posted by paulh1983
    speaking of namespaces, (that link to sitepoint was brilliant btw). I have a question,

    I could have structure as:

    classes
    project_1
    project_2

    then in each project include appropriate folder?

    So my question is why is namespaces a better solution then doing this?
    name spaces are not a so much a "better" way of doing what you're doing but more to do with grouping of your code. For example, using namespaces I can include 2 classes called "email" (eg one for rendering, one for sending) by having them in different namespaces, eg

    Code:
    /libs/email/email
    /views/email
    You could still use namespaces and have a namespace for classes, and a namespace for project_1 and project_2

    project_n van then shortcut classes by the "use" keyword
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,865
    Rep Power
    368
    thanks
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    144
    Rep Power
    4
    I've written (and still maintain) some moderately large projects in PHP, but honestly after trying out some Python frameworks I prefer to work in Python. It's just not always a practical option for deployment, whereas PHP is ubiquitous (think cheap shared web hosting).

    PHP gets bad rap, but like most things some of it is deserved and some not so much. PHP arguably has some warts, but a lot of it comes down to personal preference or domain-specific needs.

    I think the important thing for developers is neither to throw away good tools because someone else doesn't like them, nor to construct a mental bunker in which you convince yourself that some language is the only one you ever need.
    Last edited by admoore; August 21st, 2013 at 08:52 AM.
  24. #13
  25. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    501
    Rep Power
    127
    Originally Posted by admoore
    I've written (and still maintain) some moderately large projects in PHP, but honestly after trying out some Python frameworks I prefer to work in Python. It's just not always a practical option for deployment, whereas PHP is ubiquitous (think cheap shared web hosting).
    How do you find Python to be better?

    For me the criteria would be:
    - Features
    - Readability
    - Syntax consistency with other languages
    - Portability
    - Performance
    - Level of support

    Readability is something of a personal perspective and there are things I like about Python's syntax, but a lot that I don't like, too. I guess I'm just curious where you think Python gains the overall advantage.
    LinkedIn: Dave Mittner
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    144
    Rep Power
    4
    Originally Posted by dmittner
    How do you find Python to be better?
    I am almost certain that if I answer that question, I'm going to have people arguing every one of my points into the ground, or dismissing them for some contrived reason.
  28. #15
  29. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,745
    Rep Power
    9397
    Originally Posted by admoore
    I am almost certain that if I answer that question, I'm going to have people arguing every one of my points into the ground, or dismissing them for some contrived reason.
    Go ahead and we'll see what happens. I'm sure all of us here are capable of allowing someone to voice their opinion without harsh criticisms, right? There aren't too many very vocal people here and not as much fanatical love of PHP as you might think.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo