Ask HN: Why Would I Write Web Apps In Anything Besides PHP?

I recently considered moving all my web apps from PHP to something else, mainly because I was bored and it was an excuse to get proficient with another language. However, the alternatives were not written with web scripting in mind. Python and Ruby were both designed as stand-alone programming languages with web wrappers added later. Beyond those two, I couldn't even think of a third language that was even worth considering. So I stayed with PHP because PHP was designed specifically for web scripting.

My question is: What benefits are there to writing web apps in any of those other languages that weren't designed specifically for web apps?

  • Eh, I don't really get your question here.

    Why would you rewrite all your apps with something other than PHP? You wouldn't, of course.

    Why would you consider a language that wasn't "designed specifically for web scripting"? Because that's an irrelevant criteria for choosing a platform. It makes no difference if something was(n't) designed for a single purpose, only that it is effective for the purpose you require.

    A third language worth considering -- how about JavaScript w/ Node.JS?

    Benefits to writing web apps in a language other than PHP? Well, you get the benefits of that language - whatever those might be. Benefits might include anything from technical superiority (and what 'technical superiority' means is based a lot more on the application than the fact it's web-based) to it being easy to find developers who know a platform in your city when you need to hire, availability of documentation, or even the general progressiveness of the whole ecosystem (is new stuff happening? is there community interest?).

    I think that discounting everything but PHP just because they aren't pigeonholed into web apps (of course, PHP can be used for more than just the web, but let's gloss over this fact) is pretty... close minded.

    A counter question: if you like PHP and are productive/happy/etc using it, why would you go out looking for new languages to replace it? You will only discover that they aren't PHP.

  • Cleaner code, powerful libraries, frameworks with vibrant communities (django/rails), and so you have friends to sit with at lunch. Really, it's a personal preference. If you have existing sites in PHP and you're really comfortable with it, why waste time porting things over? Go create something new in the most efficient way you can!

  • One major advantage to using Python especially is the availability of many libraries and apis. I think that the main reason for the growth of PHP (at least in the beginning) was the good interface with SQL (LAMP). Now that there are good alternatives (MongoDB, Riak, Redis, etc.), PHP's SQL support isn't a must. I think that the simple nature of the ruby language is a good thing. The code is easy to understand and the libraries aren't a mess cough cough.

    All in all, it comes down to personal preference.

    Personal Plug for Python: I have used python for some major statistical analysis (over the web) and Django interfaces well with sciPy and numPy. Python also has much better native access so R works well with it.

    AFAIK: Node.js was written for webapps. Also javascript is interoperable in most major browsers so you use the same language on client and server side.

    Personal Plug for Node.js: I love node. It is really simple to use especially with coffeescript and express. The tools available are constantly growing and there are so many modules available. Also, node.js moves a lot faster with major releases and updates as well as the availability of any existing javascript library available.

  • There is no benefit.

    PHP is great for doing rapid prototyping for web applications, and will suffice even for the final version in most cases.

    Most here are concerned with producing something of value, so if it's easier to do in PHP, then do it! Your final product on the web will speak for itself, no matter what framework it was written in.

  • Good luck applying your PHP knowledge outside of the tiny sliver of software engineering domain that is web apps. Learning Python and arguably Ruby (now with JRuby out there) is a wiser long-term investment if you want to be able to use your skills towards solving other types of problems.

  • IMO, a language derives the most of its real-world utility from (good, updated, relevant) supporting libraries. This is a great reason to learn python AND ruby.

    (Personally, I have a project where I'm debating the two. I've decided Ruby for now but may move to Python. I hope I never do PHP again.)

  • I'd say a good reason to try writing a web app using other tools is because a) you don't know why because you have no experience and b) lots of other people are doing it.

    Isn't that enough reason? While languages like Ruby and Python were not designed 'with the web in mind', PHP wasn't designed _at all_. You won't understand this until you've had some reasonable experience with real programming languages. Enjoy!

  • I know PHP pretty well and enjoy it. I just started learning Ruby on Rails and it is VERY fun. It is simple and with rails it is quick to launch apps. I don't think i'm experienced enough yet to see the downside with RoR...but for now I'm happy with what I see.

  • I've been building web applications for almost 10 years. I can build a Rails app about 5 times faster than a similar PHP app. I know there might be some PHP frameworks out there, but even with those in-mind, I would say Rails is probably 2 times as easy to develop and deploy because of things like Heroku.

    I know these are rough numbers from my perspective, but the efficiency and effectiveness of the framework really adds up.

  • To really answer your question you pretty much have to write your own Django/Rails app. Why don't you give it a try in a new project?

  • Because modern web apps are more than just a thin layer over the database.

    Here's my recent experience:

    1. An image server cobbled together using RabbitMQ, OpenCV, and Imagemagick. ElasticSearch is used for title/description searches.

    Sure this could technically be done in PHP, but 80% of the code has nothign to do with the web in particular so its better to use a general purpose language that was designed from the start to be that rather than PHP which was a domain specific language that evolved to where it is today.

    2. Hedge fund manager using Quantlib and NumPy. There's no equivilent in PHP. There's no easy way to interface with C-code. Cython and Cytpes make it easy. Doing so in PHP means hand writing a C-extension. I've done that before and let me tell you the Zend Engine not a pretty thing to work with.

    3. Any project that has a rich client side interface built in javascript will get gains from using Python over PHP. At that point your server is really just a message backend controlled via REST or JSON-RPC.

  • Productivity with PHP peaks near the time when you start your project (when it is great and beats out a lot of other technologies) and without a lot of work, goes downhill from there. Put simply, it is not designed to scale well in terms of code size and complexity. It is very concrete and doesn't encourage any use of abstraction by default. For some types of apps & sites this is no problem and the simple and flat design of PHP will actually be of benefit.

    There are frameworks that alleviate some of these issues (Cake, etc.) but they are really compensating for the language deficiencies that cause the problem rather than solving them. Other languages give you a little more overhead, are a little more generic, but in return they give you far stronger tools to deal with the complexity burden that (inevitably) hits at some point for many projects.

  • If you're going to write a well-designed PHP web application (and that's subjective, but I believe most people would have a similar idea of well-designed,) you're going to end up writing or using a "web wrapper" (or in other words, framework) anyways.

  • For me the issue isn't whether another language or framework is better for the job at hand than the tools you've spent time building up an expertise in. The thing that matters is that you don't develop a closed mind which prevents you from looking at ANYTHING else out there.

    Evolving your sklls and constant learning is the hallmark of a good developer, not whether they learn Rails or Python now. Curiosity and a willingness to admit that something new and better might be out there matter more than pseudo religious battles between ardent users of one or the other piece of tech. That's going to keep you in software development for the next 25-50 years.

  • For me, I started using Python because I could write the front end (web-facing) and back end code in the same language.

    Meaning I can write back end services like mail server and share models and other code across both.

    You could argue that you can write back end services in PHP, however, it was no designed with that intention and in my honest opinion it does not translate very well because the infrastructure in terms of open source libraries just don't exist as PHP is primarily a web language.

  • It is interesting to think of a language specifically designed for web apps as different from a general-purpose language. This would of never occurred to me unless I only knew PHP.

    I suspect if you tried to make a good web app language it would look like ruby or python, and really good web app language -- one very scalable -- look like haskell or scheme.

    But to answer your question directly there are too many benefits to mention and they are language specific. I think transitioning to ruby and rails environment would be rewarding. I myself like Scala much better than ruby even though it's static typing is painful at times, and choose the rails-like framework Play! (http://scala.playframework.org). The front page shows you examples of the language expressiveness.

  • A nice side-effect is that you'll come out of it knowing another language that is useful for more than just web stuff.

  • undefined

  • You can't really say PHP was designed for web scripting... for the most part, PHP wasn't designed at all.

    By the time you get to more advanced apps, the advantages of PHP disappear and all you're left with is a somewhat messy language.

  • There's really little reason to not use PHP, except in special usecases, like real-time services, or massively multiplayer, for example.

    Facebook is, even today, basically still a monolithic PHP script.

  • There is nothing related to web development that you can do in other languages that you can't do with PHP. That should suffice for your first question: Do not rewrite any of your apps. If you want to learn another language, there are tons of stuff you can do with Python, from numerical programming to openGL.

    There is a widespread opinion that PHP is not as sexy as other scripting languages, and that it is too domain specific. That may be true. There is another opinion that with PHP you can only write spaghetti code. That one is false, it's up to you to organize your code. I 've been maintaining PHP scripts for years and didn't have that problem. Plus achieving good performance is easier with PHP, and that comes handy with high traffic sites.

    I like python for non-web projects. If only Android or iOS was written in python.

  • "I recently considered moving all my web apps from PHP to something else, mainly because I was bored and it was an excuse to get proficient with another language."

    It's just about the worst excuse going if your apps are of any value whatsoever

  • Use what you want to use, want to learn Python? Or code that C++ CGI Web App? Go for it...

    Wondering what the best language is for you to use? Probably the one you know best. When you out-scale PHP - you'll be on the beach drinking tropical drinks, and likely not care.

  • Because you're not a blathering imbecile with an IQ under 60.