Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: How will it impact my webapp if it is written in Python instead of PHP.
51 points by Chirag on July 6, 2010 | hide | past | web | favorite | 86 comments
Folks, I have seen too many HN posts on the fact that PHP is not a good language to develop a robust web application, despite of the fact few of the biggest web sites are running on PHP. We(my team and me) started debating on the issue of choice of the technology for the next project. I am still in some ways not convinced that python may be a better approach.

PHP and Python

* Both have good framework web.py | codeigniter

* Both have good helpful community and support

* Both large set of plugins

How will it impact my webapp if it is written in Python and not PHP




It will probably negatively impact your project if all of your team know PHP better and are more comfortable with it. Pick whichever language works best for your team. If some of your team love Python and are able to convince the rest of you as to why its better, then go for it. However, a bunch of strangers on HN probably aren't going to offer much of value. If you are really curious, I suggest diving into Python yourself (no play on words intended!) by reading a book on it, writing some code examples, and then maybe a small project of around 500-1000 lines, trying to use the idioms of the language that you are less familiar with. And if you're not curious, more power to you! In the end, it's the product and the team developing it that are most important.


Python will probably be easier to write and almost certainly be easier to maintain.

It's possible to write good code with PHP, but a great deal of the example code you'll find online is not good. On top of that, the language itself tends to encourage bad design (see "broken window theory").

Python has a strong culture of having one obvious and good way to do things. In some situations, that can feel restrictive, but it tends to make dealing with code other people wrote easier.


Python has a strong culture of having one obvious and good way to do things.

This is, I think, where people new to Python stumble up. If they were Dutch, the obvious way would be easier to spot.



How do you relate "broken window theory" with the grammar of PHP?


Broken window theory, as it applies to code essentially says that sloppy code begets sloppy code. PHP itself has sloppy design, such as inconsistent argument order and naming conventions for built-in functions.

Most of the complaints I can think of about PHP that are objectively demonstrable are outdated. The language now has namespaces, closures and the like. Most of the complaints I have left have to do with the feel of the language, and some remaining cultural elements; it feels like a ghetto, even though it seems to have modern infrastructure now.


And thus Zak withstood the zackattack...


Don't forget PHP now has goto!


Python will allow for easier modularity, wheras PHP will make it easier to pollute the global namespace. Likewise, all standard python components are made available in namespaced modules, are consistently named and well documented. You can certainly write PHP without creating a global mess, but novice developers will be tempted to introduce globals and the standard library is in the global namespace, setting a bad example.

Perhaps more importantly, many skilled developers favor Python and will avoid PHP. When you seek to grow your team, you will likely draw from a better talent pool if your application is written in Python.


I'm happy that I'm developing my web apps with Python. I have used almost all Python web frameworks out there. So let me explain my experience.

Django - Until 1.2 Django was a total headache but with 1.2 it really is a great tool to develop web applications. No reason not to use it unless you feel something's missing. Django has an amazing community with very helpful people.

web2py - web2py lets you create apps very fast, it doesn't push you hard and you can build something in a very short time. However when things get complicated, you will want to quit web2py. I don't like its form helpers, I don't like its validation as the validation is unfortunately not per object but the input data and url routing is headache with web2py. Web2py also has a great community. All your questions will be answered in a short time.

turbogears - turbogears is a subset of pylons with sqlalchemy as orm and genshi as templating system. i don't like the @expose decorator. it's just not for me. provides many other tools by the way. TurboGears has a small but helpful community. SourceForge is using TurboGears.

werkzeug - now this is the framework of my choice. the endless freedom. it is only a skeleton which lets you dress your application onto it very easily. you can choose anything as your orm and templating system. provides a strong url routing mechanism. supports sessions, secure cookies and any other thing you may need. however i am not using werkzeug anymore as i don't like the way people act in #pocoo on freenode. this is the only reason i am not using werkzeug. they are ignorant and i don't like it.

Pylons - My favourite Python framework of all times. Flexible as much as it can be. Provides you the freedom you need for anything. I strongly recommend using Pylons. I am currently using Pylons and I'm very happy with it. Pylons is also used at some very popular web sites such as bittorrent.com, reddit.com, etc. It has a helpful community whenever you need.

Frameworks aside, how will using Python will help you? * Very clean and beautiful code. * Easy updating and maintaining the code. * Easiness and laziness. * Great set of libraries. * Python for your mental health.

And I'd like to thank justin_vanw for the great sum. :)


"however i am not using werkzeug anymore as i don't like the way people act in #pocoo on freenode. this is the only reason i am not using werkzeug. they are ignorant and i don't like it."

Would be nice to know if this is a general thing or if we did something in particular wrong. Because if that is what you remember of this channel we should really improve our behaviour then. So it would be nice if you could elaborate on that.


i'm sorry, it's my wrong choice of word. it's not ignorant but smart ass. i don't like that. nobody is pushing anyone for answering questions. if you don't feel like you're doing something you're happy with, then don't do it. i'm also sorry for making a generalization as i know some people on pocoo very helpful and friendly. i remember you, and daslch answering my questions that way.

