Live data from Hacker News

The Two Pillars of JavaScript

medium.com

1–10 of 16 posts

Re: The Two Pillars of JavaScript

#2
> “The `class` keyword will probably be the most harmful feature in JavaScript."

I'm glad I'm not the only one.

One of the reasons Javascript became so popular is that it took many of the properties that Lispers have been extolling for decades (minimal syntax, light-weight, meta-programmable, functional, composable), but wrapped them in a familiar-enough looking package that even beginners can Get Stuff Done. (Which is where Lisps have historically failed.)

I'm hoping the future of Js will continue in this direction, but looking at ES6 and Angular, it looks like too many people are trying to turn Javascript into Java.

The heart of Javascript is simplicity and power. Arrow functions and modules are a great addition. Maybe with enough support from the community, instead of more syntactic sugar and complexity, ES7 will adopt macros (http://sweetjs.org/) and a type system (e.g tcomb ( https://github.com/gcanti/tcomb )).

Re: The Two Pillars of JavaScript

#3

> “The `class` keyword will probably be the most harmful feature in JavaScript." I'm glad I'm not the only one. One of the reasons Javascript became so popular is that it took many of the properties that Lispers have been extolling for decades (minimal syntax, light-weight, meta-programmable, functional, composable), but wrapped them in a familiar-enough looking package that even beginners can Get Stuff Done. (Which…

Off topic: tcomb looks insanely cool. Thanks for pointing it out. Though HN is including one of the parens in your link, which is messing it up. Here's a pristine version for the lazy: https://github.com/gcanti/tcomb

Re: The Two Pillars of JavaScript

#5

> “The `class` keyword will probably be the most harmful feature in JavaScript." I'm glad I'm not the only one. One of the reasons Javascript became so popular is that it took many of the properties that Lispers have been extolling for decades (minimal syntax, light-weight, meta-programmable, functional, composable), but wrapped them in a familiar-enough looking package that even beginners can Get Stuff Done. (Which…

> "I'm glad I'm not the only one"

You're not the only one, but we're being steamrolled by the Java crowd and I'm afraid that we're in a losing position. Angular is the first of many to come.

Re: The Two Pillars of JavaScript

#6
The benefits of prototype inheritance have always seemed rather dubious to me. The programmer wants to express that there are a bunch of objects with the same structure and behavior; the compiler needs to know which objects have the same structure and behavior. Forcing both sides to pretend that each object is a unique and special snowflake when that is both counterfactual and inconvenient for all involved seems pretty silly. That said, C++/Java-style class-based o.o. is no panacea either and having both things in a single language is just crazy.

Re: The Two Pillars of JavaScript

#7

The benefits of prototype inheritance have always seemed rather dubious to me. The programmer wants to express that there are a bunch of objects with the same structure and behavior; the compiler needs to know which objects have the same structure and behavior. Forcing both sides to pretend that each object is a unique and special snowflake when that is both counterfactual and inconvenient for all involved seems pret…

> That said, C++/Java-style class-based o.o. is no panacea either and having both things in a single language is just crazy.

Actually, there is just prototypal inheritance. The whole `new` operator thing (as well as ECMAScript 6 classes) is just syntactic sugar over prototypal inheritance.

But yeah, it's crazy that this had to be put in just to attract users (in the 90s, to make it look more like Java; along with method names etc).

Re: The Two Pillars of JavaScript

#8
Interesting.

I've been working with JavaScript for the past few months in a class-heirarchy environment (Educational games using a proprietary engine), and it seems to be working pretty okay.

I guess it might be because the hierarchy isn't very complex as far as I'm concerned. A lot of the ugliness in the engine is abstracted away from me as a game developer.

Re: The Two Pillars of JavaScript

#9
Agree 100% with this article. I've done Perl, Java, and NodeJS applications. The absolute worst code I've ever seen was Java, which with OO and typing adherents say leads to maintainable code. Trouble is, most Java engineers are no better than Visual Basic programmers. Functional Perl and JavaScript are beautiful things. And by staying away from classes, you get to the more fundamental - data structures and transformations.

Re: The Two Pillars of JavaScript

#10

Interesting. I've been working with JavaScript for the past few months in a class-heirarchy environment (Educational games using a proprietary engine), and it seems to be working pretty okay. I guess it might be because the hierarchy isn't very complex as far as I'm concerned. A lot of the ugliness in the engine is abstracted away from me as a game developer.

> it seems to be working pretty okay.

These things have a tendency to balloon out of control over time. I've seen class hierarchies start out very benign. Convenient and well-designed, even.

But as the codebase grows and new objects need to be modeled, it inevitably gets stretched beyond the limits of its original design, and that's where things start to crumble.

Also, the more layers of inheritance there are, the more brittle the code becomes due to tight coupling between child and parent classes. Super calls start to turn into a tangled nightmare.

Here's a different perspective on the same topic: http://berniesumption.com/software/inheritance-is-evil-and-m...

Post reply on HN