

Ask HN: PHP or Ruby? - neel980

Looking to build a website with social networking elements to connect people. Which is a better choice, PHP or Ruby? Need to consider scalability, performance, ease of development, support, hosting...
======
rb2k_
Scalability doesn't have anything to do with the programming language but
rather with the architecture. The same goes for performance unless you're
talking about pure number-crunching. The ease of development depends on your
experience with either toolset.

I'm sorry if this sounds harsh, but by asking this question you sound like you
aren't a programmer but rather somebody that wants to go to rent-a-coder and
have somebody build 'the next facebook'.

~~~
neel980
You are right, partly. Am more of a DB person with a minimal understanding of
scripting languages. Hence the reach-out. About building the next facebook, I
would love to.

------
Lazare
Short answer: Any language can scale, and any language can perform well. The
easiest language to develop and support is the one you know. Hosting is just
as simple/easy/cheap with either language. If you already know one of those
languages, go with it. If you don't, go with Ruby; it's a vastly better
language, with a more mature ecosystem.

Longer answer:

* Scaling and performance is mostly an issue of architecture, and is heavily dependent on what you're trying to accomplish. You can go a long way just by using varnish/nginx/memcached as appropriate, and serving static assets from a CDN. The actual language is sort of a sideshow, because no language is fast enough; everything needs to be pre-calculate and cached.

* If you don't know either language, you'll probably find that Ruby is easier to learn and become productive with, but it's easier/cheaper to find good PHP developers. Kind of a wash. In either case, you will absolutely need to pick and learn a framework as well, which adds more overhead. (No, you aren't going to write a social networking app in PHP without a framework.)

* It's easier to get a basic PHP page hosted, but if you're even _thinking_ about scalability and performance, then you need more than Bob's Discount Hosting. Doing PHP hosting right is no easier (or harder) than doing Ruby hosting right.

Basically, it doesn't much matter. At the end of the day, _most_ (not all)
programmers who have programmed in both detest PHP and love Ruby, and you'll
_probably_ find it easier to hire PHP devs.

------
shanelja
I personally prefer PHP, having used both.

I'm not saying that Ruby is better or PHP is better, it really depends on your
ability with the two, but from what I have found in the past, PHP has been
easier to scale and has performed well, it is also more widely hosted, though
this is really irrelevant as there are still plenty of ruby hosts.

Support for PHP is generally better as it has a larger user-base but generally
Google is your friend either way.

You should make the decision based on personal preferences, for instance, I
find Ruby much more fun to write, but I can't stand debugging it, whereas I
have used PHP for so long that now, those stupidly bad error messages are
actually a native language to me.

------
anujkk
The one you are more comfortable in developing. Choice of framework is more
important. If you are good in PHP choose a framework like codeigniter or
symfony. If you are good in Ruby choose a framework like Rails.

I have developed in all php, ruby, python and my personal favorite is
Python/Django or Python/Flask.

If you want to use any 3rd party api e.g., Facebook API make sure it has
official SDK for language you choose.

~~~
shanelja
Could not agree more, I used to hate frameworks but after experiencing
codeigniter I can definitely see the benefits now, faster development, less
complicated code and a structured site architecture.

Though, the crypto packages on CI could definitely use an upgrade.

------
eclipse31
This is a question I've been dealing with myself for some time. I've alot of
professional experience with PHP but have done some work in Ruby (on Rails)
too. I'm looking to build a decent size site and in the end have opted for PHP
for the following reasons:

\- familiarity with the language \- wide support and hosted everywhere \- not
restricted by Rails 'norms' \- easier to get up and running on a live server,
even if it's your own virtual box \- proven scalability \- personally not mad
on ActiveRecord (Rails way of interacting with DB). Would rather have greater
control over my DB interactions, which I know is possible in Rails but it's
very non-standard

Ruby IMHO is a far superior language to PHP, but you will have to learn a
framework to get it up and running on the web, whether it's Rails, Sinatra or
something else. Same with Python. PHP doesn't require a framework, although
plenty exist, so it'll be easier to get an initial prototype up and running.

------
vaidik
If you are considering PHP, do explore Yii framework. I haven't used Yii
myself but I have heard a lot about its goodness as compared to other PHP
frameworks.

If Ruby, RoR should be the first choice I guess. You may also want to consider
Sinatra.

------
wldlyinaccurate
Are you going to be writing the majority of the code? If so, try out both
languages for a few days each and see which you like better. Spending a week
choosing the right tool for the job will save you countless hours in the
future.

If you're outsourcing the development then you shouldn't be concerned about
which language is used. You should be looking for a team of developers who
know what they're doing and have experience building systems similar to yours.