and let me note that werkzeug is a framework that i'd like to see at the top and people know its value.


I don't know what your experience is with #pocoo, but in general I have found the members courteous and helpful.

If anything you seem a bit ignorant for rejecting a framework you otherwise seem to like because of an IRC channel.

If you are going to call a whole lot of people - some of whom are among the best coders in the Python community -ignorant, I'd suggest coming up with some examples.


I have been following #pocoo for the past several weeks and have found it to be very helpful and informative. I have seen a few terse replies to poorly-asked questions (such as questions asked with no context), but nothing unfriendly or ignorant. I have also seen conversations that started that way become quite productive.

And Werkzeug, I cannot recommend more highly.


The #pocoo irc discussions are logged and available online for all to see. Why don't you say what your nick is and people can look at what happened. The guys who usually hang out on #pocoo certainly aren't ignorant, but then you may have been online when none of the regulars were around and could have been dealing with a casual visitor.


>however i am not using werkzeug anymore as i don't like the way people act in #pocoo on freenode. this is the only reason i am not using werkzeug. they are ignorant and i don't like it.

Care to explain? I dont lurk in #pocoo but I am confused as to why you are putting an entire room on blast.


Some perspective if you're using Python: I've mostly done desktop apps (ObjC + Cocoa and C++ + Qt). Some time ago I decided to learn web programming. I'd been programming Python for quite some time so, unsurprisingly, I started learning Django. I never felt at home with the framework. This might just be me, but Django has too much magic -- which can be disconcerting if you like to know exactly what your framework is doing behind the scenes.

A month ago I started dabbling in Pylons. It's the best framework I've ever used. The Pylons Book is great, if a bit outdated. The official docs are nice (they seem nice to me; I've been burned by Apple's shitty documentation). The entire framework basically consists of glue code to tie together best-of-breed Python libraries: Mako, SQLAlchemy, Beaker, WebOb, PythonPaste, FormEncode, HTMLFill, Routes. Oh, and it's all WSGI. WSGI is the best thing to ever happen to Python web development. You should at least skim the WSGI PEP (PEP 333) if you're serious about Python web development.

Next, I'm planning to check out Werkzeug. It's an even tinier set of libraries that allow you to, in effect, build your own framework. If you're building a simple REST-based service, Werkzeug is what you need.

I also know some people who swear by Web2Py. I haven't tried it myself, but I hear it's great for quick and dirty webapps.


It really doesn't matter.

What matters is having great coders, great ideas for your app and executing them effectively and efficiently which is possible with both PHP and Python.

You can write horrible code with both languages, it might be horrible in a different way but it'd still be horrible. :D

That said, if you're the only one having doubts about Python but the rest of your team wants to write the app in Python and they do have experience working in Python - why don't you trust your team's judgement?

As it doesn't matter, it would be the sensible decision to pick the language your team would like to code in, imho. :)


The two framework examples you give are not at all on the same level. CodeIgniter has a lot of stuff to structure your application, but many experienced PHP developers wouldn't bother with it (and I, personally, don't think it's worth all the extra code you're importing); web.py, on the other hand, merely gets you partway to where PHP starts, with regard to writing your application. If those were your only alternatives, then I'd say you probably want to use web.py, but if using web.py is one of the choices, then you might just as well use PHP without a framework at all, which is one less piece of third-party software to go wrong.

One thing I've really liked about PHP is that (using Apache) if the webserver is up, PHP is up. When I developed most of the applications in Python, it seemed as though I was constantly worrying about the application process failing, even though this happened very rarely.

