GNU ease.js
gnu.org
gnu.org
The comments on this post are super negative, and I think that is because people really don't like the GNU project. We don't even know if the author of this library is the person who submitted it to HN.
I would be a nervous wreck if I woke up one day to find my personal work submitted to this site, and have it trashed as thoroughly as it has been here. You don't have to like it or use it for your next project, but for the love of God, don't call it a shitty ugly abomination (to combine some of the comments here...)
I love the GNU project, but this thing is ugly.
> ... it's a useless and ugly library, most of these things can be done with vanilla javascript. ... but this thing is ugly.
Your criticism is that "most of these things can be done with vanilla JavaScript." Great. What is the point of the rest of your message? Keep in mind what you have written here is fairly tame compared to things that others have said in this topic.
When people complain about how hostile "Show HN" topics are, keep this topic and its replies in mind. Can't we be nice?
EDIT: This work was written by one developer, in what I am guessing is his free time. This would be different if it was a large project backed by a group of people/company. We might as well have selected a project at random from GitHub. I hope all of your work is up to snuff, lest someone submit it and beat it into a pulp on the front page of (probably) the most popular/influential tech aggregator in the world.
that is like, your opinion, man
I think your comments suck though.
Wow, quite the negative response here. That said, this is something I was wholly expecting from the JavaScript community, so I am not swayed; I'm merely providing something that I found to be useful in the hope that it is useful to others. So thank you to those who recognized that.
I feel that many of the negative statements here could have been addressed if the posters had taken the time to understand why the project exists:
http://www.gnu.org/software/easejs/manual/About.html
The framework exists for those who wish to have the benefits of Classical OOP using JavaScript without the need for a compiler; it provides a standalone library for something many frameworks currently do, but do so incompletely: their own class systems. If there is a feature of ease.js that you do not like, you are not forced to use it; it simply generates prototypes. Language and paradigm flamewars will always exist, but let's be respectful of those who want to "program into" their language (as Steve McConnell put it).Note that GNU ease.js was created when Harmony was just barely getting off the ground, and it is still not released. Even after it is released, there will still be users who do not have the newest features. Part of the reason for GNU ease.js is to address the issue of consistency across all browsers. It works in IE 5.5 (although that wasn't intentional)---you don't have to worry about whether or not ES6 is supported. ES6 also doesn't address some concepts ease.js does.
http://www.gnu.org/software/easejs/manual/Implementation-Details.html
Let me be clear---I have a strong understanding of the prototypal model, and it does have its uses and elegance. For those who want some of the features of GNU ease.js without the framework itself, I provided both the above link and this paper which demonstrates how OOP is generally done in ECMAScript (and its problems): http://mikegerwitz.com/docs/coope.html
GNU ease.js encapsulates those hacks. There's value in that alone.To answer some of the Harmony-related questions: here is a reply to a question I received from another GNU hacker:
http://www.gnu.org/software/easejs/misc/easejs-harmony-reply.txt
With regards to the licensing: RMS asked if I'd be willing relicense under the GPLv3+, because of their campaign against proprietary JavaScript. Let me be clear on this matter as well: I am an avid free software activist. I hope that people will find GNU ease.js to be useful, but only if they are writing free software. http://www.gnu.org/software/easejs/whyfreejs.html
Thank you, conductor, for posting the project---I appreciate input from the community regardless of its tone.Admittedly, JavaScript has suffered from a lack of strong idiomatic principles. (But that has improved in recent years with things projects like CommonJS, RequireJS and Browserify)
While I admire the effort that went into a project like this, I can't help but wonder whether it will delay a developer's understanding of JavaScript rather than ease the transition into it.
The next version of JavaScript will have you know class. .. So I guess the javascript designers are going against the nature of JavaScript by bolting on a class-based structure going against the language features the designers already gave JavaScript for things like inheritance.
However, if this was a shim for some future language feature it would probably be a good idea. It doesn't appear to be and if it was widely used, would only add to the confusion once language support for classes did emerge.
Furthermore it appears to put variable name declarations within strings, which might further confuse editors/IDEs that already have trouble with the dynamic nature of the language.
I really don't mean to belittle as I'm sure a lot of effort was put into this project. It may serve a purpose somewhere and someone may find it beneficial. I just feel that it goes against the language constructs a little bit too much.
But you know, you guys WANTED "classes" so there you go. ;)
People already have a hard enough time dealing with a pseudo functional async language. Trying to lay formal OOP concepts on top of JS is an abstraction for which I cannot find an analogy.
I think the project is incredibly cool though, as I've always found "meta" programming like this to be fascinating, but this causes a somewhat serious problem:
When someone needs to go into a formal JS framework, take angular for example, they really need to unlearn all of the other JS tendencies that were absorbed over time. Switching from jQuery thinking to Angular thinking is hard enough, but going from ease.js to Angular is a horrifying thought.
In every context that you would find JS (Web dev and game dev in Unity come to mind), it will look and perform absolutely NOTHING like this.
Animal = function () {};
Dog = function () {};
Dog.prototype = Object.create(Animal);
But this? This is an abomination.Ok, looking through...holy hell it's ugly. I've never really felt the need to use public/protected in JS, and it looks inspired by PHP.
Bolting this stuff on on top of JS, in such a broken feeling way...I just can't see why anyone would use this at all.
Serious people never set out to produce GPLv3 works?
I totally grant the "this doesn't look like it's actually useful", though, although I've not been neck deep in JS for ages.
Deleted comment
You're getting the order wrong here.
- It was inspired by Java.
- PHP OOP was also inspired by Java.
It's hard to argue that Java's OOP model is bad. It encourages clear code structure and works especially well for large project (for tiny projects you don't need OOP at all, anyway). This is why C#, PHP, this library and many more are based on Java.
Oh, BTW, let's keep digging:
- Java's OOP was inspired by Objective C.
- Objective C was inspired by SmallTalk.
It's always Lisp or SmallTalk, isn't that fun?
Yet another JS framework.
However, the original intent is based on compelling rationale from C#. I cannot find the original article where the article explains the rationale, but aside from optimization benefits and self-documenting code, he makes the point that virtual methods are essentially callbacks/hooks into existing code; you therefore need to put careful thought into how to handle those virtual methods properly and expose the proper APIs.
Pull your understanding of what javascript is out of 2005.
How is GPLv3 restrictive for a "class system" whatever a "class system" is.
I would love it if the programming languages I use were GPLv3. As a developer that would give me a lot more freedom.
Also, I believe that by allowing distributors to use your code without forcing them to release their code you don't restrict potential users' freedoms - if a company wanted to use your library in their project and your license is not compatible with it they will just find another project or write a similar one themselves. The result for the user is the same: they will not get access to the code.
As a developer, though, I'd rather have more code I can read and learn from and tweak and borrow than yet another proprietary product that I'll probably ignore - even if you're giving me 10x more of the latter.
Why not use TypeScript? It offers similar features, without the extra overhead and ugly syntax.
Seriously though, I don't care much for typescript either... I'm okay with CoffeeScript as it brings as much to the table without having to type twice as much to get it.
This just seems like a sick joke foisted on people who are too lazy to learn a slightly different paradigm.
Which is why the next versions of JS (ES6 and ES7) will have:
1) Modules (namespaces)
2) Classes
3) Member visibility
Whoops. Ignore the cognitive dissonance and continue with the flame!
Now. While the library linked here isn't the prettiest thing I've seen, I immediately get it. And I can immediately start coding in it and get the expected behavior.
This, in itself, is a huge feature compared to the awkward incantations one has to do in barebones JS to do OOP (of any kind). Even the fact it's string based doesn't make it inferior to some of the other unreadable stuff I've seen by people doing JavaScript "properly" (or so they think).
So, I say kudos about that. Here we have an implementation solving a practical problem in a practical way. No plot twists and surprises.
I prefer TypeScript, but this one doesn't require a parser, so it has its benefits.
So I'm happy about that. As long as Java developers are unhappy with something, I likes it.
The awkward incantations you speak of are indeed awkward, I will admit.
I mean, how fucking confusing is
Object.create({ your prototype here });
am I right? This is much better: MySpecialFramework.extend({ my prototy.. .*ahem* class here! })