Performance and scalability shouldn't be factors when choosing a language,
either. Good caching and a delivery network like Akamai or CloudFlare will be
more than enough for most large websites. I work on several large (100k+
visitors/day) websites that run on PHP - we get by just fine by caching the
hell out of everything on multiple levels (web server, traffic manager,
Akamai).

My advice is to focus on the end product, not the implementation. Don't get
caught up in which technologies to use, or you will lose sight of what you
want to create.

------
peterhi
However if you are looking to recruit coders for the project first you need to
find a good (PHP / Ruby) coder and then let them help you with the recruiting.
If your skills in either PHP or Ruby are not up to snuff then you are likely
to make some serious recruiting mistakes.

Also I would recommend that you take a serious look at python. My personal
preferences puts java at the bottom of the list and PHP above that but below
python and ruby (I'm a ROR developer by the way).

------
dailygrind
PHP if you are on a shared hosting environment, otherwise Ruby.

------
Bolgar
If you ask such questions, then php

------
dirktheman
Do you already know one of these languages? You know what they say about
photography: the best camera is the one you have with you. The same goes for
programming: if you already know how to build something in PHP, there's not
much sense trying to make the project in Ruby.

If you know neither, try both of them for a short while and see which one you
like better. It's really a 'what do you like better: apples or oranges' kind
of question.

------
sandGorgon
If you are concerned with Ruby and scalability, use JRuby on top of Tomcat. It
does give you a few pieces of magical scalability, however (and more
importantly) it allows you to work with "enterprisey" Java
tools/libraries/systems that allow you to reach reasonable levels of
scalability quickly.

And read this - <http://www.ruby-forum.com/topic/1119702>

------
jacobwg
I agree with many of the other comments here (I prefer ruby myself, but agree
that the architecture is what determines scalability).

On the PHP bit, I've done a fair amount of PHP work, but am trying to avoid it
for the following reasons: [http://me.veekun.com/blog/2012/04/09/php-a-
fractal-of-bad-de...](http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-
bad-design/)

------
franklaemmer
PHP is phantastic. Ruby is rubbish. < just kidding. You can do cool scaleable
stuff in both languages (nowadays).

Choose the right hosting environment. Maybe a scalable cloud platform?
Consider a PaaS like: Heroku, DotCloud, AppFog …

Shameless Plug: We are developing a PHP Platform ourselves:
<http://fortrabbit.com>

------
troels
None of the points you list have any relevance for making a choice. The two
languages are so similar, that it's (imho) entirely a matter of taste which
you prefer. If you have experience in either, probably go with that. If you
don't, see what your immediate support network prefers and go with that.
You're going to need their help when you get stuck.

------
timurtamerlan
I'd suggest you consider: 1\. Labor costs. Ruby developers may be twice as
expensive as PHP ones given the same level of tasks to be solved. 2\. Labor
availability. Whether it is easier for you to find PHP programmer or Ruby
programmer when you need one?

For me in Russia answer is definitely PHP, Ruby guys are rare and expensive
here :)

------
manuscreationis
Both

Neither

Do some research and find which one works best for the product you envision
building. If they both sound like a good fit, go with whatever one you can get
help with more easily, since you mention (in the comments) you're not a
programmer.

------
neel980
Am considering Ruby at the moment. But reminded of Twitter dropping Ruby due
to certain reliability issues. Hence having second thoughts. Or am I a little
ahead of myself here worrying about something that may never affect me?

~~~
vaidik
Hmm... Do you have plans of building something at Twitter scale? If you can
foresee that, then I guess you are right when you are considering Twitter's
case of dropping Ruby.

I am no Ruby-ist but I am sure Ruby is not that bad that you will have
troubles scaling. You just have to understand how to scale and you can use
either PHP or Ruby to apply the general concepts of scalability.

~~~
Argorak
Twitter didn't "drop Ruby". They just replaces (huge) parts of their stack by
other things that might or might not written in their old default language. As
will anyone that has to work at their scale. Their frontend was still Rails
for a long time (or still is, in parts?).

Example: see what they have to offer as open source. Still quite a bit of
Ruby: <http://twitter.github.com>

------
mmahemoff
This question needs a lot more context for any answer to be useful. Who's the
developer? What's the long-term plan? What's your own background? What does
the app do?

I hate to say "It depends", but sometimes it really does.

------
phoenixwizard
I would suggest Rails if you want ruby and definitely consider Laravel as a
php framework. I am quiet loving the framework, though am bootstrapping one of
my web apps on laravel and majority of my works are in Rails ...

------
borplk
These threads really will get you nowhere. There are countless discussions
like this all over the internet and in every one of them you'll find people
stating one or the other choice. You need to try it for yourself.

------
neel980
Thanks for the responses folks.

------
gitarr
Python. (YouTube, Reddit, ...)

Second choice Ruby without a second of doubt.