PHP really is an ugly language, but you eventually get used to it. :(


A friend of mine always says "it just doesn't matter" in his startup, meaning just chose a language instead of constantly debating over which is better, which will scale better, which sounds more awesome...

It's probably more important to just getting something done in the first place. You can probably rewrite when you get some revenue.


If you have to ask this question, you're out of your technical depth.

The best thing you can do is promote the guy who's clamoring the loudest to steer clear of PHP to technical lead, and defer all future technical decisions to him.

The language is just a tool. Consider car racing. If you have a poor driver in the fastest car, it won't make a difference. No matter how fast the car is that he's driving, he's going to lose. And if you have a great driver in a slow car, no matter how good he is, he's going to be limited by the speed of his car.

If you have a poor technical lead, it won't matter what language you choose. You can give him a great language, but he will not understand and take advantage of its best features. If you have a good technical lead, but you choose a bad language, the quality and pace of his development will be forever limited by the language.

(And in the context of a team, the abilities of the team to make good technical decisions are limited by the technical direction your technical lead sets -- which is why you need the most talented guy in the position of technical lead.)

The guy on your team who is the most against using PHP is likely the one who best understands the ways in which PHP will limit your team. You do not have the deep technical understanding to make these judgments, and for that reason (without taking months of hard work to gain such understanding) you should defer to him.

Yes, some of the largest websites are written in PHP. But you do not have the same level of resources to throw at the problem that they have.

You're also starting your development at least 5 years later than any of the largest websites that you refer too. Frameworks/plugins/communities evolve quickly. There were more reasons 5-10 years ago to choose PHP then there are today. Companies that have already written millions of lines of code in PHP will find it very hard to switch to another language -- but you do not have to deal with the weight of such legacy issues.

As a small team, you need to look for every advantage you can get. Choosing a programming language that makes your developers more productive is an important part of that.

If you care about framework, community and plugins, Ruby is also a better language than PHP, and Rails provides these three things in spades. Assuming you don't have a good system administrator on your team, companies like Engine Yard and Heroku provide scalable managed Ruby on Rails hosting -- so you can outsource combating issues like down-time and data loss.


"The guy on your team who is the most against using PHP is likely the one who best understands the ways in which PHP will limit your team. You do not have the deep technical understanding to make these judgments, and for that reason (without taking months of hard work to gain such understanding) you should defer to him."

sorry, what? the guy on his team who is most against using PHP could equally well be an idiot who is simply repeating stuff he has heard on the web by rote, using regurgitated puff to hide his complete lack of understanding of both the issues and the languages themselves.

Your willingness to entirely overlook that possibility and to make the kind of sweeping statements you have made in your post in the absence of any data causes me to doubt that you have the kind of experience and technical expertise that is required to make that kind of statement.


Of course he could be.

I don't envy the position of any non-technical person that has to make key technical decisions on a technical project.

Ultimately it takes a good developer to spot a good developer, so a non-technical person seeking to build a "robust web application" starts at a huge disadvantage.

Without understanding the pros and cons of each language choice, all he can do is gamble on finding a smarter person than himself that he can trust. I'm advocating he choose the anti-PHP guy, slightly tongue-in-cheek, because given the limited amount of information presented, that choice gives him the best odds.

Being in the position of having to make such a bet is less than desirable, but given his lack of technical knowledge, what else would you have him do?


Im not clear what makes you think the OP is a non-technical person? The question he phrased was the exact question that he should have asked, what is unfortunate (but unsurprising, given the complexity of the answer) is that nobody seems to be answering it clearly.

He asked: "How will it impact my webapp if it is written in Python and not PHP"

That is a fantastic question, and it deserves better responses than the 'language x sucks' ones it is mostly getting.

The simple fact that he asked the correct question gives me a great deal of faith that he is in fact technically inclined, technically able and has some development experience. The way in which it was phrased makes me believe that english is not his habitually spoken language.

He clearly does lack experience in using Python, and is (quite reasonably) hesitant about plunging into a different language without attempting to find out more about it.

"I'm advocating he choose the anti-PHP guy, slightly tongue-in-cheek, because given the limited amount of information presented, that choice gives him the best odds."

it really doesn't. some quite ridiculously stupid people are anti-PHP.

Given the information available, I would advocate that he use the language that the majority of people on his team are most familiar with. Nothing like having a team learn an entirely new language and associated design skills to bog down a project.


"gives me a great deal of faith that he is in fact technically inclined, technically able and has some development experience."

I'm sure he has development experience. But too limited an amount.

It is a valid question, but I don't think any response provided here can properly demonstrate to him the value of a language like Python over a language like PHP. No more than someone could teach him to fly a plane in the span of a post like this. It's not a simple subject, by any means.

The best anyone can do is point him to resources that he could study and learn over a period of time -- or advise him to listen to someone talented that he trusts.

I'd be very careful listening to anyone advocating PHP for a project starting from a blank slate. Yes, there are talent developers that prefer PHP. And there are many more poor developers that prefer PHP as is the most popular default choice for those that lack experience, are not comfortable with their own technical judgement, or believe that all languages are more or less equal.

Many on HN would argue that a top-tier developer would not choose PHP, period. But you may not be able to get hold of a top-tier developer -- and in that case a team of solid PHP developers may be the best available choice, if not the best possible choice, particularly if you've worked with them before, and the project is technically simple and limited in scope.


"I don't think any response provided here can properly demonstrate to him the value of a language like Python over a language like PHP. "

Oh, I entirely agree. The practical differences between them in a web application just aren't that important.


I have been writing serious, database backed, large dataset, etc etc web applications using Python for about 4 years. Although it may seem like bragging, I probably know the ins and outs and what-have-yous of the python web programming landscape as well as anyone.

State of web programming in python:

The frameworks:

Django: More powerful? No. Faster, more seductive. In the long run you'll outgrow it, if you are any good. It gets you from zero to twenty five percent almost instantly, then gets in your way. The ORM is a terrible mess. The template language is easily the worst (slowest by 10x, slow enough that common templates take 300ms to render, insanely unusable 500 line tracebacks), of any of the common python templating languages. Once you swap out the ORM and the templates, you suddenly realize what is left is also a piece of crap. Django middleware are horrid. I remember trying to write a database session middleware and an error-reporting middleware in django, only to determine it is literally impossible (there are edge cases where any middleware can be skipped and never see the request). When having to deal with it, I use it's oddball WSGI adapter and park WSGI middleware in front if it. I can not say enough bad things about django, it is rotten through and through compared to the alternatives. The admin interface is neat, but is basically a toy once you run into real complexity or data volume. I might use django if I were making a content based application on contract, since the admin interface would be a huge piece of free functionality, or a very simple web app, like a hotel website or something.

Pylons: WSGI based, thank the lord. This means you can write real, flexible, efficient, predictable middleware. I was a huge Pylons fan from around the beginning of 07 until I discovered Werkzeug near the end of 08. I still lurk in #pylons quite a bit, and it was at my urging that the Banquet library (a common interface to all template systems) was discarded (although it may have been on it's way out anyway). Pylons uses great libraries under the hood (webob, beaker, etc), and I would recommend it without hesitation. The __call__ method of the BaseController class used to be a complete mess, I would guess that it still is. Luckily you only run afoul of it very occasionally. the __before__ and __after__ methods are handy. When I stopped using it they were still recommending AuthKit officially, but the mood of #pylons seemed to be (and I agree) that AuthKit is a horrifying abortion that should never be used. The canonical stack with Pylons is Pylons-SQLAlchemy-Mako. I would swap Mako with Jinja2, although who use Mako tend to be loyal to it, and there aren't too many huge warts (the way it does template inheritance makes my head hurt though). TLDR-Pylons good.

Werkzeug/Flask: My personal favorite. You are building a web application, you should have all the moving parts where you can adjust them as necessary without bolting on bizarre hacks, and Werkzeug lets you do that. It may be a bit of a jump for a beginner. Flask is an attempt to make a 'framework' out of Werkzeug, and it seems to be getting some momentum. If you know what you are doing, I believe Werkzeug is the best thing out there for Python web programming.

Tornado/Twisted: Either is great. Due to the pain of dealing with them (you need special event driven db adapters, etc) I would only use them for long-polling applications or the long polling portions of a general application.

Also rans: Turbogears: crap, web.py: crap. Also also rans: Zope (if you don't know what it is already, you probably don't want it).

How to deploy:

mod_wsgi for Apache is the one true way to deploy python web applications. Anything else (fastcgi, reverse proxy, etc etc) is a hard to maintain, unreliable, mess. I would put mod_wsgi on each webserver, and have a machine running nginx or varnish or pound as a load balancer. Varnish is the best if you want to do sophisticated caching or edge side includes, nginx is easy and fine also. Everybody seems to want to argue for something besides mod_wsgi, since Apache is so unfashionable. Part of me wants to encourage everyone to do so, because it makes it drop dead easy for me to walk in and 'fix' your apps reliability problems in about a half a day, and look like a genius in the process. You can deploy python applications to run multiple threads per instance, but realistically due to technical limitations of the interpreter you don't want to run many threads. I suspect less than 10 is the optimal amount. Luckily you can have mod_wsgi spin up multiple processes as well. I would have it recycle the processes after around every 25000 requests, even if you don't have any memory leaks in your app.

Database: I recommend SQLAlchemy. There isn't really anything else worth mentioning. Even if you hate ORMs (there is a strong argument for and against), the sql expression language SQLAlchemy gives you is basically the most amazing thing there is. It takes quite a bit of time to master. If you use SQLAlchemy, use the defaults for the Session until you understand it, or you will end up spending a lot of time and trouble mucking with it.

Nosql: I don't trust it. I suppose I might be becoming a dinosaur, but I also haven't had a major use case where I really needed it.

Other: These don't really have to do with python specifically, but I'll throw them in at the end here: I recommend Redis over Memcached. I strongly recommend Postgresql over Mysql (unless you don't understand what a join is). If you have lots of images (say over 2000), put them in S3 from day one. Some stopgap solution is more painful to fix later than earlier.


I'd have to disagree with you here. In fact, my experience is almost exactly the opposite.

Django is incredibly easy to get going, and you can rewrite bits of it as you need to. It's reasonably easy to switch out the templating language if you need to, and I haven't had any problems like you describe with the ORM or admin app. For prototyping apps I wouldn't use anything else. I'm currently running with nginx/FastCGI and haven't seen any problems.

Pylons and SQLAlchemy, on the other hand, I found hideous - lots and lots of boilerplate, particularly when setting up models, weird tracebacks that had no relation to the original problem, poorly integrated bits - I basically couldn't populate databases from a unit test, then run a controller, then check the results, since SQLAlchemy would lose the connection after the controller.


> I basically couldn't populate databases from a unit test, then run a controller, then check the results, since SQLAlchemy would lose the connection after the controller.

What you say makes no sense. SQLAlchemy just uses the usual adapter for whatever database you are using. What does "loses the connection" mean to you? SQLAlchemy, by default, uses a pool of connections. I suspect you tried it for an hour and gave up without really understanding what you were doing.


From memory, committing to the database involves both saving and closing the connection. So when you get back to the unit test, there's no database connection.

Maybe there's a way to do it properly within SQLAlchemy, but if so it's completely non-obvious from a few days of searching the web, Pylons documentation, Pylons book, mailing list, etc.. I wasn't trying to do anything fancy, just set up a very basic unit test.

Here's one of my old comments with some more detail: http://news.ycombinator.com/item?id=1176948 "Instance <Foo at 0x103779f90> is not bound to a Session" was the error that I was getting.


http://www.sqlalchemy.org/docs/session.html?highlight=expung...

The following is more of a screed than a personal response to your post, so please don't take it personally.

This is something I run into quite a bit more than you might expect. Partly it is because I used to spend a lot of time in #sqlalchemy, #pylons, #pocoo, #python, and #postgresql on freenode (I'm 'ltbarcly' on freenode, feel free to msg me HNers!). For some reason it is common to believe that you can sit down and write applications that use an ORM and relational database without knowing both the ORM and relational databases.

If you are going to use relational databases, you should be prepared to become an expert in SQL, Database drivers, unicode (and why utf-8 or any other encoding isn't the same as unicode, in the same way that jpg or gif isn't the same as image data), indexing, data types, normalization tradeoffs, transaction isolation levels, locking semantics, ACID tradeoffs, how to read and understand query planner output, and much more. This is a lot to know, but if it were a college class it would be less than a semester long.

If you are going to use an ORM you have to know everything you would need when you use a relational database, and in addition how and when the ORM performs queries, how it maps to the database, what queries it will produce and when for any given action or attribute access, how db transactions map into the orm operations, how to perform common SQL operations via the orm (rather than loading more data than you need and filtering or joining via the application).


I think what he might be referring to is when you run an in-memory SQLite database in your unit tests (which is common practice, for speed and convenience). If the test server runs in a separate thread to the unit test, then they use two separate in-memory databases and you cannot populate the server database from your unit test setUp.

This however does work in Django - presumably by somehow passing the same DB connection to the test server.


Apparently, you like to write your own low-level stuff, and that's okay. But in my experience in Django there is very rarely any need for that.


I think for a web framework to be successful (all other things, like features, being equal) it needs a few essential ingredients:

- plugin ecosystem. Not necessarily at the beginning, but tha architecture should make it easy enough to add plugins (or apps, or extensions or whatever they are called by the framework) that developers feel encouraged to do so.

- high profile sites or projects, or at least a high volume of sites, so developers can answer manager's question, "Well, who uses it ?". Again, no framework will have this at the beginning but it will need this to get big (bit of a chicken and egg situation).

- good documentation, preferably but not exclusively online. Good == well written, up to date, well organized and consistent.

- good marketing: maintainers who can blow their own trumpet in the blogosphere, conferences, books, Twitter etc etc.

Now the code may be crap, and it may not have this feature or that feature, or it may or may not be easy to extend or customize. But the above points are required if it is to stand a chance.

Django, despite the flaws you mention (and I agree with some of them, and could add a few of my own) meets these criteria. It has the sites, the documentation, a healthy ecosystem of apps (though of varying quality), and is marketed by people who work, or used to work, in the newspaper business.

Flask, as an up-and-coming framework, is just a couple months old, so obviously doesn't have the ecosystem or the high profile/high volume yet. But it is well-positioned to take off : the documentation is excellent, and it has a good plugin architecture, with about a dozen or so "official" extensions already. Whether or not it does take off depends on many other factors, but I'd say it's future looks quite promising. It may need some aggressive marketing, or at least one or two high profile sites.

Pylons, OTOH, doesn't look so healthy. Documentation, last I looked, was out of date, poorly organized, and contradictory (AuthKit is recommended in the docs, newbies use AuthKit, get confused by its crapiness, go on IRC, and get told "don't use Authkit" - why is it still in the docs at all ?).

It's not so easy to add plugins, except at the WSGI level, which is often the wrong level of abstraction, plus there is the confusion of "entry points" and how to make it all work with Paster. As a result (and also because of the pisspoor docs) despite being around almost as long as Django, Pylons doesn't have a good plugin ecosystem. It has one high profile site - Reddit - but otherwise for the time it's been around I can't think of many others.


You don't need special db adapters for Tornado. Idiomatic Tornado apps only use async when blocking on an external event (fetching a page from other site, waiting for another user to do something). Db and file system blocking is handled by running more instances of the Tornado application.


> and it was at my urging that the Banquet library (a common interface to all template systems) was discarded

Buffet.


Oh yea. It sucked.


You do not need special db adapters for tornado/twisted. The one that comes out of the box for tornado is a thin wrapper over the mysqldb library, and I've seen mysqldb used in twisted applications.


I'm surprised how much I agree. Werkzeug, Jinja2, and SQLAlchemy are fantastic pieces of software and a great foundation for any web app.


I'm looking into Tornado + MongoDB for a REST API. Many reads, some writes, eventual consistency is fine. Anyone got first-hand experience with that?


Could not agree more.

My default stack is Werkzeug+SQLAlchemy+Jinja2. Deployed on Apache/mod_wsgi. If a customer wants Windows/IIS, I deploy using isapi-wsgi.


I do not know what you mean by a "robust" web application, but in my experience Python libraries (for example feedparser) are of higher all-around quality. Less pitfalls, means fewer bugs and faster development.


What I mean by 'robust' is scalable and usable.


And what do you mean by scalable and usable? :) Scalable in what sense? Usable by who?


With PHP it will be much much easier to outsource parts of your project compared to python. There are more PHP developers and they are much cheaper.


The downside of that is that it's much harder to find good PHP developers. There are an awful lot of awful developers who use PHP; less so with Python and other 'niche' languages.


The only way to get useful answers (vs just answers) to these questions is to get a feel for web-app development with Python yourself.

Work through a Python tutorial (I suggest "Dive Into Python") first and then set up Django and work through the Django tutorial. Build a small app of your own with Django.

If you are a decent programmer all the above should take you a weekend at most.

And then you'll have some first hand experience about difficulty of transition etc.

Fwiw, I prefer Django to PHP. But then I am biased so use appropriate amounts of salt. I'd kill myself if I had to work for very long in PHP.


If you want a more "guided" approach to Python webdev, try looking into Django. There's a large community that has built up around it contributing tons of plugins.

I say this as someone who is working on a Pylons site. You can do anything with Pylons that is possible with Python, you just have to figure it out yourself or twist someone else's library to make it work. Sometimes you don't need that much freedom and the guided approach will do 90% of what you need. Do a bit of research and see which approach best suits your needs.


I'd also recommend a look at Flask: http://flask.pocoo.org/. It's quite new but more polished and easier to learn than Pylons, and comes with excellent documentation and handy extensions.

As you say, however, Django is a good place to start for a beginner - it has a larger community and ecosystem of apps for doing just about anything web-related (although the apps are of variable quality). It's also quite mature (5 years now) and has more job opportunities.


contributing tons of plugins.

applications, not plugins


How about choosing one that your team knows better? Your startup's app is not a good place to learn new technology, as proven by Reddit and Twitter, among others.


Yea, Reddit and Twitter are great examples of places that failed because they were afraid to learn new technology? Wait. That failed because they tried to learn and implement things in unfamiliar technologies? Oh, wait, what?


No, they tried to build the app with a technology they wanted to learn {Reddit : Lisp, Twitter: Rails} and then had to rewrite it (mostly) from scratch when that didn't work out {Reddit: Python, Twitter: Scala}.

Neither failed, because they were smart enough to know when to ditch. God knows how many startups failed because they didn't know that.


For Twitter, Rails was the technology they knew. They decided it wasn't the right tool for their needs. Scala is the tech they learned (and continue to learn) on the job. They even have a group blog detailing this process (http://gracelessfailures.com).


Maybe debating about it is not the right approach. If you have experience in PHP and you can afford some (inherent) delays in the next project you should try Python and see for yourself. You will be hit by reality faster and better than any debating would. Then you'll have an educated opinion for the next (second) project.

I'm biased towards Python.


I've been creating sites for a number of years now and have used php since the days of putting perl scripts in your cgi-bin. I'm just now starting to learn python. Here's mho.

If you use php, check out symfony. Codeignighter is crap once you get to know you way around symfony. Php is something I feel comfortable using and know my way around. I use it for all my web sites.

The reason I am learning python is to use the app engine. It looks like a cleaner language then php and seems to be slightly more powerful.

I think it would come down to 1) does your developer know php, python, or both? Let him develop in whatever language they choose. 2) where are you gonna do with it? I think there's a time and place to use php and to use python.


