Ask HN: PHP vs. Node.js vs. Go for a new startup?
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 ] threadWhen 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 can easily take 1m/day.
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.
http://www.techempower.com/benchmarks/#section=data-r7
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.
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.
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!
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.
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.
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.
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.
I find gorp with Revel (http://robfig.github.io/revel/) makes for a powerful and performant backend. I just wish Revel had better testing integration.
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
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.
http://www.codinghorror.com/blog/2009/03/sharpening-the-saw....
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.