A Conversation for 'Hello World!' - Programming Tradition
The javascript example
TRiG (Ireland) A dog, so bade in office Started conversation Apr 14, 2012
Could be shorter. As a standalone JS file, rather than embedded within HTML, it could be just
document.write("Hello world")
Or, more usefully,
document.getElementById('container').innerHTML = 'Hello world!'
That's still in a web context, javascript interacting with HTML. JS can also be used as as a server-side script (Node.js) or as a general-purpose programming language, but I've never tried that. I don't know what the JS equivalent of "echo" would be.
With shorttags enabled, the PHP example could be reduced to <?='Hello world'?>, but since content outside PHP tags isn't parsed and is simply output as is, the actual simplest PHP example would not use any PHP at all. But perhaps that would be cheating.
TRiG.
Key: Complain about this post
The javascript example
More Conversations for 'Hello World!' - Programming Tradition
Write an Entry
"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."