From my Quora post on PHP[1]:

"PHP is just like every other language: it allows you to write horrible, insecure, stupid code. It also allows you to write clean code."

Really, the language doesn't matter. Find people who write good code and give them the tools and atmosphere to do so, and your code will be good. Both are mature languages with plenty of time put into plugins, security, and documentation. Both can obviously scale well, and both have the same set of capabilities barring some specific edge cases.

[1] - http://www.quora.com/What-are-PHP-s-main-flaws-(and-good-par...


Really, the language doesn't matter.

I disagree.

Python, by design, makes it hard to write bad code. PHP, by design, encourages bad code.


but a good developer can write good, clean code in either one.

Every language/IDE combination encourages a 'default' coding approach, I agree that the PHP 'default' coding approach tends to be to create a hopeless muddle of assorted, random crap. OTOH, which would you rather have...a coder who is currently being 'forced' to write marginally better code in Python than he would in PHP because of the language constructs, or a coder who understands good code design and knows how to apply it?

A good coder will be a good coder in any language, the fact that a crappy coder can be made to look marginally better if they are forced to use Python just doesn't feel like much of a win to me.


BS. Can PHP do this? http://www.joelonsoftware.com/items/2006/08/01.html

(In fact the latest version of PHP (5.3) can, but for years PHP has been lacking this, so the point stands.)

