Ask HN: PHP vs. Node.js vs. Go for a new startup?

29 points by x0054 ↗ HN
I am coming back to the IT industry after about 6 years of being involved in something completely unrelated. My partner and I are starting a startup that’s going to make a online blogging application for a niche market. If we are successful, the application would need to be able to scale to handle a lot of users (100k visitor per day if we are successful, nothing like FB levels or something). Because it’s going to be a blogging platform with a business model similar to squarespace.com, the load will be distributed over many different domains, making it easier to scale.

Both my partner and I have good knowledge of PHP. However, due to the complexity of the project, we will have to find additional developers anyway. From what I read online Node.js and Go are the in thing right now, and scale much better than PHP. My question is, should we stick with the “Devil we know,” PHP, or dive into learning and developing in Node.js or Go. Should we consider another programing language / platform?

What are your thoughts. This are honest questions, we are just looking for some feedback. Thank you for your help.

74 comments

[ 0.26 ms ] story [ 116 ms ] thread
Pick what you know the best. You will waste time in learning something new instead of working on your product.

When time comes, you can always optimize it(writing performance critical parts in c), or pay guys who are better than you to "translate" your app to another language.

God knows i'm not following this advice, but please do not fall into a "premature optimization" trap.

PHP will take your 100k/day and work wonderfully.

PHP can easily take 1m/day.

PHP is rarely going to be a bottleneck, especially with opcode caching. Content heavy stuff beats up a database, so caching there, then stick Varnish in front of apache.
(comment deleted)
Yes, use what you know the best. Might want to consider using a framework like Laravel 4 or Symfony 2 to boost your productivity.
If it's performance you care about, here's a ridiculously exhaustive set of benchmarks for every web framework you've heard of, and many more you haven't.

http://www.techempower.com/benchmarks/#section=data-r7&hw=ec...

I've got no love for PHP, but if you must, use a recent version and a decent framework.

If you are starting a business and plan to be the initial developers, use what you know (PHP) because you probably won't have time to learn new stuff and build your business. I'd base the decision on who is doing the coding and what skills they have. Try to stick to standard frameworks and programming practices/decent docs, task/project management, and source control, making it easier to transfer responsibility and project historical artifacts to other developers or grow the team as you grow your business.
Stick with what you know so you can get your start-up off the ground quickly and cheap. Once you hit PHPs limits, you can still gradually migrate over to $whatever_language_is_hipster_language. Regarding node.js and Go explicitly, I'd give those two at least one year of "maturing time" until you use it for mission-critical stuff.
If you are hiring "additional" developers then you need to go with something you know, unless you want to learn something new and get started on it first. Otherwise you are just hiring developers and not participating...
100k visitors per day is 4k visitors/hour is 1.2 visitors/s. Suppose each visitor clicks on 10 pages (that is very high) and you get a total of 12 requests/s. Now even assuming much higher load during peak hours you're still looking at max 100 requests/s.

My point is that that kind of traffic is truly minuscule. As long as you set it up correctly and use a decent cache it will handle the load fine. Any platform you choose and hosting for ~$200/month will be enough.

100k/day is far from 4k/hour
You need to explain traffic spikes and lulls, because right now your argument looks ridiculous.
You're assuming that all the visits are evenly distributed over the day. I doubt that assumption will hold...
No, I explicitly assumed peak loads about 10 times the average, 100 reqs/s instead of 12 reqs/s..
If you don't care about performance issues, go for PHP, with a nice framework, so you can get ready quickly. Else, go for node.js (I don't know Go, but it seems it has a pretty good performance too).
Summary: Php is a stable and reliable.

Nodejs: Is new and young.

Go: Same history as the one above.

Scalabilty is not something that you should worry about at this stage, if your app reach the scale that you expect it to get then refactor and do something about it. Scalability has nothing to do with the language, so use that "Devil you know", stop wasting time and move on.

Go with PHP and buy Steve Corona's book - https://www.scalingphpbook.com/.

Also, be sure to get up on the improvements that have been made with PHP 5, 5.3-5.4. It's come a long way in 6 years.

Good luck!

If I was starting from scratch today I'd use Go. Go makes writing fast, scalable and reliable servers as easy as it is possible to make it. At least that is my experience.

I started out writing CGIs and servers in C many years ago and have experimented with Perl, Python, PHP, Ruby, NodeJS and Go since then.

Go has a syntax that is instantly familiar and simple to master. Go's concurrency paradigms are simple to understand and easy to use. Go's compiler is fast and clear. If a Go program compiles it nearly always runs. Go's built-in library has most things you need to write HTTP-based servers.

If you use Go naively you will almost certainly be using Go correctly: your server will be fast and efficient. This is not the case with NodeJS. Writing fast, efficient NodeJS code is hard. Maintaining fast, efficient NodeJS code is even harder.

On the down side - while Go don't suffer from 'callback hell' but it does have a tendency towards 'cast soup' - this makes working with JSON a little trickier than it should.

Aside from the main programming language I would also look at:

* JSON API-first driven development

* Redis

* NodeJS's plethora of web-centric code management tools & compilers: SCSS, RequireJS, Grunt etc

