17

I am an experienced PHP developer, and I would want to know what of both languages is better for web development.

I understand that there are a lot of factors to evaluate; but focusing in execution time, in your own experience making connections to a MySQL server, parsing and concatenating strings, and making several echoes (or prints), what language would you recommend me?

I cite this specific situations because are common for me, and I don´t calculate fibonacci sequences neither prime numbers, like are showed in several benchmarks.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Luis Arriojas
  • 561
  • 3
  • 8
  • 19
  • I'm not sure you would notice a difference unless you were really pushing the limits of either language. There are a lot of factors when it comes to performance and I don't think you can flat out say X language is faster than Y language. – Rusty Fausak Sep 23 '11 at 04:19
  • 3
    Can't believe this question is actually getting up votes. – Perception Sep 23 '11 at 04:24

1 Answers1

10

Even if things aren't specifically integer comparison or string comparison problems, looking at those computations is a decent indication of how the language will perform in more complex tasks. Keep in mind, though, that web development isn't all about computation speed. Unless you're doing some fancy backend data processing (in which case PHP is really not appropriate) when it comes to things like generating pages: it's still often worth the small sacrifice in terms of speed/memory to make it much, much easier to develop.

Also: Python+MySql is kind of a pain, in my experience. It can be done. But it's not nearly as nice.

Which is faster, python webpages or php webpages? <- lots of stuff here

Community
  • 1
  • 1
Turnsole
  • 3,422
  • 5
  • 30
  • 52
  • 5
    No mention of opcode caching makes that a pretty useless benchmark. – ceejayoz Sep 23 '11 at 04:15
  • The author's comment that `The Neither column is the one that should be used to compare the four languages really` basically decimates your argument: that has PHP operating on parity with Python. – cwallenpoole Sep 23 '11 at 04:25
  • I never argued they had any kind of parity. (?) – Turnsole Sep 23 '11 at 04:27
  • 2
    @Hydrangea That's the problem. You say that Python will kick PHP where the sun doesn't shine, but then you cite a source which says that they are more or less on par with each other. – cwallenpoole Sep 23 '11 at 04:29
  • Python executes faster than PHP "at pretty much everything". How is that even remotely controversial on a programming forum? – Turnsole Sep 23 '11 at 04:32
  • @Turnsole Without proof, or at least a citation it is just a comment. This said: Your link is broken, so now even your only "proof" is gone ;) – KingCrunch Dec 09 '13 at 12:50
  • @KingCrunch: Now you're just being a troll. I never used the word "proof", since the OP asked about comparing execution time I linked to a blog where someone had done that comparison. Two years later, it really surprises me that people are still even commenting on this thread. Why not just vote for it to be deleted, if it offends you so much? – Turnsole Dec 09 '13 at 15:50
  • @Turnsole "Two years later, it really surprises me that people are still even commenting on this thread." Welcome to the internet, you must be new :) But seriously: You said it is not "even remotely controversial", so it's also your turn to proof that. It doesn't offend me. I was just looking for sources and not just opinions. – KingCrunch Dec 09 '13 at 21:40
  • @ceejayoz Python does auto opcode caching doesnt it? isnt this why the .pyc appears automatically? – DEzra Dec 24 '13 at 11:18
  • Python is quicker than PHP. It's not just about math operations, but think about large systems. If you think about a web system in python (why would, otherwise, compare python against php?), the classes are initialized once - perhaps you have a bunch of init code. In PHP you have autoloads to partially solve the problem of getting the classes you need without bulk-loading everything but in python that problem does not exist at all. In python you can even have a "dumb cache" in a central context. In PHP you don't have a central context and are forced to install an external cache. – Luis Masuelli May 23 '14 at 16:35
  • for short programs (scripts) PHP wins because Python has most of its stuff in modules it must load, while PHP has them in the core. But if you run a long-term race with both languages competing, Python runs again. Under some circumstances Python is even faster than Java and (under even more narrower conditions) nearly as quick as C. – Luis Masuelli May 23 '14 at 16:37
  • "Python+MySql is kind of a pain" - wat? If you use raw SQL - there is no difference between PHP and Python. And if speak about ORM - there are many good ORMs for Python. Tell me which ORM for PHP is better than any ORM in Python. – Gill Bates Jan 09 '15 at 07:55
  • @LuisMasuelli what about Ruby on Rails?? what is its performance ??? VS PHP and Python ??? – Bilal Maqsood Aug 11 '15 at 10:42
  • @BilalMaqsood Not sure at all - never used it. – Luis Masuelli Aug 13 '15 at 14:54