

Ask HN: Is PHP more scalable than Ruby or Python? - mikeyur

Edit: I just realized how generic my post was... so I want HN to weigh in on something a friend said:<p>"PHP is more scalable than Ruby and most languages"<p>//start old post
Let me preface this with: I'm not trying to start a language war.<p>I have very little experience coding, but have learned enough (some may say 'caught') PHP to get by.<p>I want to take it a step further but I'm getting thrown in a thousand different directions. I want a language/framework that's fairly straightforward and somewhat scalable.<p>I am looking at Python/Django, but getting pulled towards Ruby/Rails by friends - and some people saying that PHP is more scalable than either Python or Ruby and I should be looking at the Cake or CodeIgniter frameworks.<p>Can someone push me in the right direction? I want to invest the time in a language but I'm not sure which to start with.
//end old post
======
teej
Scalability for web applications has -nothing to do with the programming
language-. PHP, Ruby, Python, ASP.net, they all use the same strategies to
scale. Three things: cache religiously, index well, and refactor your database
queries.

Take it from me: I've worked on a Java site with over 2 million monthly
uniques. I built a Ruby on Rails app from the ground up that grew to over 15
million pageviews a day. I also helped build a PHP-backed api the handled a
few million hits a month.

I'm sick and tired of the "X scales better than Y" debate. It's pointless.

~~~
dasil003
Not only pointless but willfully ignorant. Think about it, people who say one
language is more scalable than another don't even understand scaling means.
Only slightly better are the religious rants about some framework or another.

In reality, the most a language or framework can provide is a slight head
start in terms of absolute performance. The dominant factor will always be
nature of the application.

------
mechanical_fish
Don't freak out about it. This is not like getting married.

First the easy advice: If you have friends pulling you toward Ruby and
Rails... learn Ruby and Rails. Momentum is a good thing. Comradeship is a good
thing. Don't worry: If it turns out in two years that we'd all rather be using
Python and/or Django, we can switch. It will still be there.

Now we begin to edge toward personal opinion: I'd avoid sticking with PHP. Not
merely because PHP is often like a parody of a programming language, but
because variety is the spice of life. Learn something different. Take a look
at how other languages do things.

Now, if you really want to stay out of a language war, ignore anyone who goes
on about the "scalability" of their chosen language. Most of those claims are
just posturing, backed up with no relevant data. [1] If your PHP friends won't
shut up about their language's unbeatable super speed, show them the first
fifteen minutes or so of Yehuda Katz's Merbcamp keynote:

<http://www.merbcamp.com/video/katz3.mp4>

... and once they're done rending their garments and throwing things at the
screen tell them to take some data and go argue with someone who cares. You've
got better things to do.

\---

[1] Why do most language scalability arguments have such dubious data to back
them up? Because, as others have taken pains to point out, languages don't
scale: _application architectures_ scale. If your webapp is much more complex
than "Hello, World" its efficiency will depends on a host of factors, of which
the speed of any particular language construct is usually a tiny one.

------
icey
Any mainstream language you choose will be scalable enough.

Spend some time reading online rails and django documentation. Either one will
be fine for you to learn.

My personal opinion is that Python is easier to learn for a beginner, but not
by much. Ruby has <http://hacketyhack.net/> which is a fun way to learn, and
Python has <http://www.diveintopython.org/> which is a tremendous (and free!)
resource.

I say flip a coin and roll with it. They're both great languages and both
frameworks are great for learning.

[Errr... The submission changed after my response was entered, sorry if it
seems a bit off-topic.]

~~~
shutter
That's true; Ruby and Python would both be worth learning. I'd push you toward
Python, though, mainly because it has more traction outside of web development
too (e.g. system administration, etc).

------
jacquesm
Scaling software has much more to do with the architecture of the software
than with the language.

It is possible to write software in any language that scales poorly as well as
to write software that scales very well.

Right now I'm working on a site that pulls in about 1/2 million uniques daily
written in Java (chosen by the programmer before me), before that that same
site was written in PHP.

