

10yr+ PHP Dev Wondering: Python vs. PHP for Web Applications? - dirtflinger

10yr+ PHP Dev wondering: Python vs PHP for Web Applications?  Please don&#x27;t let this drag onto a bitter fanboy debate about which programming language syntax is better...I just want to hear your story if you have used both PHP and Python in your web development years.
======
gedrap
I was a PHP dev for ~6 years, switched to Python about a year ago.

* Once you know PHP, it's really fast to get shit done. Can't deny that.

* After staying with one language for so many years, it's crucial to try something new. You might not like it, but there might be some parts that could inspire you. It's really toxic to be stuck in one mindset for a very long time.

* Anecdotal, but I found an average Python dev to be better than average PHP dev (oh god, all those custom PHP frameworks I had to maintain and rescue projects from death).

* Python has great libraries for statistics, machine learning, image processing, etc - it's very universal.

* There is loads of great info about Python on the Internet and transition should be smooth once you get used to not putting semicolon ;)

* I found that there are more better paying jobs in Python.

All in all, why not to try?

------
jamestnz
I've developed for the web (ranging from small one-script hacks, up to large
commercial applications) for about 15 years. Much of this work has been in
PHP, often using the CodeIgniter framework [1]. As far as PHP goes, I do like
CI; it provides some semblance of an MVC environment, a predictable
URL/parameter routing scheme, view templates, and so on. I have a CI custom
controller I inherit from to publish my REST endpoints. Generally CI projects
will tend toward a somewhat common/predictable structure, enhancing
maintainability and team development.

But over the years I've also inherited some absolutely abhorrent PHP nightmare
projects, whose design/coding decisions truly boggle the imagination. Often
based on no framework at all, and apparently motivated largely by the
developer's desire to use as many PHP and SQL features as possible in the same
project.

Latterly I've been using python for some web projects. I played briefly with
django, but I've found myself settling on Flask [2], a very nice
"microframework" which is super easy to get running with, and which gives a
great balance between power and stay-out-of-my-way-ness. It has a simple URL
routing system based on function decorators and regex, the ability to factor
your apps into reusable components based around your python modules, jinja2
templates, etc. I use sqlalchemy for db access.

Honestly I find it much more of a pleasure to be coding python/flask vs
PHP/codeigniter, but due to team and project constraints it isn't always
possible to go that way.

[1] [https://ellislab.com/codeigniter/](https://ellislab.com/codeigniter/)

[2] [http://flask.pocoo.org/](http://flask.pocoo.org/)

------
candl
I don't use PHP at all, but one thing I envy PHP (and Perl) users is that they
have excellent libraries to interact with SQL databases in the form of PDO
(PHP) and DBI (Perl). There's no direct equivalent of this in Python which is
a shame. The mantra in Python land is to use ORMs which I am not a fan of.

~~~
fragi
Have you checked web2py with its DAL? you can get it also as a standalone
module [https://github.com/web2py/pydal](https://github.com/web2py/pydal) Also
there is db.py from yhat.

~~~
vram22
PyDAL (DAL) seems good on an initial look. I've just started exploring it, but
recently wrote a post about publishing database data to PDF using PyDAL and
xtopdf, my Python PDF creation library, here:

[http://jugad2.blogspot.in/2015/01/publish-databases-to-
pdf-w...](http://jugad2.blogspot.in/2015/01/publish-databases-to-pdf-with-
pydal-and.html)

PyDAL is now a separate project and can be used without web2py.

------
dscrd
PHP seems to fall apart in the seams when trying to reach a higher abstraction
level. For instance, Symfony 2 tries very hard to include modern OO techniques
in there, but the end result is that its performance is incredibly bad. Also,
the OO basis is ripped from Java (which is not a perfect fit in some places,
given that Java is a more static language), which I do not enjoy at all.

Python isn't the fastest dog out there, but doesn't fare so badly with the
abstractions, and its OO style suits a dynamic language better. It doesn't try
to be a Java.

Neither language will give you much protection against programming errors, nor
optimize your code very well like many of the new hip languages (Rust, Go,
Nim) do.

------
devonbleak
For mass hosting of web applications written by untrusted 3rd parties I like
PHP better because I can restrict what they can do via php.ini and there seems
to be better support for static analysis.

That said most of the stuff I write myself lately is in Python.

------
smt88
I've used both, but I can't answer this without knowing what you want to use
it for.

I don't know that I've ever heard anyone say that they prefer PHP over Python,
so I doubt you'll get that response on here.

I'm honestly not a huge fan of either. Are you deciding whether to learn
Python? What you want to use going forward?

Honestly having 10+ years of PHP experience probably makes it a hands-down
winner (for you personally) in terms of productivity. It'd be a while before
you'd see any real productivity gains from Python.

That said, there are maintainability considerations for each language, and
Python wins in some of those categories.

~~~
jack9
> I don't know that I've ever heard anyone say that they prefer PHP over
> Python

I hear it all the time. Primarily by polyglots who are interested in
prototyping things. I use both, I prefer PHP and I'm increasingly aware that
people aren't learning PHP rather than watching it evolve past Python.

------
saluki
Before you decide checkout the Laravel PHP framework.

[http://laravel.com](http://laravel.com)

[http://laracasts.com](http://laracasts.com)

Taylor has done a great job on it.

------
raoul_duke
If you're talking frameworks, I prefer Python. Django is a juggernaut and
getting better and better with each release. PHP frameworks come in all shapes
and sizes, but I haven't found one that feels as comfortable as Django. If
you're taking a generally static site though and need a few bits of dynamism,
I'd stick with PHP as it'll be lighter and get the job done fine.

------
jhildings
The hardest part about Python it's not Python itself but rather the server
environment / deployment things. PHP is just save files and visit apache
server, Python had a much steeper curve to learn all those things around.

And then of course it's the spacing issues which is hard to understand at
first glance

------
0942v8653
I think if your website is mainly just a bunch of templates then PHP's html-
by-default will make things easier. Same for making small changes to a static
site. But if you're doing something any more dynamic than that I'd prefer
Python.

------
robodale
14 year American .NET Web developer here. Your question is invalid.

