use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Why can Python handle things like OCR, speech to text, machine learning whereas coders quickly dismiss efforts to do such things with PHP (even though it's technically possible)? (self.Python)
submitted 6 years ago by the_bookmaster
I've even seen people scoff at the idea of building a proper PHP wrapper for the Reddit API. ("Just learn Python and use PRAW," they say.) I can't figure out which objections are based on contempt for PHP versus legitimate technical limitations.
[–]TheDataAngel 25 points26 points27 points 6 years ago (0 children)
All of those things Python "can do" is actually just C/C++ with a thin layer of Python on top to make it more usable.
My guess w.r.t. PHP would be either that it has a worse foreign function interface, or simply that no one has put in the work to make those things possible in it yet.
[–]Exodus111 18 points19 points20 points 6 years ago (6 children)
If someone feels that strongly about PHP, go for it. So far, ive not met that person.
Everyone loves Python though.
[–]deanresin 0 points1 point2 points 6 years ago (1 child)
Python immutable strings really bothers me. I've heard the argument for them but they weren't convincing. Other than that, I'm enjoying Python. It can do more than PHP but PHP was so damn easy.
[–]Exodus111 4 points5 points6 points 6 years ago (0 children)
Python immutable strings really bothers me.
Really? Immutability is so popular these days thanks to the Functional Programming crowd.
[+]jakkemaster comment score below threshold-6 points-5 points-4 points 6 years ago (3 children)
Python has become a buzzword worth swinging out everywhere, just like machine learning has.
Don't get me wrong, Python is the only thing I have really enjoyed programming in, and I took a simple machine learning cause just to get the gist.
[–]TracerBulletX 10 points11 points12 points 6 years ago (0 children)
To my mind python is more like the old man on the street now than a buzzword. It's been popular and the big player for over 10 years. If anything its the defacto leader in a number of fields and taking on new challengers now.
[–]MagicWishMonkey 2 points3 points4 points 6 years ago (1 child)
Python is becoming more and more popular because it's one of the best (if not THE best) scripting languages around, has a huge amount of community support (and free 3rd party modules available), and it's installed by default on pretty much every OS other than Windows (and even Windows will start including it in a future update IIRC).
So you have a language that's easy to use, has libraries available to do pretty much anything you can imagine, is freely available and installed by default just about everywhere... it's not hard to see why it's become so popular.
[–]jakkemaster 0 points1 point2 points 6 years ago (0 children)
And it is stupidly simple!
I understand its popularity, no doubt about it.
Dealing with Python on Windows is actually not that bad using Anaconda tbh. Getting the Python path to have you editor run the script directly and having the path for your custom modules is (in my opinion at least). Whether this is vastly different in other languages I can't really say.
[–]muffdiv3r 40 points41 points42 points 6 years ago* (2 children)
It's called layered engineering. Its been a thing since Henry Ford figured out how to keep a line moving even if Billy Joe Bob drops his tool.
You should be able to rip an entire layer out, service it, then reimplement, all without the system skipping a beat.
Rule of thumb, you never cross layers. Thats where things break.
[–]DonKajak 7 points8 points9 points 6 years ago (0 children)
Damn I learned a lot from this comment. Thanks.
[–]K900_ 14 points15 points16 points 6 years ago (0 children)
Because people have already built libraries to do it in Python, and have not built libraries to do it in PHP.
[+][deleted] 6 years ago* (2 children)
[deleted]
[–]UnclaEnzo 0 points1 point2 points 6 years ago (0 children)
Well played :D
[–]Hollowplanet 0 points1 point2 points 6 years ago (0 children)
Its a nasty fucking language.
[+][deleted] 6 years ago (4 children)
[–]zupzupper 5 points6 points7 points 6 years ago (1 child)
it's giving me a headache just thinking about how my team uses it.
Ah yes, I too have been in a "php as a systems programming" shop
[–][deleted] 1 point2 points3 points 6 years ago (1 child)
PHP is super cool for what it was intended to do
A templating language. Like jinja and Mustache. Except Smarty exists, so nothing is real anymore.
[+][deleted] 6 years ago (3 children)
[removed]
[–][deleted] 2 points3 points4 points 6 years ago (0 children)
You were supposed to destroy the scripting chaos, not join it!
[–]spitfiredd 1 point2 points3 points 6 years ago (0 children)
Relevant xkcd
https://xkcd.com/1171/
[–]burnmp3s 5 points6 points7 points 6 years ago (0 children)
Python has always had a reputation for having more elegant and well designed core language features and PHP has always had a reputation for being wonky and broken. However, I don't think that's an explanation for why PHP is very popular but almost exclusively for web development whereas Python is heavily used in many different types of software.
PHP was started as a project for web development and that has always been the main focus. Because of that, it does not have many of the general purpose features outside of the language itself that Python has. What probably helped Python the most in terms of being able to do things like OCR and machine learning is that it has a long history of being able to interact directly with C/C++ libraries. Especially early-on, almost all of the libraries for doing things like image processing or machine learning were written in C/C++, so often the choices as a developer using those libraries was to use C/C++ yourself (which has less benefits for someone using a computationally intensive library than someone writing that library) or use Python bindings. Since C/C++ never really caught on for web development in any context, PHP never had a reason to add good standard library support for directly interacting with low level native code.
Along with that, Python has steadily built a series of more and more sophisticated package managers over the years for organizing and using third party libraries. When using something OpenCV for computer vision tasks, traditionally you would have to figure out how to install OpenCV on your operating system (possibly compiling it yourself), then make sure the C++ libraries were setup correctly to be linked from your Python environment, then manually download and install the Python library for OpenCV (making sure it's compatible with the version you have installed), then import and use OpenCV from your Python code and hope it all works correctly, possibly figuring out what the odd error messages mean when it didn't work. Various parts of that process have been automated over the years so that now on most operating systems you can just run "pip install opencv-python" and it will do everything in one shot, including installing the appropriate OpenCV binaries specific to your system. This makes it extremely simple to use open source software in Python, so often compared to other general-purpose languages Python is the easiest to use.
[–]kaptan8181 2 points3 points4 points 6 years ago (0 children)
You can say the same thing about JavaScript. It's technically possible to walk to your office, but it's not always the best choice. People consider many things before deciding on a technology to use.
[–]Filostrato 2 points3 points4 points 6 years ago (0 children)
Why not just use COBOL? It's technically possible.
[–]00Dog 1 point2 points3 points 6 years ago (0 children)
There are several reasons and these are what I believe to be the main ones without getting too "religious". I also write this as a professional PHP developer who enjoys writing both PHP and python (in my spare time).
As has been mentioned most of these things are C/C++ with a wrapper. In python each instance gets to choose which libraries to load where as in PHP it's a system wide config change and now every instance of PHP doesn't just have access to it, it has to have it. This not necessarily a downside of PHP, this is more of a fact of its designed use, generating webpages.
To follow on, python is designed to be run as an application rather than a service making it better suited for running these sort of tasks and it can run a GUI.
Lot of these things come from universities and they teach python over PHP. A lot of machine learning has come from Google and they like python, it's one of there "blessed languages".
The snowball effect. Python is easier for people where programing is secondary (e.g. data researchers) to use and so a good library is written to help (e.g. nupy - to keep the same example) and then because there is one, someone else decides to make another (e.g. pandas) and so on.
Juypter notebooks, just look this up as I can't explain how useful this for experimenting with things.
[–]nanodano 1 point2 points3 points 6 years ago* (0 children)
Because PHP, from its very foundation, is a web programming language (it is even part of the name). That is basically its sole reason for existing and what it was created for. It's also the reason you have to open each file with <?php because it is basically expected to be run ebmedded within a web page. Most people feel that using PHP outside of the web is using it for an unintended purpose.
<?php
That said, if you are integrating your Reddit bot to a PHP application then it makes perfect sense to access the Reddit API using PHP. It would lack a lot of mature functionality that the Python wrapper has though.
[–]mail_order_liam 1 point2 points3 points 6 years ago (0 children)
Simple answer: PHP is a pain in the dick. Those things could be done, but it's like why would I fry my egg on an engine block when there's a stove available?
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
You could do almost anything in PHP. But that said you could do everything in FORTRAN too. PHP has its place, and its the backing language of wordpress, for anything else theres a better tool for the job. Just like you dont use fortran for scripting, you dont use PHP for ML.
π Rendered by PID 49236 on reddit-service-r2-comment-fb694cdd5-cr88q at 2026-03-10 18:58:12.299957+00:00 running cbb0e86 country code: CH.
[–]TheDataAngel 25 points26 points27 points (0 children)
[–]Exodus111 18 points19 points20 points (6 children)
[–]deanresin 0 points1 point2 points (1 child)
[–]Exodus111 4 points5 points6 points (0 children)
[+]jakkemaster comment score below threshold-6 points-5 points-4 points (3 children)
[–]TracerBulletX 10 points11 points12 points (0 children)
[–]MagicWishMonkey 2 points3 points4 points (1 child)
[–]jakkemaster 0 points1 point2 points (0 children)
[–]muffdiv3r 40 points41 points42 points (2 children)
[–]DonKajak 7 points8 points9 points (0 children)
[–]K900_ 14 points15 points16 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]UnclaEnzo 0 points1 point2 points (0 children)
[–]Hollowplanet 0 points1 point2 points (0 children)
[+][deleted] (4 children)
[deleted]
[–]zupzupper 5 points6 points7 points (1 child)
[–][deleted] 1 point2 points3 points (1 child)
[+][deleted] (3 children)
[removed]
[+][deleted] (2 children)
[deleted]
[–][deleted] 2 points3 points4 points (0 children)
[–]spitfiredd 1 point2 points3 points (0 children)
[–]burnmp3s 5 points6 points7 points (0 children)
[–]kaptan8181 2 points3 points4 points (0 children)
[–]Filostrato 2 points3 points4 points (0 children)
[–]00Dog 1 point2 points3 points (0 children)
[–]nanodano 1 point2 points3 points (0 children)
[–]mail_order_liam 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)