PHP versus Django or Others

Realistically though, for a beginner to think that replacement of the final physical software is going to take more than 5% of the expended effort getting to that point, is overly optimistic. This is the main reason for recommending to 'just get it going' using acceptable tools - I've seen plenty of decent PHP systems and wouldn't wish the complexity of what I use on a beginner.
 
I didnt know that about PHP7. Interesting info. Definitely the way to go before my sledgehammer suggestion
 
I didnt know that about PHP7. Interesting info. Definitely the way to go before my sledgehammer suggestion
Yeah, even if you don't need the performance, move. On some client sites we moved to PHP 7 once Hetzner allowed, on average cut the load time by about half a second while bringing down resource usage.

Note newer PHP 7 code focuses on actually ignoring useless code/optimizing it, so it's becoming more beginner friendly. I'll see if I can find the talk.

EDIT:
Found in my history by typing in the creator. :D
 
It's faster than python and it has switch cases, php7 is life.
 
It's faster than python and it has switch cases, php7 is life.
I like switch cases, but python does have a nice alternative way of doing it.
Python:
def switch_demo(var):
    switcher = {
                1: "Jan",
                2: "Feb",
                3: "March",
                4: "April",
                5: "May",
                6: "June",
                7: "July",
                8: "August",
                9: "Sept",
                10: "Oct",
                11: "Nov",
                12: "Dec"
    }

    return switcher.get(var,"Invalid Month")

var = int(input("enter a number between 1 and 12"))
print(switch_demo(var))
You can do it a bit differently as well, but that was my use case specific. It's actually pretty neat.

Python:
def my_switcher(switching_var, parameter1, parameter2):
    return {
        "start": start(parameter1, parameter2),
        "end": end(parameter1, parameter2),
    }.get(switching_var, unknown(parameter1, parameter2)) #second is default

   
#make sure to have function name.
def start(parameter1, parameter2):
    #does something
   
   
def end(parameter1, parameter2):
    #does something
   
   
def unknown(parameter1, parameter2):
    #do default
 
Last edited:
That's pretty neat
Yeah, you need to take into account what switch cases are for. The compiler in python can't really optimize it due to how it works, so not really needed for performance. The only thing I miss about it is the fact that I can better structure code, which the example I posted allows me to do.

I used it to match users' state to a function call, so if they disconnect I can know what they were currently doing and resume at the same state. Was a problem with the framework I was using (and yes, I was using python specifically due to a ML package). Ended up being easier to write it in Java as the framework was more feature rich/less buggy there and using a webhook to do the ML heavy lifting when needed. Was my specific use-case though.

EDIT:
as a side note, do note benchmarks will be a bit different to real world.
Python 3 has a large cost to call for the first time/initialization, and then it will stay in memory and be low cost for any subsequent calls.
PHP will pay for every initialization. Again, both can be tweaked to be like the other in the way they handle it, but for most use cases you won't really see too much difference between PHP and Python.
PHP has not been slow since PHP 7 (and I could even argue PHP5).
Your use case will define your choice, e.g. in PHP I can't start multiple threads to parallelize something unless you hack it, then python would be better.

As an aside, anything but Node.JS :p

These are about java vs PHP vs Node vs Go, but again, this is not really apples to apples, each language has its strengths.
1539261841672.png
1539261883316.png
1539261893910.png
https://www.toptal.com/back-end/server-side-io-performance-node-php-java-go

Do note in the above for some reason the dude used PHP5.4 and not PHP7. It will beat Node in every single one of these tests.

If you follow that, we should all move to Go, but if team is more familiar with Java, why not go for that? :p

A lot better a benchmark is this: https://www.techempower.com/benchmarks/
 
Last edited:
And yet I keep telling people that Node is hopelessly inefficient, and dimwitted to config properly.
 
It's faster than python and it has switch cases, php7 is life.

The "speed" of a language is by and large irrelevant. When was the last time a language's speed was a hindrance? If speed is a real concern you should look into Go, C etc. and fix your architecture (and I'm not talking about how you structure your classes).

What is more important most of the time is tooling, ecosystem, ease of use on developer machines, language features etc.

PS: Pretty sure Python is amongst the "slowest" out there, but if you want to speed it up you can always use PyPy but some third party libraries won't work... never bothered using it myself though.
 
It's faster than python and it has switch cases, php7 is life.

Code:
if val == 'switch':
   print('cases')
elif val == 'are':
   print('pointless')
else:
   print('it is true')
 
Top
Sign up to the MyBroadband newsletter
X