

Ask HN: Bet the farm. Python or PHP? - t0pj

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?
======
menloparkbum
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.

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).

That said, the most tasteful option out of your choices is Python.

~~~
hello_moto
Most of Google products were written in C++ or Java.

GMail - Not Python

AdSense - Not Python

GMaps - Not Python

Search - Not Python

~~~
lyime
source?

~~~
hello_moto
AdSense - <http://www.reddit.com/info/6m9fi/comments/c04990m>

Reference to Guice.

GMaps - my ex-TA was an intern at Maps team, she told me that mostly it is
written in C++. She also told me how surprised she was when she found out that
most big products were written in C++/Java instead of Python.

GMail - might want to ask Paul Bucheit, but I remember vaguely coming across a
blog post/article saying that it is written in C++ and Java.

Joshua Bloch (Effective Java author) said that they developed in-house
middleware that bridge Google's infrastructure with Java (BigTable, MapReduce
were written in C++).

I suspect Google is using JNI to access C/C++ based framework/infrastructure.

So far, I only know 2 products written in Python:

1) YouTube (purchased)

2) Google Groups (semi purchased I think, from the people that brought you
ClearSilver template in Python).

I heard YouTube had to integrate their code to Google's infrastructure, but I
don't know if they had to re-write some stuff.

------
jrockway
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.

Then look at the 500 or so libraries available for PHP.

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 _culture_ 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.

One line summary: Perl has more features and libraries than the alternatives,
_and_ you already know it! I think the choice is a no-brainer.

~~~
t0pj
I really would like to use PHP or Python in a big project to at least get some
experience.

I tell ya, I do love Perl.

With limited exposure to PHP and Python, could you elaborate on some of the
things PHP and Python are lacking compared to Perl?

~~~
xirium
Most fundamentally, PHP combines Perl's array and hash data structures.
Although you can access name/value pairs as even and odd array elements, code
that doesn't need both sets of properties will run slower and consume more
memory because a structure implementing both sets of properties is implemented
automatically.

Why use a languge like that when you're already familiar with Perl?

~~~
jrockway
If I recall correctly, a PHP "array" doesn't necessarily iterate (with
foreach) in numerical order. That's just weird.

------
rms
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.

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.

~~~
t0pj
I guess, for a lot of people, PHP would be easier to dive into than Python?

I get your point; without any other knowledge, you'd be better off selecting
from a pool of Python developers than PHP developers when looking for good
hackers. Correct?

Although I would be able to somehow separate the good hackers from bad by
initially chosing Python, would you say that good hackers would also stay
clear of opportunities where PHP is involved? What would facebook think about
that? ;)

Just want to know your thoughts. Thanks.

~~~
jrockway
You won't find any PHP hackers. The good PHP developers realized that PHP was
a waste of their time a long time ago. All the novices have significantly
lowered the average PHP developer's salary compared to other languages.
Basically, there's no skill and no money in PHP, so the good people don't use
it.

~~~
rms
This is stated as an absolute where there are certainly good PHP developers
that work at Yahoo and Facebook... still, a less extremely worded version of
your statement is true.

~~~
wallflower
upcoming.org was coded in PHP. That being said, anyone can code a website but
creating a website of value that attracts users...

------
yourabi
Go with Python. PHP is probably the worst language I've had to use (Single
namespace, poor unicode...)

Python on the other hand is pretty cool. It can be OO, functional, or
procedural depending on how _you_ want to look at it. It also has a lot baked
into the standard interpreter and has some really awesome frameworks (Django,
Pylons)

~~~
t0pj
Single namespace in PHP - Ouch. You can gracefully get around this with
classes perhaps?

Any thoughts on PHP frameworks?

On Python, I've heard that TurboGears is a pretty good framework as well.

I remember reading somewhere that you don't run Django, it runs you. Any
fiction in that?

~~~
wensing
_you don't run Django, it runs you_

I use Django (GeoDjango actually) at my full-time job, and love it. My
progression was PHP -> Python -> TurboGears -> Pylons -> Django. I can say
with confidence that it is the best of them all. Yes, many choices have been
made for you, but they have been made in an elegant, Pythonic way, and you
retain the ability to get under the hood to a healthy extent.

~~~
noahlt
May I ask why you switched from Pylons to Django?

