TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How will it impact my webapp if it is written in Python instead of PHP.

51 pointsby Chiragalmost 15 years ago
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.<p>PHP and Python<p>* Both have good framework web.py | codeigniter<p>* Both have good helpful community and support<p>* Both large set of plugins<p>How will it impact my webapp if it is written in Python and not PHP

25 comments

srequealmost 15 years ago
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.
Zakalmost 15 years ago
Python will probably be easier to write and almost certainly be easier to maintain.<p>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").<p>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.
评论 #1491087 未加载
评论 #1490399 未加载
评论 #1490213 未加载
notphilatallalmost 15 years ago
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.<p>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.
TheSmokealmost 15 years ago
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.<p>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.<p>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.<p>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.<p>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.<p>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.<p>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.<p>And I'd like to thank justin_vanw for the great sum. :)
评论 #1491404 未加载
评论 #1491363 未加载
评论 #1491336 未加载
评论 #1492790 未加载
评论 #1490898 未加载
GeneralMaximusalmost 15 years ago
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 <i>too much</i> magic -- which can be disconcerting if you like to know exactly what your framework is doing behind the scenes.<p>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 <i>seem</i> 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.<p>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.<p>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.
JustAGeekalmost 15 years ago
It really doesn't matter.<p>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.<p>You can write horrible code with both languages, it might be horrible in a different way but it'd still be horrible. :D<p>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?<p>As it doesn't matter, it would be the sensible decision to pick the language your team would like to code in, imho. :)
randallsquaredalmost 15 years ago
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.<p>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.<p>PHP really is an ugly language, but you eventually get used to it. :(
jessoralmost 15 years ago
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...<p>It's probably more important to just getting something done in the first place. You can probably rewrite when you get some revenue.
bennoalmost 15 years ago
If you have to ask this question, you're out of your technical depth.<p>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.<p>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.<p>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.<p>(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.)<p>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.<p>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.<p>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.<p>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.<p>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.
评论 #1490492 未加载
justin_vanwalmost 15 years ago
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.<p>State of web programming in python:<p>The frameworks:<p>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 <i>easily the worst</i> (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.<p>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.<p>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.<p>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.<p>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).<p>How to deploy:<p>mod_wsgi for Apache is the <i>one true way</i> 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.<p>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.<p>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.<p>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.
评论 #1490622 未加载
评论 #1491040 未加载
评论 #1490540 未加载
评论 #1490584 未加载
评论 #1490989 未加载
评论 #1490879 未加载
评论 #1493651 未加载
评论 #1490463 未加载
评论 #1493719 未加载
beza1e1almost 15 years ago
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.
评论 #1490267 未加载
jebalmost 15 years ago
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.
评论 #1490626 未加载
plinkplonkalmost 15 years ago
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.<p>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.<p>If you are a decent programmer all the above should take you a weekend at most.<p>And then you'll have some first hand experience about difficulty of transition etc.<p>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.
stratosparkalmost 15 years ago
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.<p>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.
评论 #1490307 未加载
评论 #1490368 未加载
BerislavLopacalmost 15 years ago
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.
评论 #1490427 未加载
crististmalmost 15 years ago
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.<p>I'm biased towards Python.
f1gm3ntalmost 15 years ago
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.<p>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.<p>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.<p>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.
bkrauszalmost 15 years ago
From my Quora post on PHP[1]:<p>"PHP is just like every other language: it allows you to write horrible, insecure, stupid code. It also allows you to write clean code."<p>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.<p>[1] - <a href="http://www.quora.com/What-are-PHP-s-main-flaws-(and-good-parts)?__snids__=1360846#answer_55743" rel="nofollow">http://www.quora.com/What-are-PHP-s-main-flaws-(and-good-par...</a>
评论 #1490301 未加载
petervandijckalmost 15 years ago
Repeat after me: it does NOT matter. It does NOT matter. It does NOT matter. Choose the one you are most comfortable with.
评论 #1490906 未加载
jrussbowmanalmost 15 years ago
If you know PHP and CodeIgniter well, and don't know Python very well, then it will take it longer to write in Python.<p>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.<p>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.
karanbhanguialmost 15 years ago
Just use what your team knows better. Period.<p>There are enough implementations of both languages in the real world (YouTube - Python, Yahoo/Facebook - PHP)
gte910halmost 15 years ago
It entirely comes down to who knows it (so when you hire, what type of people you get).<p>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.<p>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.
kashifalmost 15 years ago
Python for more modular code.<p>Python for maintainable code.<p>Python for better libraries.<p>Python for Google App Engine and .NET<p>Python because of a cleaner grammar and better syntax.<p>Python for you.
superdavidalmost 15 years ago
Use what you're good at. If you're good at neither, it's time to find another day job.
ANINDIANalmost 15 years ago
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!
评论 #1490902 未加载