No amount of "good code design" can work around core features that are missing from a language.

The argument that all languages are more or less equal is as nonsensical as saying all cars are more or less equal, or all guns are more or less equal -- it ignores the tremendous advantage that using good tools can provide.


"Can PHP do this?"

well, as you've pointed out yourself, yes it can.

"for years PHP has been lacking this, so the point stands."

Im sorry? I must be missing the point. How does the presence (or absence) of a particular language feature prove or disprove the point that bkrausz made originally?

"..<snip>...it ignores the tremendous advantage that using good tools can provide."

not really. well, kind of.

so the thing is that if I take the things that (in my experience) work to make a project successful, and I squash them all up into a big ball, and then I take that ball and I split it up into two heaps....one heap consisting of the things that the developers brought to the project and one heap consisting of things that the language brought to the project...and I look closely at the relative sizes of those two heaps....then almost always the heap of things that the developers brings is a lot larger; so much larger in fact that in general the effect of the programming language can be ignored.

That is a pretty general statement, and there are clear cases where it is simply not true, but in general it is true, and I would particularly claim that in the case of a web application and choosing between PHP or Python, it absolutely is true. In the hands of good developers either will solve the problem well, both will provide a good, readable and maintainable code base. In the hands of an idiot, neither will be any good.


"Im sorry? I must be missing the point. How does the presence (or absence) of a particular language feature prove or disprove the point that bkrausz made originally?"

