var app = express.createServer();
app.get('/', function(req, res){
res.send('Hello World');
});
app.listen(3000);
That is, admittedly, longer than PHP but it's arguably easier to understand what's going on, much easier to modify and extend, and just as easy to copy and paste off the web.For Sinatra:
require 'sinatra'
get '/' do
"Hello World!"
end
Again, does PHP have any real advantage here? Python solutions will be similar. And in all those cases we can turn this into a full app with only a few more lines.Consider this example of a completely function blog: https://github.com/mitsuhiko/flask/tree/master/examples/flas...
There's 76 sloc of code in the blog app, plus tests, templates, database access, and more. And it's clean, clear, and simple. What does the PHP equivalent look like?
Of course, PHP is still shorter for hello world...mostly because it's running as a CGI app. This is a terrible, archaic idea for all the reasons that get discussed when people talk about Why PHP Is Terrible, but nothing is stopping you from configuring other languages that way. So here's a real apples-to-apples comparison:
Python:
print "Hello world!"
Too long? Try Ruby: puts "Hello world!"
19 characters including white space? Beat that! :)