I have witnessed innumerable chats where the hello world experience of Java has been teased.
public class HelloWorld { public static void main(String[] args) { System.out.println(“Hello, World”); }
}
You can take a part basically every word and start explaining the concepts to the newbie:
– public: the notion of package/public/private/default visibility
– class: what is this OO thing?
– static: instance vs. class methods
– void: return types and nothingness
– main: entry
– String[]: types and arrays of type (v.s. Lists and other Collections)
– args: arguments to methods
– System: what things hang off that… and oh yeah java.lang.*
– out: STDOUT / streams
– println: printy printy
There is a rats nest off of most of those items.
In the land of Perl/Python/Ruby/… we scoff at this.
print “Hello, World”;
The same can be said in JavaScript land, but our boilerplate has changed over the years and now most modules end up with trappings (that differ between libraries):
// Twitter Bootstrap
(function(){ // …
)();
// underscore.js
(function() { // …
}).call(this);
// craft.js
;(function(window, document){ // …
})(this, this.document);
// jQuery
(function(window, undefined) { // …
})(window);
// can.js
(function (window, $, undefined) { // …
})(this, jQuery);
We have gotten “smart” to stick to the good parts, but it is a shame that there is quite a learning curve around the language (this, arguments, and all that jazz).
In an ideal world the power of a platform will show itself like peals of an onion. You keep finding more.
JavaScript isn’t all bad in this way at all, but we could use some help.
Leave a Reply