Yes, you are missing the point. I refer to closures, the feature at the core of functional programming, not just any "particular language feature". Functional programming is an extremely powerful tool to wield, and has been absent from PHP since its inception until very recently.

A great developer with a functional programming tool in hand is able to well outperform a great developer who must work around its absence.

Here's a paper that surfaced to the front page of HN recently on the importance of functional programming: http://news.ycombinator.com/item?id=1482797.

This is just one example, but a very potent one, of why language selection matters.


yeah, closures are good.

we really do appear to be having two different discussions, Im neither claiming that PHP is 'better' than Python nor am I arguing against functional programming.

I am simply arguing that the most important thing in a project is the quality of the developers, not the language they chose; and that given a good developer and a choice between PHP and Python I would almost certainly find the relative language features so entirely unimportant that I would choose the language based on stupid things like what language the existing codebase is in, what language the developer preferred and had most experience in and how recently I had been frustrated by the languages in question.

OTOH, I am always willing to debate the relative importance of language features, so by all means lets go there.....

Closures in particular are a very powerful tool in async/multi-threaded environments, but in the stateless/sync environment of a web application environment, they collapse down to syntactical sugar, and solve nothing that cannot be solved in other ways.

The software industry has, by and large, been working around the absence of closures for years....I certainly wont argue that it is better because of it, but to claim that PHP has been seriously crippled by the absence of closures over the years is to entirely overlook and understate the multitude of other problems its users have had to overcome.


