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: Bet the farm. Python or PHP?

24 pointsby t0pjalmost 17 years ago
1. Extensive support of libraries and frameworks. 2. Excellent community. 3. Rapidly develop and deploy. 4. Capable of scaling quite well.<p>Python and PHP score well on all four of these points.<p>I am about to embark on building a web app; calendar/scheduling/notifications with some social networking and people matching/search functionality. The site will be highly configurable/maintainable by it's community from establishing/interacting within groups to tweeking page layouts.<p>So far, I have chosen this stack:<p>Ubuntu, Apache (dynamic content), thttpd (static content), MySql, memcached.<p>I'm quite experienced in Perl but just a beginner in both Python and PHP yet I am determined to use either Python or PHP in my latest project.<p>I'm looking for the pros/cons and any other tips from the HN community. I'm at a fork in the road and I guess that once I make this choice, it'll be quite difficult switching after the initial framework is built out.<p>I'm not sure if I have/haven't given enough information to go on but I would appreciate everyone's input, not only on PHP or Python but on any of the other technologies I have chosen as well as critiquing my (currently vaporware) web app.<p>So which is it; PHP or Python?

27 comments

menloparkbumalmost 17 years ago
I've used all three of the languages you mention for relatively large web applications. People will say PHP sucks because it is ugly and retarded and only has one namespace. People will say Python sucks because of the whitespace issue and mod_python doesn't work on a $5/m shared hosting plan. Perl sucks of course because "the syntax is crazy!" But, huge sites are built in PHP (Facebook, Hype Machine, Flickr, half of Yahoo!), Python (much of Google) and Perl (craig's list). In my experience they are all about equivalent except for aesthetic reasons.<p>The headaches in a web app are usually at the user interface level (DOM/CSS/Javascript) and at the systems level (there's a bug in fast cgi! MySQL imploded!) and language choice gluing it all together is mostly a matter of taste. People with taste overestimate its importance. You can get pretty far in the internet biz with no taste (MySpace... originally done in COLD FUSION).<p>That said, the most tasteful option out of your choices is Python.
评论 #212075 未加载
评论 #212195 未加载
评论 #211894 未加载
jrockwayalmost 17 years ago
Why throw away Perl? You already know Perl, and Perl has lots of things that PHP and Python don't. Before you ditch Perl, look at DBIx::Class, Moose, and Catalyst. And the other 10,000 libraries on CPAN.<p>Then look at the 500 or so libraries available for PHP.<p>Perl has a really insane library culture, and it's very hard to give that up. I like the syntax of other languages better (Lisp is my favorite), but it's hard to give up the millions of hours of free work called the CPAN. Perl also has great tools for testing (see how many Test:: modules there are), and it has a <i>culture</i> of testing. So the libraries you download from the CPAN aren't some untested i-hacked-it-together-while-drunk snippets of code; they're all very carefully tested. What it boils down to is that when you move your app from development to production, you'll be reasonably sure that your libraries (and app) still work.<p>One line summary: Perl has more features and libraries than the alternatives, <i>and</i> you already know it! I think the choice is a no-brainer.
评论 #211790 未加载
rmsalmost 17 years ago
Python... both languages are along far enough that they will meet all four of your points, but people that program in python are on average better programmers than PHP programmers. So it makes hiring good hackers easier by eliminating many of the bad hackers.<p>Other than that, if you like the syntax of PHP, it is as good as python as long as you program using the MVC paradigm. Personally I like the syntax of python a whole lot more than PHP.
评论 #211945 未加载
评论 #211822 未加载
yourabialmost 17 years ago
Go with Python. PHP is probably the worst language I've had to use (Single namespace, poor unicode...)<p>Python on the other hand is pretty cool. It can be OO, functional, or procedural depending on how <i>you</i> want to look at it. It also has a lot baked into the standard interpreter and has some really awesome frameworks (Django, Pylons)
评论 #211834 未加载
thoraxalmost 17 years ago
I loooove Python. But if asked to "bet the farm" on a web app, I'd go with PHP because it's been successfully demonstrated again in again in every form of web app you can imagine. In a year, I'd recommend Python, but I still find Django and the other web frameworks a bit too immature and clunky to do things that PHP has been hacking with for years and years. As much as I hate to say it, for the Python community the web server has been an afterthought until the past two years. PHP was bred there.<p>I probably would say it's a closer call if we hadn't found a great MVC framework for PHP called Code Igniter that just makes PHP (of all things) much more pleasurable to hack in than it used to be.<p>All this being said, you're not risking much by going with Python/Django. But if the farm is on the line, I'd personally have to go with LAMPhp.
评论 #212264 未加载
评论 #212429 未加载
评论 #211866 未加载
treedalmost 17 years ago
Python. For a lot of reasons. It's easy. It has a lot of libraries. The Python based CMSs are better. And most importantly it's easier to find decent python programmers. The vast majority of PHP guys I have interviewed ONLY know one language: PHP. The python guys tend to be much more well rounded. Of course the PHP guys are usually cheaper. You get what you pay for in this case. I would also have to recommend against perl. I did perl for 10 years before I switched to python 4 years ago. I think their philosophies say it all: Perl: There's more than one way to do it. Python: There's one obviously right way to do it. Sure, that's a huge generalization but I find it true in a lot of cases. Perl really is line noise compared to Python. And reading someone else's Perl is a real challenge.
评论 #211891 未加载
wensingalmost 17 years ago
Python. It is more powerful with an extremely flat learning curve. In other words, you don't hit many walls with it. When you want to do something more powerful, the answer is 'right there'--it fits the brain.<p>This is a bit dated but may help: <a href="http://www.artima.com/intv/prodperfP.html" rel="nofollow">http://www.artima.com/intv/prodperfP.html</a>
评论 #211881 未加载
评论 #211934 未加载
andreyfalmost 17 years ago
Python has functions as first-class objects, very simple namespaces (files/folders), generators, and a cleaner syntax not to mention a thriving, growing community, much more helpful/intelligent (at least in my experience) than PHP's.<p>PHP has a lot of coders that are one step about script-copy-pasters.<p>No questions about it - Python is the way to go.
sachinagalmost 17 years ago
I spent a lot of time bellyaching about this when starting my company - looking at PHP, Perl (preferred by the devs), and Python (preferred by the advisers I trust).<p>In the end, we went PHP, and it was hugely lucky - we were able to hire a couple of devs on very short notice because we were in PHP, even though we use a less popular framework called Qcodo. After they were hired, I asked them what they thought, and there was no way they were going to learn a new language to join us, but they were ok learning a new framework.<p>My feeling is that PHP has the largest base of developers out there, and that means that you've got the biggest base of potential co-workers. If you yourself are a great hacker, you can prop up whoever else you're working with. If you're building an app/business to scale, you have to have other hackers join you.<p>Hell, Apple has a hard time finding Objective C hackers, and they're Apple.
评论 #211956 未加载
评论 #211887 未加载
Hexayurtalmost 17 years ago
Python. PHP is really good for hacking things out, and there's a case to be made for using Python for the back end programming, and odds-and-sods of PHP to extract data into templates and so on - but fundamentally if you have real code to write, use Python.<p>PHP ain't bad, but PHP code is fragile. The language, over a year or two, meanders about breaking code willy-nilly, and that alone is good enough reason to steer clear of it for serious applications.
fedecargalmost 17 years ago
1. Based on content management: PHP. The biggest publishing site on the Web, Wordpress, uses it.<p>2. Based on libraries: PHP. You have PECL, PEAR, ezComponent, Zend and many others. Whatever you need, it has it.<p>3. Based on syntax: PHP. It's damn simple.<p>4. Based on deployment: PHP. It's fast and painless.<p>5. Based on execution model. PHP. mod_php, as an apache module, works and it’s scalable.<p>6. Based on frameworks: PHP. Symfony and Zend Framework offer a modular, MVC, loosely-couple architecture. They not only provide a solid infrastructure, but also an extensive component library.<p>7. Based on performance: Any, as long as you cache everything.<p>Good luck!
mechanical_fishalmost 17 years ago
<i>calendar/scheduling/notifications with some social networking and people matching/search functionality. The site will be highly configurable/maintainable by its community from establishing/interacting within groups to tweeking page layouts.</i><p>How much of your app can be built by hooking together existing Drupal modules?<p>If the answer is "lots" -- and because your brief description sounds like a long list of stock parts from the Social Network aisle at Costco, I wouldn't be surprised if it is -- perhaps you should consider Drupal. Which means PHP, alas, but that's a small price to pay for avoiding the annoyance of building every single one of your site's 120,000 proposed features yourself, from scratch.<p>If the answer is "a lot, except for features X and Y, and I hate Drupal's existing, buggy options for Z" the Drupal community will be really happy to see you develop and contribute open-source code that can do X and Y. And we probably <i>all</i> hate Z, so fix it and you'll be our hero. You'll have plenty of time to work on Z because you won't be spending time redeveloping things like "basic user logins with emailed password reminders", or "users can create and join groups which have their own subsites" from scratch -- yet again -- in a language whose idioms you haven't learned yet.<p>If the answer is "not much"... may I suggest that you seriously reduce the scope of your first project?<p>Of course, if the proposed app is less of an actual future product than it is an excuse to broaden your mind by learning a language that's not Perl or Java, you should probably grab onto Python or Ruby with both hands. PHP has many practical features, but it doesn't have much to teach a Perl programmer.
评论 #211880 未加载
mojubaalmost 17 years ago
Don't worry about "Extensive support of libraries and frameworks", you don't need it. All web sites I built, large and small, required only two additional components: the DB glue (typically mysql) and UTF support (mbstring). There may be specific situations when you might want to send https requests or use compression, but that's ok, even that is not called "extensive libraries and frameworks". The bottom line is, a good web site has a clean, simple source that doesn't depend on third-party code that much.
terminatoralmost 17 years ago
The best advice is try both PHP and Python and choose the one that matches your taste.<p><a href="http://www.google.co.in/search?q=php+sucks" rel="nofollow">http://www.google.co.in/search?q=php+sucks</a> <a href="http://www.google.co.in/search?q=python+sucks" rel="nofollow">http://www.google.co.in/search?q=python+sucks</a> <a href="http://www.google.co.in/search?q=django+sucks" rel="nofollow">http://www.google.co.in/search?q=django+sucks</a>
tubbyalmost 17 years ago
PHP. Why? Because if you ever move your app to a hosted server, you'll have tons of hosting options with PHP. Only a few with Python.
评论 #211897 未加载
underscorealmost 17 years ago
What are your feelings as a beginner in each language? Have you found any little design decisions that leave you scratching your head, or make you start cursing loudly at the computer? Have you built anything with them? If so, did you run into any issues that you feel were a result of the language?<p>I'm a bit of a hedonist, but if I were in your situation, I'd probably try to pick the one that was the most fun to work with. As you say, once you've started building, it won't be (or maybe for you it will be?) as easy to switch, and you probably don't want to figure out that you hate coding in whatever you've chosen while trying to finish your web app.<p>When in a variant of your situation (PHP/a PHP framework versus Python/Django), I chose Python. I'm not you, so we may have totally different tastes and may have come to a different conclusion given the facts. I've been pretty happy with my choice, though.
评论 #211795 未加载
iamdavealmost 17 years ago
&#62;calendar/scheduling/notifications with some <i>social networking</i><p>Why?<p>More and more web apps are coming out with social networking tied in, and very few of them succeed BECAUSE they have social networking tied in. Socializing a site is a bit more than giving people profile pages and enabling them the ability to "friend" people, at least that's how I look at it.<p>So my question to you is this: how are you planning to make the social aspect of your site actually work? How are you going to make the ad hoc benefits of social networking replicate to an online presence? Will people actually benefit from socializing, or are they just going to have friends who they will have the extraneous ability to leave comments about?
评论 #211804 未加载
metajackalmost 17 years ago
Language isn't as important as the framework you will use for developing the web app. Have you looked at Django vs. Simfony, etc? Why not consider Ruby and Ruby on Rails?<p>I tend to choose Python and more specifically Django.
talkaboutadatealmost 17 years ago
Why don't you do a small prototype in both, and see where each one takes you? I'm not really a programmer, but I've got a dating web app running on around 50 pages of php.
schtogalmost 17 years ago
i never used Perl, one of the few languages i havent even tested.<p>so it has a culture of libraries people say but what kind?<p>making a lot of really high-quality ones like in python or just spewing out tons of buggy libraries with poor documentation and it is hard to find what you need or something in between?
wvenablealmost 17 years ago
PHP. So in a year down the road, you won't have to make the switch to it like everyone else has.
评论 #211826 未加载
bayareaguyalmost 17 years ago
Why two web servers (thttpd and apache) instead of just one, say lighttpd or nginx?
评论 #211994 未加载
评论 #211871 未加载
bingloalmost 17 years ago
Why are you determined to use either Python or PHP in this latest project?<p>I would make sure you have a good answer to that question before using something besides Perl.
评论 #211830 未加载
sicularsalmost 17 years ago
python
RobertLalmost 17 years ago
Excellent discussion by some obviously very experienced and intelligent people. I haven't used Perl too much, I'm much more experienced in Python and PHP, but I think all are capable languages.<p>I think the most important things to consider are things that you can't really relate effectively to a forum discussion like this and that is what your real skill levels at each of these languages is and the availability of skill in your area and network of friends.<p>I would lean more to those factors for making the final decision because it makes no matter that python might have wome extremely elegant and powerful syntax or library for coding a specific functionality if nobody working on the project is familiar enough with the language know the syntax or the library.<p>The primary investment in any new app like this is "developer time". Managing that resource requires the juggling of many more factors than the capabilities of any given language.
bjclarkalmost 17 years ago
Ruby
评论 #211872 未加载
lakeeffectalmost 17 years ago
Python, It is more responsive than php.
评论 #211784 未加载