4 ms·
I would dispute that it's easy to pick up for beginners. It's easy to START doing then things, and then intricacies you don't understand will kill you. The pr
by PhrosTT 12y ago
I would dispute that it's easy to pick up for beginners. It's easy to START doing then things, and then intricacies you don't understand will kill you. The prototype chain, function call context, closures, asynchronous code, etc.
Type class Dog extends Animal into js2coffee.org and you get this:
var Dog,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor();
child.__super__ = parent.prototype;
return child;
};
Dog = (function(_super) {
__extends(Dog, _super);
function Dog() {
return Dog.__super__.constructor.apply(this, arguments);
}
return Dog;
})(Animal);
- personjerry 12y agoYeah I remember seeing a post on HN that challenged the user on the behavior of some especially tricky javascript.
- bphogan 12y agoFirst, I'd argue that none of that would be "beginner" things. Programmers always seem to forget what it is like to not know how to program. A beginner would never use something like that. Second, when you bring class-oriented Java-style constructs to JavaScript, it looks ugly because it's not what JavaScript is about. JavaScript is different. It's got a completely different way to do OOP, which you have to learn. I'll agree that JS has weirdness. But a lot of the things we think are "wierd" are things that seem strange because we've programmed in Java or something else. Ask someone who started with JS and only learned JS. They don't find those things strange at all.
- kingdomking 12y agoWhat you're saying is true for a lot of languages. What you're missing from OP's comment is that it's easy to pick up, which is still true despite your example. Picking up a language doesn't mean much more than getting something done to an ordinary beginner and that's certainly a lot less fleshed out than both my and your standards of picking up a language.