~~~
wensing
The real reason I switched was because I began working at a newspaper, and
Django and journalism are married/fused inextricably. Choosing Pylons over
Django in a news endeavor would be rather ... odd.

That aside, I said I progressed from Pylons to Django because I would choose
Django if I had to do the Pylons project over again. Why? Because although I
rejected (rebelled against?) it at the time, being 'forced' into an ORM for
data entities would have been a really good thing. Since Pylons "lets" you
shirk an ORM, I did ... but the result feels more like PHP than Python. Turns
out Django's hand-holding is, in many cases, good because the answer they
provide is the smart thing to do. And doesn't that sound like a description of
Python itself?

Would I choose an ORM-ified Pylons experience over Django? Probably not.
Django routing seems better, there's Django-enhanced unit testing, and I even
prefer the way Django forces you to keep Python out of your templates in favor
of "template tags" and "filters".

Perhaps most importantly, Django has nearly-impeccable documentation, and a
thriving community.

------
thorax
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.

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.

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.

~~~
t0pj
Code Igniter framework for PHP.

Thanks. I'll take a look at that.

~~~
MikeW
My personal gripe with Code Igniter is that it doesn't have a built-in
templating language (this is by design).

I absolutely love Smarty (smarty.net) and highly recommend it and have used it
in many projects so far.

There have been attempts to integrate Smarty into CI but I saw a benchmark
that showed that combination was unacceptably slow and won't scale well.

~~~
t0pj
Thanks for the link to Smarty. I'm checking it out now.

------
treed
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.

~~~
t0pj
I can tell ya that reading and understanding some of my own Perl from even 3
or 4 years ago is a real challenge. ;)

All I can say is that I hope I'm getting better.

------
wensing
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.

This is a bit dated but may help: <http://www.artima.com/intv/prodperfP.html>

~~~
t0pj
Once again, I appreciate the links. Thanks.

------
andreyf
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.

PHP has a lot of coders that are one step about script-copy-pasters.

No questions about it - Python is the way to go.

------
sachinag
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).

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.

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.

Hell, Apple has a hard time finding Objective C hackers, and they're Apple.

~~~
neilc
If you're hiring candidates that wouldn't consider learning a new language to
join an interesting startup -- well, good luck!

------
Hexayurt
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.

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.

------
fedecarg
1\. Based on content management: PHP. The biggest publishing site on the Web,
Wordpress, uses it.

2\. Based on libraries: PHP. You have PECL, PEAR, ezComponent, Zend and many
others. Whatever you need, it has it.

3\. Based on syntax: PHP. It's damn simple.

4\. Based on deployment: PHP. It's fast and painless.

5\. Based on execution model. PHP. mod_php, as an apache module, works and
it’s scalable.

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.

7\. Based on performance: Any, as long as you cache everything.

Good luck!

------
mechanical_fish
_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._

How much of your app can be built by hooking together existing Drupal modules?

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.

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 _all_ 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.

If the answer is "not much"... may I suggest that you seriously reduce the
scope of your first project?

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.

~~~
t0pj
I appreciate the advice.

You know, I sometimes feel as though I'm living under a rock. It pains me to
expose my naiveté, but I never really heard of (even the word) Drupal until
about a month ago and all of a sudden /bam/ I must've overheard Drupal in
conversations at least three or four times since then. I never really put two-
and-two together on this one; selective hearing perhaps?

I tell ya, I'm always learnin' something new.

Thanks for opening my eyes.

------
mojuba
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.

------
terminator
The best advice is try both PHP and Python and choose the one that matches
your taste.

<http://www.google.co.in/search?q=php+sucks>
<http://www.google.co.in/search?q=python+sucks>
<http://www.google.co.in/search?q=django+sucks>

------
tubby
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.

~~~
t0pj
Hopefully, PHP would still be the right choice _for me_ if I then have to move
beyond the single hosted server.

That is interesting though; that there does seem to be a ton of hosting
options with PHP versus Python.

------
underscore
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?

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.

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.

~~~
t0pj
Thus far, I've built very simple pieces of PHP such as logins, maintaining
sessions, writing/reading to/from MySql. My one concern with PHP is the
overwhelming "alphabet soup" of functions.

I haven't done anything web-facing with Python just yet, just using it to;
parse files, some socket programming - basically getting a feel for the
language.

So far, I couldn't say I've run into any issues resulting directly from the
languages themselves.

Thanks for the input.

------
iamdave
>calendar/scheduling/notifications with some _social networking_

Why?

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.

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?

~~~
t0pj
Wow. Lots of questions. Thanks!

On a plan to make the social aspect work, is there a finite list of ways to
choose from? I don't believe there's really only one way. It definitely seems
that "social networking" could have a negative effect on my plan yet I hope to
do things a little differently.

There will be some socializing benefits.

~~~
iamdave
When I say "how" I don't mean are you going to use OpenSocial or anything like
that. I mean when you implement it, how are you going to make it useful?

~~~
t0pj
I don't mean to be coy, but it comes down to giving people something that 1)
removes, transfers, or simply defers pain and 2) simply increases happiness.

I would think that's useful in some way to some people at least some of the
time.

------
metajack
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?

I tend to choose Python and more specifically Django.

------
talkaboutadate
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.

------
schtog
i never used Perl, one of the few languages i havent even tested.

so it has a culture of libraries people say but what kind?

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?

------
wvenable
PHP. So in a year down the road, you won't have to make the switch to it like
everyone else has.

~~~
t0pj
Should I read that as a little tongue-in-cheek? :)

Everyone else has switched to PHP? Explain, please.

------
bayareaguy
Why two web servers (thttpd and apache) instead of just one, say lighttpd or
nginx?

~~~
t0pj
If I go with PHP, Apache will be running non-threaded.

To run Apache/PHP as lean as possible, I'll take advantage of thttpd's polling
to quickly serve up any static content I have to as many simultaneous
connections as possible.

I haven't taken a really deep look at lighttpd nor nginx.

I see what you mean though, why would I use two distinctly different http
servers where one would simply do?

Could you give me some hints as to what I'm missing out on if I stay with
Apache and thttpd or what I'd gain going to either nginx or lighttpd?

Thanks!

~~~
rcoder
Apache buys you two things: rock-solid, time-tested stability, and millions of
words of writing both online and in print about administration and tuning.

Lighty and Nginx are both (like thttpd) leaner, potentially faster, and
"sexier." Neither has the proven stability or community that Apache does, and
neither is going to help much if your bottlenecks are at the application
layer, rather than just shooting raw bits over a network cable.

~~~
t0pj
_Neither has the proven stability or community that Apache does_

I care about the community/support aspect and you're right; I think going
solely with Apache, and skipping the leaner httpd engines, is definitely a
possible choice for me.

Thanks.

------
binglo
Why are you determined to use either Python or PHP in this latest project?

I would make sure you have a good answer to that question before using
something besides Perl.

~~~
t0pj
I actually know Perl and Java pretty darn well.

I wish to constantly expand my understanding of computing in general, and
learning a new language is a great way to go.

I hope to not only learn a new syntax or two but also learn to think in
different ways. This works with human languages, too. Yosh!

~~~
binglo
Ah. Ok, then that makes things easier.

For your case, don't use Python, nor PHP. Both are pretty much just like Perl
and Java with only minor syntax changes.

If you want to expand your understanding of computing in general, while _also_
learning a new language, _and_ while doing a webapp, if I were you I'd learn
Common Lisp and try out Hunchentoot. There's even some screencasts for that
setup floating around.

Going with Python or PHP after Perl and Java is _not_ going to be terribly
enlightening for you.

~~~
t0pj
Thanks for the advice.

I've also been learning Lisp (sbcl) over the last six months and have tried
out Hunchentoot with elephant, cl-who, and parenscript.

I'd say one of the things keeping me from going with Lisp is the potential
pool of developers to pick from when expanding the operation. I think I would
have a better chance at enlisting others with PHP or Python than with Common
Lisp. Is this line of thinking wrong?

------
siculars
python

------
RobertL
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.

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.

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.

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.

------
bjclark
Ruby

~~~
tubby
Slow

------
lakeeffect
Python, It is more responsive than php.

~~~
t0pj
By more responsive, you mean from rendering the html/css/js sent back to the
browser? Or more responsive when connecting to the back-end MySql database?

If you could elaborate, I'd appreciate it. Thanks!

