My ECMAScript 7 wishlist
nczonline.net
nczonline.net
Dart's core libraries include first, last, isEmpty, isNotEmpty getters for Iterables, as well as a ton of functional methods like map(), where(), reduce(), expand() (flatMap). Not only do the built-in Lists implement Iterable, but so do NodeList, so you can do things like:
var e = query('#id').children.first;
Dart's annotations would serve as custom property descriptors, and mixins are like traits. Having interfaces in general is also hugely beneficial.It also sounds like he leans towards wanting closed classes with your requests for deepSeal and defensive classes. This does prevent a lot of errors. Both Dart and TypeScript give you this type of safety.
It is also proprietary in that Google is in absolute control of the development process.
I'm not sure about membership in ECMA, I think there other requirements.
I'll raise it with the team and see if we can have a place to post upcoming meetings, agendas, minutes, and decisions and draft specifications. It'd also be nice to have a way, besides the issue tracker (which like all issue trackers can seem like a black hole for issues for some people) to propose items for upcoming meetings. I find Python's PEP to be a pretty nice system.
[1]: https://groups.google.com/a/dartlang.org/forum/#!searchin/mi...
I hardly ever write code in a standardized language. Actually, I don't think I know anyone who writes code in a standardized language, because nontrivial programs in "standardized" languages almost always go outside the strict confines of whatever mediocre crap some committee adopted.
Only the vast majority of all commercial code ever written.
Your position is simply to dismiss the value of standards and state that it's fine that Dart is proprietary.
Also your statement about ECMAScript is flat out disingenuous. JavaScript implementations may move ahead between ECMAScript standards, but it is standardized, and by a real cross-industry group, not just a rubber stamp from one company.
It is hard to take seriously an assertion that the level of standardization between Dart and JavaScript is comparable.
I also didn't state that it's fine that Dart is proprietary, and I'd appreciate you not putting words in my mouth. My position is that your premise is incorrect and Dart is not proprietary.
Haskell is one of the few modern languages I know of where a language was birthed in committee. ALGOL and COBOL are some older examples.
So it will take until like 2020 to be able to use it without transpilers and hacks for all the non supporting browsers (most of them).
So I don't have any ES7 wishes. Until then who knows even if I'll still be doing web front-end work.
And to my personal preferences, I prefer "items[0]" to "items.first()", though the latter is more "english". One of the comments from the post also suggests "items.slice(-1)[0]" as a replacement of "items.last()", but that's another case...
Dense array layouts are largely an optimization that the JS runtime applies if it's able to. So you 'can' put arbitrary properties on an Array, but you risk throwing away the benefits you get from using it instead of Object.
Sadly the risk of compatibility pain is huge for almost every change you can possibly imagine. I've been participating on es-discuss for a couple years now and tiny, harmless changes end up breaking real web applications on a regular basis - causing the spec committee to have to scratch their heads and figure out a fix. Sometimes there isn't a fix, and they have to rethink.
Anyway, while many of these things would be nice additions, I think ES7 will contain more low-level features which particularly benefit libraries and compile-to-js languages, such as SIMD support and value objects. Personally, I'd love to see tail call elimination in the spec.
http://www.nczonline.net/blog/2014/04/22/creating-defensive-...
- async / promise / await
- object merging / cloning (with options / deep)
- array properties instead of methods (ruby style, array.first, array.last, array.empty, array.contains, etc...)
- lets not forget other object types that need methods, Number, Boolean, String (.equals, .equalsIgnoreCase, etc...)
Let's just say, javascript could be a lot better :P
So... what is the problem again?
(a lot of the other stuff in the article is valid though)
There's also value in having things like this standardized. If its a common idiom, its worth including in the standard to allow people to use it without having to worry about what utility libraries they're including.
Why should the first parameter be privileged? Why isn't it possible to add a new method to, say, Array which is scoped to your lexical context?
Even classic procedural programming didn't have this problem (as long as you don't need access to private data): Just add a function that does what you want and it'll look and behave just as the other functions on Array.
EDIT: Maybe the focus shouldn't be on adding a few convenience methods here and there, but rather on making the language itself more "pliable" or "growable" as Steele would probably say.
Regarding "dynamically typed": CLOS[1] got this right. Common Lisp is dynamically typed. In short: Dynamic/static typing has very little to do with this.
last(array) feels to much like C style OOP.
array::last()
would mean same as last.call(array)
that means `last` can just be a regular variable in scopeif ( !array.length ) { //do something }
Seems succinct enough not to require a separate function.
Check existence as well, this also works for a jQuery selection.