* Single-page javascript App technology: Ember, Angular etc

* Docker.io

* SVG

* Camlistore

These (with Go) are the main technologies I'd use to build a large web infrastructure.

Node doesn't suffer from callback hell if you're an adequate javascript developer. Named functions?

Or how about a class which you pass methods to your callback functions and bind them to the instance properly.

You never need to nest a callback if you know how to work with prototypical inheritance.

So, clearly, I'm not 'an adequate javascript developer'.

Luckily an inadequate javascript developer can write naive code in Go that reads from disk or writes to a socket without worrying about needing "a class which you pass methods to your callback functions and bind them to the instance properly" or "prototypical inheritance".

You can just call a function and use the result.

you still need to write callbacks,wether they are named or not, that's the problem. Go deals with concurrency a much nicer way. 10 asyncs operations in a row are still 10 functions you'll need to write in javascript.
I've done a couple projects with Go now and really like it, but it does have a big weakness as far as backend -- models and and the tools to make a good model abstraction layer. This may be a personal opinion problem, so I'd like to hear what other people think of it. I personally find the tools for interacting with datastores particularly weak. Their sql package for example was way too simple for me.

I've heard good things about the mongodb package and interface, but I haven't had a reason to use mongo.

So really if you use Go for your server side, you'll get a lot of nice benefits, listed by sambeau, but just be aware, you might have to tussle to find the right fit of backend tools, and you will likely have to make your own Model abstraction. This might not be a downside though, as I know a lot of engineers will build (or rebuild) the model layer no matter the framework.

Great question. Other folks have made good points about the value of sticking with what you know but on the other hand there are advantages of other platforms as well. Could the kind of blogging application you've got in mind be built around Ghost? [1] If so then node could make a lot of sense.

I weighed a similar choice this summer and my first thought was Go but a friend suggested I look at node.js, Closure or Scala as alternatives. I wound up choosing node.js for an initial version because of the vibrant ecosystem with some great building blocks, mostly MIT-licensed.

jon

[1] https://github.com/TryGhost/Ghost

I'm going to go against the grain here and say ditch php and build it on node. There is no better way to update your skillset than by building your own product with a tool you've never used. If you're building a web app, you'll need to learn JavaScript regardless.

Worry about scaling problems when you hit them, not when you're picking a language. For comparison, I serve 100k users per day using rails/Postgres on a single $80/month linode server.

Node. Node node node node node.

Why node?

Node is a great framework for building web applications. It's got good support for scalable servers using Amazon Opsworks, nodejitsu, heroku, etc.

Javascript developers are easy to find, and even with no Node experience, any developer worth their salt can get up to speed pretty quickly.

Front-end and back-end can be written in the same language.

You can build rapidly and get to an MVP very quickly, at which point you can either switch to an enterprise language like Java (ugh) or Go, or whatever else to leverage performance, or scale your existing Node codebase using modules such as cluster, or by developing simple strategies on multiple servers.

I have built every kind of applicaton you can think of using Node, from desktop apps using node-webkit, to simple TCP video streaming servers using the built in networking and piping data directly into ffmpeg.

Testing and test driven development is natural in node, and you can write your server tests and browser tests in the same framework using mocha and phantomjs. I've even been building integration tests and automated UI tests using node, mocha and pahntomjs.

Our latest concurrent benchmarks for a load balanced group of t1 micros on a single mongodb instance get to at least 30k concurrent requests a second before you get a few timeouts, but that's just because i'm not too familiar with ops and haven't done any proper optimisation yet.

There is no right answer to this quest, but the above is my personal and professional opinion.

Summary:

A Javascript developer that have been using it for client-side purpose will not learn how to use nodejs from the day to night even if he is a expert on it, for something nodejs is for serverside programing.

"Front-end and back-end can be written in the same language.". I would prefer to right my backend in something else instead Javscript , even PHP would be a more pleasant choice, and if that would be the case i would rather use Clojure and Clojurescript togather to right everything in the same language.

> Mediocre Javascript developers are easy to find

FTFY.

In all seriousness, though, I'm the lead developer on a web applications team at a medium-sized client services company and my experience has been that competent JavaScript developers are among the hardest kind of developer to find right now.

I'd strongly recommend using what you know best. If you're good at PHP, use that.

If, however, it's been a long 6 years and you're going to be pretty rusty at whatever you use, I'd recommend giving Node.js a shot. We've had really good luck with it and it has a fantastic community behind it.

Building a startup is hard enough. Adding another rather large dimension of an unknown language/technology is increasing risks significantly. Untested/unfamiliar technology is one of the top 5 risks which cause software budget and time overruns (pick any book by Steve McConnel on software project management, he does a good summary of these risks).

If you think you have the time and resources, and more importantly, if an interesting technology is part of the reason why you wanted to do a startup; then take the numerous technical advice given by others here.

In brief: - PHP => cheap developers - Node.js => share code between client / server / meteor.js - Go => multithread & performance
What's wrong with Python? I've messed with all 3 you listed but at the end of the day I always end up going with Python.
Use whatever is best for you... PHP can scale... I've built applications that handled 4x as much visitors per day as you mentioned without any real problems... Crappy code is in every language, it's all on you... You can build amazing things in PHP... Just like you can in Node.js and Ruby, and Python...

If you want to build it quickly, do it in what you know best... If you want to learn a new language as you go, build it in Node.js or Go.

Unless you know you can't use what you know, stick with what you know. Business concerns trump technical concerns for early-stage startups, and the differences between the three are minute as far as business is concerned. However, having to struggle with learning a new stack can impact your business.

Even if the differences between node.js and Go mattered, you won't get anything valuable from asking HN "should I use node.js or Go", since the two stacks are broadly in a similar niche and have similarly-sized communities. It'll mostly be fans of one technology bashing the other, as you can already see in this thread. It would be better to focus on specific concerns: Do you need support for shared memory on multicore? Is the ability to reuse JavaScript code on the browser and the server a concern? Is there a specific library that's essential to your business that's only available on one or the other? These questions would engender a much more interesting discussion.

node's error handling is by far its weakest point IMO, Go is a lot better in that respect, but a full javascript stack has its advantages
I remember you criticized on twitter this point of Node some time ago and the response of some leaders of Node community was like "Sorry, this isn't Erlang" and "Erlang is better but it's harder"
Yeah, pretty naive responses, but understandably most people who have been in the community for a long time don't want to admit the reality, seeing as node is what powers most of our jobs haha. Bottom line is node has a massive flaw, and it should be fixed, at least core members should have interest in fixing it.

Especially with tools like Go there's a lot of pressure to NOT use node in production when great alternatives are available. Node still has the "JavaScript edge", but if fault tolerance remains as poor as it is now that won't matter for long.

Your are right.

Once ES6 is here(when? i dont know), things are going to get better i think,

but Go way of dealing with concurrency in general is a lot better than javascript's for now.

Generators will help a tiny bit but certainly not nearly as much as something like coroutines with separate stacks. I know the node-fiber guy(s) had some issues with v8's internal stack usage so it doesn't seem like a near-future possibility to really have light-weight coros in node :(
FWIW (to give a little context to this comment):

TJ is the author of Jade, Stylus, Express, Connect, Component, Kue, Mongoose, Knox, Cluster (before the bundled cluster module), Canvas, N, Commander, etc, etc.

If anyone has a perch upon which to criticize Node, he's certainly amongst the most qualified.

This is the best answer. You can scale any language to 100k pageviews/day. Some scale easier than others, but almost anything reasonable will hit those numbers with the proper infrastructure.

New languages and frameworks have their pitfalls. Pick what you know so that you don't get tangled up in the weeds while trying to build out a product quickly.

I still don't understand why people ask this question. It's exactly like you say. The technology stack does not really matter. All that matters is how productive you are in the initial phase.

You should always be choosing something you are familiar with, because it will allow you to get where you want much quicker. And yes, later, then you do actually build a business, you can start playing around with newer technologies. But only if they are valuable for the business.

Double so because OP has been out of the loop for 6 years, which tells me that they are probably a bit rusty and not prepared to absorb a new language on short notice.
PHP.

You want to start with something you know, especially at a time when getting an MVP, making iterations, and being nimble is important. Because you both already know PHP, this is a no-brainer. Things have changed dramatically with every aspect of web development in the past 6 years, and PHP is the thing that (although its changed a lot) has probably changed the least compared to your web front-end (HTML5/CSS3), client-side JS, and responsive design (which basically didn't exist 6 years ago).

You should also consider the economics of your situation. Developers who know enough about Go and Node.js to do it professionally are going to charge you much more than those who code PHP professionally.

Ultimately, you're probably doomed to failure just by raising this question. Its been stated ad nauseam on HN before, but you need to iterate quickly and discover what works and drives traffic/sales. Don't waste time trying to learn a new programming language. If you want to devote any time to learning something new, it should be learning how to market your product better.

Depends on what you want to do. But I can tell you that this is sort of a pointless argument for a blogging platform

I've found that the really important bit when writing read-heavy web-apps is good caching. The write-path could be written in something slow-ish and it will be hit far less than the front-caches serving data.

So, if you need a web templating language + basic json callbacks, php will definitely do the trick for version 1.0 (or ruby-on-rails or whatever gets you up to 100% feature complete). I've written game backends which did ~2.5k-3k rps on a single machine with PHP (though, I did have to fix PHP APC's locks to handle those loads in the process).

But then you still need to know JS to write the frontend code.

Node.js basically lets you combine 2 skill sets into one - the frontend and backend can share the same data model code for instance. This is easy if you have complex data-structures to communicate between the two layers.

Go actually gives up that advantage, but wins out because it can do compute intensive tasks faster - and can do state-ful daemons in a much nicer way. If you were building say, an online game, where say it was poker game with low-latencies, I would go for go. Definitely.

But as it stands, the only reason to go for Node.js is that your front-end dev can double as a backend-dev. Otherwise, I'd stick with what you know & are most productive in.

We have a server that we've deployed for our customers. It's a middleware-free web platform. It won't be released officially for some time but we'd be happy to have you evaluate it.