Ruby, perl, PHP they're all just different hammers, a good programmer should
be able to write scalable web applications with all of the above, but will
find a matter of personal preference (or historical accidents) to make the
decision.

In the beginning it is probably smarter to learn how to program in a language
for which there is a market, not to focus so much on scalability issues
because when just starting out getting paying work is probably more important.

Another issue when learning how to code is to learn how to write clean code, I
know I'm showing my age here but you could do worse than to have a look at the
source code to the GNU utils package, there is a ton of 'good' code in there
that will help you to develop a legible style. That will come in handy in any
language, scalable or not :)

------
eatenbyagrue
I assume you're asking about scalability in terms of pages per second or
whatever, but what you should be more worried about is the scalability of your
development effort. As other posters have said, speed of the platform is not
the issue.

Rather you should consider what platform you think you can get the most done
in the shortest amount of time - having friends that use the same platform
counts for a lot. Similarly, many people think (including myself,) that you
can get more done faster using RoR or Django than you can PHP, particularly if
your project has any complexity.

------
pstinnett
Just made a very similar thread to this!

<http://news.ycombinator.com/item?id=460456>

~~~
mikeyur
I decided to change it up to 'is php more scalable' - realized how generic my
question was. Checking out your thread right now.

------
bharris
Why are you worried about scalability when you're just learning to program?

~~~
mikeyur
I'd like to keep it in mind and I find it fascinating. Plus, in the future I
don't want to have to tear down what I've built and rebuild again just because
it wasn't scalable from the start.

Basically I know enough PHP to get by and if it's possible to code some
awesome, and scalable, apps in PHP then I might as well expand my knowledge of
PHP instead of starting with something new and completely foreign.

~~~
jonny_noog
PHP advocate Terry Chay has said:

 _Rails is like a rounded rectangle and PHP is like a ball of nails._

 _When I say that PHP is a ball of nails, basically, PHP is just this piece of
shit that you just put together put all the parts together and you throw it
against the wall and it fucking sticks._

Putting aside the comparison between a framework and a language (maybe he
really meant Ruby rather than Rails, I don't know), These quotes really rung
true to me as a person who has some experience with PHP and Ruby on Rails.

PHP is ugly, no one will really disagree with that. But when used in the
domain is was designed for (websites) it gets the job done. It's a ball of
nails that sticks to the wall. Until recently at least, Rails was a bit more
hassle to deploy, PHP is ever present, even on super cheap shared hosting
packages and more "plug and play" in deployment. The fact that PHP is so
popular means there's a massive amount of pre-existing apps and help (of
varying quality) only a Google search away. This is true for any language, I
guess, but PHP more so than most.

But Ruby (like Python) is a bit more general purpose and compared to PHP just
seems more thought through to me. More consistent. I've always felt that aside
from any other factors, this possibly also has to do with the age of the
languages and what time they "grew up" in. But in any case, I actually find it
easier to conceptualise more in depth concepts when using Ruby and Rails. So
Ruby - and by extension - Rails is more like a rounded rectangle, it feels
nice with no sharp bits, somehow balanced and symmetrical in my mind. But I
feel the initial learning curve of Ruby (and I assume Python) might be a
little steeper than PHP. Maybe that's just because I had gotten more ambitious
by the time I'd hit Ruby.

Hopefully my ramblings have helped you a little. But to more directly answer
you, yes it is absolutely possible to code some awesome and scalable apps in
PHP. Just look around, the Internet is full of them. But would you benefit
from learning some Ruby or Python along side your existing PHP knowledge, the
answer is again absolutely yes. I probably don't have to add it, but just to
be clear, you can of course also code some awesome and scalable apps with Ruby
or Python.

I don't think these choices are as "either or" as a novice might generally
think. Many concepts are similar regardless of which language you use. Putting
time into one language does not necessarily mean that time is wasted if you
later choose to switch.

~~~
dasil003
PHP is a great language to get stuff done. And if you're a decent programmer,
the later versions even give you the tools to get things done relatively
nicely.

The only problem for a beginner is that you'd have a hell of a time finding
any decent code to learn from. This can be a problem in any language to some
degree, but PHP is the worst, followed shortly by Javascript.