"I am simply arguing that the most important thing in a project is the quality of the developers, not the language they chose"

I agree with the first part, but I think the language choice is integral to just how good those good developers can be.

I don't believe for a minute that a great developer can develop in PHP without being seriously crippled by it.

Functional programming has a tremendous amount of value outside of async/multi-threaded environments that cannot simply be replaced by other means. There are real limits to the amount of modularity one can achieve without functional programming, and modularity is key to great programming. I'd point you again to this paper: http://news.ycombinator.com/item?id=1482797

The state and history of the software industry at large only demonstrates that the majority of software developers in key technical positions within the industry are and have been less than great.

But if your argument is that PHP is "good enough" given a bunch of average developers... well then, yes, probably. Certainly plenty of good software has been written in PHP. I'd just argue that with the right developers it's far less than optimal, and that the choice of language could easily be the difference between the success and failure of a complex project.


"Functional programming has a tremendous amount of value outside of async/multi-threaded environments that cannot simply be replaced by other means."

Functional programming, or closures? I said: "Closures in particular are a very powerful tool in async/multi-threaded environments, but in the stateless/sync environment of a web application environment, they collapse down to syntactical sugar, and solve nothing that cannot be solved in other ways."

I made absolutely no statement regarding functional programming in general, and the label 'functional programming' applies to a much broader set of topics than just closures, so I am entirely at a loss as to why you think it makes sense to 'rebut' my statement about closures with something about functional programming?

"There are real limits to the amount of modularity one can achieve without functional programming, and modularity is key to great programming."

I entirely agree, modularity is good.

"The state and history of the software industry at large only demonstrates that the majority of software developers in key technical positions within the industry are and have been less than great."

indeed.

"But if your argument is that PHP is "good enough" given a bunch of average developers..."

LOL.

It really wasn't.

Im glad you like functional languages and closures, you really should check out Scheme - its even MORE functional than Python.


> Closures in particular are a very powerful tool in async/multi-threaded environments, but in the stateless/sync environment of a web application environment, they collapse down to syntactical sugar, and solve nothing that cannot be solved in other ways.

Every feature in every language is syntactic sugar for ASM instructions and solves nothing that cannot be solved with raw machine code. It's precisely the expressiveness of the higher-level features that gives them their power.


"Closures in particular are a very powerful tool in async/multi-threaded environments, but in the stateless/sync environment of a web application environment, they collapse down to syntactical sugar, and solve nothing that cannot be solved in other ways."

Closures allow for abstractions that are impossible to achieve without them. Yes, you can always get the same functionality, but you will be forced to deal with a weaker abstraction.

PHP has closures however.


