Language design

Benjamin Gruenbaum benjamingr at gmail.com
Sat Jun 13 00:43:45 UTC 2015


I'm going to address your questions.

`Object.is` - have you checked and read the actual thread in the list
explaining the motivation behind that?

"Operator [] casts its argument to string ... but not when used with
Symbol" - that's the poit of symbols - to have non string keys that are
unique. Reading the motivating symbol thread or a tutorial should clarify
the point of symbols and how they solve a hard problem in a rather elegant
way. Also it's not an operator.

"New iterator API relyes on Symbol.iterator. Why do we need it? " - to have
a uniform way to iterate things that support iterations, much like
implementing an interface in a statically typed language or __iter__ in
Python. Again, this has been explained a few times in past threads.

" Why not just use strings and prototypes?" - because that would break
backwards compatibility and be a less elegant solution, using a symbol also
ensures you do not accidentally implement a protocol.

"fromCodePoint doubles fromCharCode, but differs a bit. " it differs a lot.
Not that it would matter much since you can't break the whole internet just
because you'd like to "repurpose" something. Code that relies on this is
literally used by billions of people and billions of websites.

"Iterability and enumerability are distinct, but iterability is just
enumerability with numeric key (yeah, I know that it is possible to create
endless or random iterator, but in fact this means that you just don't need
to use the key provided)." - in the scope of the spec enumerability is of
object keys and iterability is iteration of an iterator. Not everything has
its keys iterated - the reason an iteration protocol is needed is to make
this distinction - how would you iterate a `Map` or a `Set` or any other
non array-or-object collection? This is why every other language defines
this form of protocol (From c++ to Java and C# and Scala to dynamic
languages like Python to purely functional ones like Erlang and Haskell)
and why ES does too.

" Why can't we use methods definitions to define methods as a function
declaration?" I have no idea what you were trying to say here, sorry.

"Why JS is so badly designed?" for the same reason other languages are. JS
has quite the back story, a lot of baggage and hindsight is always 20/20.
Every language sells you the "awesome" story until you use it - I'd argue
other languagesl like Python and Haskell have as much if not more baggage.
Ignoring the fact asking this is completely pointless and needlessly
argumentative - language design is really hard. If you're interested in
what motivated a lot of the things in ES - please the material is out there
go read it :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150613/25e130db/attachment-0001.html>


More information about the es-discuss mailing list