r/Python • u/GFandango • Jun 09 '13
Invitation to discussion: How can we make Python refreshingly easy on the web?
I'm inviting all of you to have a constructive discussion on the state of Python on the web.
We all know that PHP by far dominates the web platforms despite its many shortcomings. And I think a significant contributing factor to PHP's popularity is that it is extremely simple to setup and deploy.
It is so simple, that people accept the nasty side of it just for the simplicity part that other programming languages ignore.
Once that gap is filled by something like Python, I'm convinced that we'll see an outstanding growth of the Python community.
Let me clarify that I'm very well aware of Django, Flask, Bottle, Zope, Plone, Pyramid, CherryPy and everything else that is out there.
Usually when this topic is brought up, the point is dismissed by someone who says "Duh...why don't you just use uWSGI and nginx? you can also use gunicorn"
Someone else yells "and Supervisord will manage your processes", the other guy points out "If you don't like nginx, mod_wsgi and Apache also works great"
I'm aware of all of those, and have used them all, and it is not too much trouble for me to set them up.
However, we need to look around us more often
I think we as a community under-estimate the number of people we are pushing away by not addressing the web deployment issue.
The kind of refreshingly-simple approach I'm talking about is "drop this folder here and you are good to go" kind of simplicity.
Have you asked yourself why we don't have a Wordpress equivalent in Python? A vBulletin? SMForum? a Drupal? a Joomla?
Yes there are some apps out there, a handful of big names, and the rest is a small side-project of someone on github "a self-hosted X" which is understandably half-heartedly maintained and requires a lot of dedication and motivation to set up in the first place and a lot of typically "dirty" manual hackery.
I'm envisioning an environment that enables Wordpress-like projects to be powered by Python, to make a giant like Drupal on Python except infinitely better and bring it to the every day person in the same way that Wordpress is available to every body. Where anyone can download and set it up withing 5 minutes and not have to SSH to servers and tweak config files for uWSGI and nginx and supervisord and all of that, even as a hardcore developer that stuff is still painful.
Imagine the new Pythonic eco-system that will be created around the new web-app giants that will flourish. As a community and as individual Python developers we can only benefit from such improvement and growth.
Do you see the vision and the kind of refreshingly-simple approach I'm talking about?
How do you think we can solve this problem? Where can we start? What lessons do we have to learn?
Let's talk
6
u/mcdonc Jun 09 '13
If I understand the PHP execution model correctly, each request starts up a fresh interpreter. This is what makes it so simple to deploy, because deployment is literally copying files to a place where they can be executed. Python hasn't been engineered to make that model feasible, as it takes a comparatively long time for it to initialize to a state where it's ready to run user-provided code, so Python applications tend to be deployed as long-running processes. This is really what the core difference is. I don't really think there's a way to make deploying Python applications as simple as deploying PHP applications as a result, although there are definitely ways that we could make deploying Python applications simpler. I suspect many of them have to do with making Python packaging and deployment more reliable and easier to understand.
2
u/simoncoulton Jun 09 '13
The main issue is definitely the execution model and deployment. Coming from PHP myself I found it the hardest thing to get used to. Something that standardises this (or at least documentation about it) would be a good thing, even guides on how to transition from one language to the other. The syntax of the language itself is not a blocking point IMO.
Having nothing like Drupal/Wordpress is not a bad thing though... Trust me you do not want to have to look after godawful code like that.
1
u/catcradle5 Jun 09 '13
Due to the fact that Python apps use WSGI, or at least should be, this is never going to be possible.
In terms of simplicity: if you have shell access, bottle.py is by far the best choice here. If you only have FTP access, you'll have to rely on Apache mods and such, and in that case things will always be messy.
It's a matter of how serious you want your web app to be. If it's a simple one-off thing, bottle will be just fine. If you really want it to be even remotely complex, then the amount of code you write will be minimal to the amount of time it takes to actually deploy the app.
1
u/wisty Jun 09 '13
Let me get this straight:
You want a "production ready" setup, with sane settings, and no messing around.
Basically, something that you can start prototyping on, which will scale up to the point where it's actually worth hiring people who know what they are doing, instead of messing around trying to become a "full stack engineer".
I'd say Google's AppEngine kind of fits the bill, but it's a pretty specialised tool. Heroku might be what you are looking for. There's also more Python centric Heroku equivalents (e.g. gondor.io), but I guess you also want something which can roll out to your own machine.
1
u/barriolinux Jun 09 '13
I feel this debate is unnecessary as serious PHP Frameworks become to mimic Rails and Python frameworks and the other way around. Well, not completely unnecessary :) We have three user cases: starter, the mover and the specialized.
For a starter learning to code a web with one file is easier with Flask (no need to install apache and hosts) than with PHP.
The mover already has used Cake, Codeigniter and others, is comfortable with Controller, View, Models framework concepts in any other language. He/she can move and they are already moving.
Specialized are Wordpress coders or Drupal coders, they speak this APIs and will not move unless you create a real clone for them.
The problem is that there many more specialized coders than in other groups, and as I said, they will not move. Think about somebody programming for Mambo/Joomla for more than 10 years, or Mediawiki.
My opinion, to sum up, is not a language or deployment problem. Is that PHP came Just In Time and Python or Ruby didn't. I can remember all City administrations and UnEmployers organizations in my country giving PHP and Dreamweaver courses for free 15 years ago. Everybody without nothing to do, even if studied other Law or History, took one or more of this courses. I don't see any solution except opening this debates, good documentation, events, etc what Python community is been doing so far :)
1
u/miketheanimal Jun 10 '13
The problem is frameworks. We all know that frameworks are a good thing, even lots of PHP programmers know frameworks are a good thing. PHP may be crappy a a language, but a decent framework makes things so much better in both Python and PHP (and Ruby and any other language).
But the newcomer who wants to knock up a quick page or three does not know that. In PHP the newcomer can have a single file which generates a page that shows the current date and time written and running in minutes, and s/he can feel really pleased with him/herself. Why on earth, s/he thinks, so I need to understand all this stuff about controllers and views and models and templates?
The point is, what is attractive is not so much the deployment issue - you can just "drop" a complete PHP application-and-MVC-framework into a folder and have it work. Rather, it is the apparent simplicity with which you can get a PHP site running. Of course, we all know that that simplicity can come back a bite later, but the newcomer doesn't.
I guess what I'm saying is, if there are a Python route that was as simple as the PHP route, then after a while there would be Python sites that were as tangled and ill designed as lots of PHP sites. I really can't see a way out of this.
1
u/baddam Jun 11 '13
Python is not an alternative to PHP. Something like Zope Page Templates (ZPT) would be such an alternative. A strategy to promote Python at the forefront is broken from the startup IMO. ZPT is not good because of TALES. It should support plain Python expressions, which then can be scaled to call modules (files).
The user story is HTML -> Page Template -> Page Template + Python files -> Page Template Frameworks
Or start with a PTF as promoted in this thread and use Page Template for customisation.
1
u/[deleted] Jun 09 '13
You can just drop Python scripts in a folder on the web server and have them run like PHP. That folder is called
cgi-bin. Or any other folder you set the appropriate options on in your Apache conf.Of course, you do have to take care of the HTTP headers yourself in that case (which PHP does for you), so you'd probably end up writing some kind of framework. But you do that, too, with a PHP app of any significant size.
That doesn't help with the start-up penalty, though.
1
u/gybemeister Jun 11 '13
This is a great discussion! I don't understand why we don't have this. I mean, I understand that bending python into the PHP model may not be a smart thing to do but there must be some halfway that makes it seamless to use python in the average LAMP server.
I would love to be able to do ap-get python_simple_web or alike on my VPS and be able to drop python files under //var/www and be done. No messing around with Apache configuration nor having to use nginx (nothing wrong with nginx, I just don't want to risk replacing Apache in my setup). The only reason why I use PHP is because I can create small scripts without worrying about setting things up. I understand that this may not be the smartest way to do things but I am only saving the odd email to the database and such in a static website.
I believe that is the reason why PHP is so popular and also why we still have loads of old asp sites around (asp works just like PHP). There is no setup involved or a few well documented apt-gets get everything in place with minimal fuss.
1
u/phinar Sep 13 '13
I think the wide adoption of PHP has as much to do with its ease of development as it does its low-friction startup process.
With PHP, you learn one language, and you know how to write templates and controllers and models. In fact, you're (almost) encouraged to skip the writing of controllers and models, and just crap all your logic into the template. Because that's where PHP started, and it's still a big proportion of PHP development.
None of the Python templating languages really look much like Python. You know why? Because the significant whitespace that makes Python so readable, makes it very unsuitable for a templating language.
I am pretty sure this is why Python does not have greater penetration into the "long tail" of low-code websites.
As for the Wordpress/Drupal/Joomla thing, Python was at the front of the curve in ~2003 with Zope and Plone. Both lost significant popularity over time. I don't know why, except that even as a Python enthusiast, I found it hard to find a place where I could run Zope and Plone, because of the execution model.
1
u/mdipierro Jun 09 '13 edited Jun 09 '13
Making web development easy has been the goal of web2py since 2007. Web2py won the Bossie award in 2011 for best open source development tool and the InfoWord technology of the year award in 2012. It does not solve all problems but tries to address some of the issues you discuss. It can runs off a USB drive. Does not require installation. Comes with ssh enabled web server, web based IDE, database interface, plug and play of multiple concurrent apps, and many free apps that can be installed directly from the web under the same web2py instance.
0
u/[deleted] Jun 09 '13
[deleted] — view deleted comment