> (In fact the latest version of PHP (5.3) can, but for years PHP has been lacking this, so the point stands.)

Actually, it's been able to do that for a LONG time. Pretty sure (99.9% sure here) you could do that in PHP 4, and probably in PHP 3 as well (but really, it's been so long, forgive me for not remembering). Different syntax, of course, but yeah, you could do that.

PHP 5.3 essentially just made it more explicit.

Edit: When I say different syntax, I mean slightly different syntax, obvious, because it's Python being reference. The end result, however, is the same.

And, if I may be so bold, the PHP way prior to PHP 5.3 (though still supported), encouraged a cleaner implementation then the 'Cook' example demonstrated in the link above.


Well, I guess I'm asking for trouble arguing against a language I have no development experience in.

A quick Google search shows that PHP 5.2 and earlier seem to support something like the anonymous functions required in the example I linked to above -- via the create_function method. But using it in practice appears to be full of ifs, buts and complexities: http://nz.php.net/manual/en/function.create-function.php#706...

But maybe one could get it work if used with care.

If I were ever chained to a desk and forced to work with a PHP framework like Drupal that does not yet support v5.3, I'd look in to this.

Otherwise I'd choose a language that cares more for concepts like readable code and deep modularity.


Actually, older versions of PHP could do that, too, as long as you pass the function names as strings. $functionName() works fine in PHP < 5.3, though I'm not sure when it was introduced.


Thank you! For some reason I always take flak for this position, great to know I'm not the only one who feels this way.


a coder who is currently being 'forced' to write marginally better code in Python than he would in PHP because of the language constructs, or a coder who understands good code design and knows how to apply it?

That's an esoteric question.

A good coder wouldn't choose PHP in first place, unless there are pressing reasons (i.e. a legacy code-base).

Consequently you can speed up your hiring process simply by weeding out candidates who propose to use PHP.


LOL

'No true scotsman...'

FWIW my hiring process rarely includes a request that candidates propose the language that they will perform their work in.

(oh, and its not an esoteric question. It is a deeply practical one. I desperately want to hire good, pragmatic coders, not people who are only capable of writing good code if they are in an environment that makes it easy)


Well, you probably want your coders to create and maintain an environment that makes it easy to write good code in. PHP has no place in such an environment.

Moreover it's highly unlikely that a good coder would apply for a PHP job in first place.


> Well, you probably want your coders to create and maintain an environment that makes it easy to write good code in. PHP has no place in such an environment.

I agree with the second part, but I think the first part is wrong.

I think he wants coders to create and maintain software that the company will use on a daily basis, in which case, PHP is perfect for that.


heh. especially if you and I decide to define "good coder" as "someone who wouldn't apply for a PHP job in the first place"

that would make it IMPOSSIBLE. muah ha ha.


Agreed. Even if these two pieces of code might accomplish the same thing, at least the Python version doesn't make me want to stab myself in face whenever I write it:

Invoking an object callback in PHP:

    call_user_func_array(array($object,'method_name'),array($arg1,$arg2,$arg3)); 
Invoking an object callback in Python:

    object.method_name(arg1,arg2,arg3)

    (Python's *args and **kwargs are especially useful in these types of situations.)
Although PHP is slowly adding useful modern language features (lambdas, closures), some of the syntax really is terrible. I honestly can't imagine anyone preferring the former to the latter, at least in this example.


Repeat after me: it does NOT matter. It does NOT matter. It does NOT matter. Choose the one you are most comfortable with.


it does NOT matter. It does NOT matter. It does NOT matter.


If you know PHP and CodeIgniter well, and don't know Python very well, then it will take it longer to write in Python.

If you move to something like Tornado (python), Twisted (python) or node.js (javascript) then you might be able to get more performance out of your app, but really only if think moving to that level of complexity is necessary for you app.

In general, it's best to go with what you know. Yahoo! uses a lot of PHP as does Facebook. Since you mentioned CodeIgniter specifically, you're already well down the path of using a framework that allows you to write modular and reusable code with PHP.


Just use what your team knows better. Period.

There are enough implementations of both languages in the real world (YouTube - Python, Yahoo/Facebook - PHP)


It entirely comes down to who knows it (so when you hire, what type of people you get).

PHP has a lower skilled mean programmer who does it. This is not necessarily a bad thing if cheaper programmer is better than better programmer for your company.

PHP is easier to get going, python has more compelling libraries once you do. Python libraries are often better maintained than their PHP brethren, and the debugging stack for python is much more compelling.


Python for more modular code.

Python for maintainable code.

Python for better libraries.

Python for Google App Engine and .NET

Python because of a cleaner grammar and better syntax.

Python for you.


Use what you're good at. If you're good at neither, it's time to find another day job.


Use Python + Django hosted on Google App engine It will remove all your worries of paying any thing unless you get million hits per month!


I concur. Also you will be disciplined into writing scalable code and will not have to deal with operating system issues, setting up servers, configuring db's etc., so you can focus on programming.

(If you want an invite to Fosdev for trying out GAE quickly, let me know.)




Applications are open for YC Summer 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: