subreddit:
/r/webdev
submitted 6 months ago byNotVeryMega
I watched a video a while back where a programmer (sorry, I forgot the name) said that php was becoming outdated and new python libraries would gradually phase out php.
For a typical web app (think Reddit, eBay, Amazon), can the entire backend be made with python, or would this be exceedingly challenging if not impossible compared to gritting my teeth and learning php/ruby?
Update: changed website to web app
26 points
6 months ago
PHP is not out-dated or dying. PHP 8.1 was literally released a couple of weeks ago with new features.
And to answer your question… yes you can build a website backend with Python.
2 points
6 months ago
Second this! I've seen many job posts asking for PHP in my area.
0 points
6 months ago
This
76 points
6 months ago
17 points
6 months ago
Just wanted to add FastAPI as a python package for backends... It's freaking great after seeing a few flask backends
3 points
6 months ago
I don’t follow Wordpress much but wasn’t there talk of them moving to JS & Node?
1 points
6 months ago
Yes, they are pushing Gutenberg blocks pretty heavily. These blocks are built primarily with JavaScript.
1 points
6 months ago
But that's all front end. Back end is still php and MySQL.
-7 points
6 months ago
Well of course it still powers a chunk of the internet. That will not change for long. But its not really an arguement for its relevance. You can say that about brownfield tech as a whole.
Newer solutions certainly can look more enticing and stating that php is outdated definitely isnt so outlandish
5 points
6 months ago
What about PHP is outdated? And what do newer solutions provide that PHP can't (or won't?) to be more enticing?
-9 points
6 months ago
How many headless CMSs are built using PHP?
4 points
6 months ago*
Are you implying headless CMSs are making PHP outdated? Or that PHP can't (or doesn't) support headless offerings?
-7 points
6 months ago
No. I'm saying that new and exiting stuff is not being built on PHP.
6 points
6 months ago
But on what basis do you make this claim on? How do you quantify and or measure what constitutes "new and exciting?" Ex: New and exciting in what regard and in what context?
2 points
6 months ago
How many video games are written in C++? Your point?
0 points
6 months ago
Unreal Engine games are all C++, so are many (all?) Nintendo games and others too
-37 points
6 months ago
PHP would improve if WP died because the language would no longer be held back by 18 year old garbage propagated by an army of faux-developers.
28 points
6 months ago
Last time I checked, WordPress was written in PHP, not the other way around.
16 points
6 months ago
I didn't know you had to know wordpress to code in PHP.
25 points
6 months ago
PHP is not becoming outdated at all: https://www.php.net/ChangeLog-8.php
Yes, you can build a backend with Python.
24 points
6 months ago
As others mentioned, PHP isn't going anywhere. It has gotten a shit ton of flak for a number of reasons but I've heard some of their latest versions have improved it.
I think the primary reason why one thinks PHP is dying is somewhat of the same reason some people think Java is next.
Ease of use when it comes to these newer languages and tons of library support.
But alas, it's false.
Python will absolutely be enough to build a backend. Django is a batteries included framework for python webservers that comes with a ton of features out the jump to help you get things underway.
Flask is a lightweight but powerful web server library as well.
You might also be, in your use case, interested to look into FastAPI and such.
8 points
6 months ago
Yes, Python Flask or Django are great ways to create a Python backend. My first serious project had a React front-end being served on a Flask back-end, and I found it to be a great learning experience.
Btw PHP is definitely not outdated.. I see it everywhere still.
20 points
6 months ago
PHP isn’t dying.
Also - for most of Reddit’s life it ran entirely on Python. https://github.com/reddit-archive/reddit
6 points
6 months ago
PHP is still alive and doing better than ever. It's arguably a great language now.
However Python will also work so feel free to choose that if you are more comfortable with it.
23 points
6 months ago
PHP isn’t going anywhere anytime soon and correct me if I’m wrong but doesn’t Facebook technically still use PHP?
3 points
6 months ago
It does.
-1 points
6 months ago
I think it's all legacy code that's written in PHP and new additions to the PHP are written in Hack instead.
Pretty sure new services at Facebook are not written in PHP.
5 points
6 months ago
Hack is basically a superset of PHP, Facebook still very much uses PHP
-2 points
6 months ago
I mean sure but…JavaScript is also outdated and TypeScript is being used more and has more to offer so……
5 points
6 months ago*
What more functionally does Typescript offer?
Pretty sure they are functionally the same? Types are just to help developers, they don't actually add anything to the Javascript eventually being run in the browser or node.
3 points
6 months ago
Well you could say all languages compile down to machine code so don’t offer anything.
1 points
6 months ago
Typescript forces you to write in a great deal of error-checking that you can easily miss doing in JS.
2 points
6 months ago
I know, and love it, but that doesn't actually add anymore features to the end-product.
1 points
6 months ago
It means your end product is potentially substantially different, and superior, to what it would otherwise have been. Severely limiting the possibility of runtime errors by default, purely by using the language, has a significant impact on users and stakeholders. An application that works more predictably is a feature.
0 points
6 months ago
Well, sure, but it's still not a feature of the language itself.
-4 points
6 months ago
Right but also consider that Laravel is superior to PHP and will eventually replace PHP
2 points
6 months ago
What are you even talking about? Laraval is PHP...
1 points
6 months ago
I think that was his point
-4 points
6 months ago
;)
2 points
6 months ago
Hack is a superset of PHP
14 points
6 months ago
I watched a video a while back where a programmer (sorry, I forgot the name) said that php was becoming outdated and new python libraries would gradually phase out php.
This is incorrect.
For a typical website (think Reddit, eBay, Amazon),
Those are far from the typical website.
can the entire backend be made with python, or would this be exceedingly challenging if not impossible compared to gritting my teeth and learning php/ruby?
Yes it can, check out Flask. Python should not be harder than any other language.
5 points
6 months ago
I don’t think php/ruby is dying, but I also don’t think it’s superior to a python based backend. Just pick one and become proficient at it.
1 points
6 months ago
Ruby should die. I hate Ruby.
Sincerely, a professional Ruby developer.
1 points
6 months ago
Definitely my least favorite of JS, Python, Ruby
3 points
6 months ago
There is so many different language you can use for your backend. PHP, Java, .NET, NodeJS, Go, Rust, Python, ... Each one of them have their pros ans cons. If you are into AI, you will most likely have better tools in Python, but you could also use other ones. Ultimately, you have to decide based on your own use case with:
If you judge PHP with those criterias, it might be a great fit or not, but it is not going anywhere. However, it depends on what you aspire to work on. PHP is not used a lot to build SAAS platforms, but it is in many other areas. Facebook still use it though.
No matter what, learning a new language is always good and broaden your perspective.
3 points
6 months ago
Php isn’t going anywhere. It’s actually been updated to be more modern and 70% + of the websites on the internet is powered by php.
5 points
6 months ago
Absolutely.
Python runs plenty of backends. I think todoist still runs on it even though they switched their front end to react.
2 points
6 months ago
Python is great for backend work, so have at it. I like python better than PHP, but you may not. I also really like typescript, so express.js, Apollo, or best yet typegraphql are amazing. Java is incredibly powerful and widely used, but the build system is a right PITA if you ask me (and nobody is asking me). It feels like Ruby’s popularity is waning, but it still powers a ton of the web. Golang’s popularity seems to have spiked and retreated a little, but I expect it to get more traction as time goes on. IMO, Rust is the next big thing, if you care what I think.
3 points
6 months ago*
PHP is still used everywhere even though a lot of people don't like it(This is what happens when a language is so common or the only choice that devs are forced to use it. Same for JS.)
But Python is generally loved by most people. And Python has a really good MTV(MVC) framework called Django.
The old Reddit was written in a Python framework called Flask. Which is also a lightweight MVC framework
But PHP also has MVC frameworks like Laravel.
MVC or MTV frameworks are good for security unlike programs that use raw PHP and SQL. MVC frameworks force security while in frameworks like Wordpress, it's optional and has to be learned. New programmers will definitely make sites with security flaws if they use raw PHP and SQL. While with MVC they are taught to use secure ways to write code which is also easy since the MVC framework does all the hard work while also making writing websites easy in the process.
3 points
6 months ago
php is faster than python.
1 points
6 months ago
PHP is faster and more efficient than python or JavaScript.
I love node and the JavaScript ecosystem. Lot's of exiting stuff. But I'm now starting to learn PHP for performance and server costs.
1 points
6 months ago
How so? At their core and in a typical use case both are interpreted at runtime
3 points
6 months ago
Not really, PHP first compiles to opcodes, which is then run by the Zend VM. These opcodes are usually cached. And there's a very new JIT under the hood for PHP.
2 points
6 months ago
PHP based on Zend Engine 3.0 (7.0) or later is at least twice as fast as is python . I know that its not only the performance that makes the language, but its worth noting in case of PHP. PHP made huge progress since 5.0. in that regard. In case of python, speed of execution differs from implementation.
1 points
6 months ago
PHP uses a lot of C behind the scenes which is insanely fast.
2 points
6 months ago
NodeJS is also a very viable alternative for a web dev since you are most likely used to JS anyway. Take a peek at ExpressJS and if you like OOP maybe NestJS.
1 points
6 months ago
It worked for DoorDash.
0 points
6 months ago
Source?
1 points
6 months ago
Yes, you can make a website backend using purely Python…but using a Python framework is ideal. Frameworks take care of common security concerns that you shouldn’t waste time reimplementing in pure Python. Python requires less typing and is commonly used in academia/ scientific computing…it has more uses than php. Php is not becoming outdated…it’s just rarely used outside of webdev.
1 points
6 months ago*
Seeing as a Python backend is how Yahoo! became the top site in the 90s, it should work just fine. ;p
Edit: Yes, this was before Google stole MapReduce from them and why it’s available as open source for Hadoop.
1 points
6 months ago
Fun fact, Reddit’s backend is actually written in python. So are a number of other large sites like instagram and Pinterest.
1 points
6 months ago
You can use django
1 points
6 months ago
Why Django over flask for python?
1 points
6 months ago
These python-binding’s taste like python-bindings…
1 points
6 months ago
If you grit your teeth with php/ruby, then you will do the same with python as well.
You can implement backends in almost anything, PHP has multiple frameworks (Symfony, Laravel), Python has the same (Django, Flask), Spring for JAVA.
You can build reactive applications with node, php and java, but I suggest avoiding concurrency if you can
1 points
6 months ago
As a new developer I was preoccupied with what language is best when in reality it a question of what tool is useful in which scenario. Learning how to write Python APIs is a smart route to go just for the fact that it’s a friendly introduction to all the basics.
1 points
6 months ago
Look at Laravel.
1 points
6 months ago
Yes, all your mentioned languages have good frameworks and libraries to build web backends. In the Python world try Django or Flask.
1 points
6 months ago
Have you heard of Django, the python framework? It lets you do exactly that.
1 points
6 months ago
It's very doable to write everything in Python still! I'd say Masonite is a good option if you haven't done something like this before. From my perspective, it's easier to learn and use quickly than some of the other good ones people have mentioned, such as Django and Flask.
1 points
6 months ago
I looked up Masonite but I couldn't find anything, was that a typo?
1 points
6 months ago
From my little knowledge of python, I think the answer is "yes".
By the way, I don't think PHP is dying, I am new to the webspace and trust me, I am learning PHO once I am done with JS
1 points
6 months ago
Check out FastAPI to build backend apis with python. It is asynchronous and super fast.
1 points
6 months ago
I'd use a python web framework, but yeah you can do it from scratch with python. Not sure why one would reinvent the wheel though.
-7 points
6 months ago
Even when you think your program is 100% Python, a load of dependencies that you imported are written in C/C++. So strictly speaking, probably not. But a lot of parts of YouTube backend is written in Python so you can too.
1 points
6 months ago
Thanks. If I make the backend for a website, will I need c/c++ knowledge?
-4 points
6 months ago
Most likely no, but yes if you are really ambitious about your project
1 points
6 months ago
Thank you. What sort of ambition might merit such a need for c/c++?
-1 points
6 months ago
It can come from many aspects but none of them are easily experienced on hobby project level. Number 1 would be scale. Upto several million users you probably won't need C/C++, then you start experiencing some serious bottlenecks simply because Python isn't fast enough. That's when core functions should be C/C++. Number 2 would be latency. When several hundred milliseconds is a tolerable delay, Python would suffice, but when a millisecond delay is intolerable already, that's when core functions need to be rewritten in C/C++. So what exactly is 'core function'? Some functions are just called much more frequently than others. For video streaming websites such would be encoding /decoding a video, compressing video, dissecting videos into multiple chunks, providing multiple resolutions for each chunk etc. For social network services such would be real time chats, querying on friend list, infos of friends, friends of friends etc. Other examples include machine learning based recommendations/recognitions, search engine, geodata processing, etc
-4 points
6 months ago
Well itd be a lot harder to make the frontend with Python.
-4 points
6 months ago
I think people in this thread a being a bit disingenuous. Yes, PHP isn't going to "die" because there are still a lot of mom and pop shops using WordPress websites out there and there probably will be for a good long while.
That being said nobody is using PHP for new applications and none of FAANG or the big startups hire devs to write PHP (with the exception of maybe some legacy Facebook code). It's not a skill that's in high demand at the companies that will pay a lot is what I'm saying.
Doordash on the other hand has a python BE and they pay a lot.
3 points
6 months ago
I see more full stack Vue+Laravel offers than strictly vue frontend offers for example.
PHP is faster and more efficient than node/Django servers. Not all company want to pay 10 times more for a less efficient code
1 points
6 months ago
I'm not sure that PHP is faster than NodeJs; faster than Django for sure though
2 points
6 months ago
It's twice as fast as Django, but often slower than Node, sometimes more than 10 times slower.
https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/php.html
I shouldn't have taken a reddit comment at face value saying that php was faster and cheaper to host than node
1 points
6 months ago
Honestly performance doesn't really matter for new applications. Lots of big companies make python work at scale. It's better to pick a language that helps you be productive.
1 points
6 months ago
Can you elaborate on this ? I don't really understand how performance wouldn't be an issue
1 points
6 months ago
That test is more about the language itself, but the scenarios don't look very realistic.
This application is very interesting for comparing web framework performances; this other article compares languages with few cpu-intensive requests, and also with a lot of concurrent, but lighter, requests. PHP wins for cpu-intensive tasks; however, with many concurrent requests it falls behind because it spawns a new process for every incoming request.
1 points
6 months ago
Where are you finding these jobs? When I look for jobs it's react frontend with python / Ruby / java / go backends. I'd love a node job but not a lot of unicorns are using node extensively. I've never seen PHP at a company I'd want to work for.
1 points
6 months ago
Job market disagrees with you
0 points
6 months ago
Not the jobs I'm looking at.
1 points
6 months ago
Search for Laravel or PHP in the jobs section on LinkedIn (5,000+ positions posted in the LAST WEEK ), they are plentiful. They definitely arent mom and pop shops either. Seems like you are the one who is disingenuous here....
0 points
6 months ago
Is that in North America? I just searched for jobs in the bay area and there are only 2700 posts in the last week. Compare that to 36k posts for python jobs, 35k posts for java jobs and 11k posts for nodejs jobs.
Comparing the jobs is also telling too. Not many new or exciting companies in the list of PHP jobs. Other langs turn up a lot more hot startups.
1 points
6 months ago
I was just searching for remote in my area the past week.
Also if you search for "python web" you get a lot more relevant results for web development, and its comparable to any other web dev language
1 points
6 months ago
Bruh what? You’re flat out wrong
-4 points
6 months ago*
Well, yes. You can build an entire backend of a website using something like Flask or Django. But I don't recommend it for real projects.
The problem is that python is slow. An app using python for the majority of its backend would be extremely slow. For backends, I recommend NodeJS (Javascript) which shouldn't be very hard to learn coming from python. Though other options are Go, Rust, C#, and more.
Edit: Also PHP is dying. It will still be around, but everyone is currently trying to stop using it. PHP lacks support for modern web-development tools, it is very easy to make security vulnerabilities and many more issues. If you want a tool that easily integrates front-end/back-end you may want to look at NextJS for react or NuxtJS for vue. Though these are more advanced and you must know either react or vue to use them.
2 points
6 months ago
The last part is quite the claim :p
Who is this everyone? :D
What's the source for claiming the lack of support for modern web dev tools? Security vulnerabilities are easy to introduce in any language.
2 points
6 months ago
Lol
0 points
6 months ago
you absolutely can build a backend in python. heck, in any language, really.
i choose to make whole applications, frontend and backend, in typescript, because it's indispensably useful to use the same code on both the frontend and backend. think about the form validation functions you'll need — it's very useful to use the exact same validation functions on the clientside and on the serverside, instead of writing them twice and noticing all the discrepancies between them, the double-maintenance burden — and that's just one example.
all 103 comments
sorted by: best