
JavaScript. The Core: 2nd Edition - wmonk
http://dmitrysoshnikov.com/ecmascript/javascript-the-core-2nd-edition/
======
Sawamara
This is a very solid foundation to work with, for anyone who might have
struggled with the contexts and how arrow functions, local variables, thises
(hah) and prototypes fit into the bigger picture.

It also clearly shows that Javascript is not the mess that it looks like from
a beginner's perspective. Yes, anyone can create a 15-20 min video about how
== and === can mess up stuff, how you cant just pass around a function with a
this in it without being careful, how NaN is wtf, and all that jazz. But at
the end of the day, stick to this language long enough and it works for you.

~~~
chubot
I wonder why nobody has created a version of JavaScript that just throws
exceptions for all the WTF cases? That is, it would basically be a mode like
'use strict-at-runtime'; .

This would be incompatible, but it would be a useful development aid. Surely
most frameworks like React and Angular avoid these corners of the language,
and they could be trivially modified to run on such an interpreter? It would
improve their code quality.

I know this would be a large amount of work, but it doesn't seem that huge
compared to all the other JavaScript infrastructure out there (parsers,
transpilers, etc.). There are more independent JavaScript interpreters written
than interpreters of any other language, AFAICT. At least before ES6, writing
a JS interpreter was a one-talented-person project, not a huge team project
like a JIT.

I guess one reason is that the DOM and node.js bindings aren't easy to
reproduce. But I would think people still run their unit tests in a limited
environment and it would be useful for some code. It could even be based on
narcissus -- JavaScript in JavaScript?

~~~
erokar
Probably because the WTF cases are exaggerated. After a couple of months
coding JS you will know it well enough so it doesn't bite you. It really is a
non-issue for people who work with it daily.

~~~
chubot
I agree it might not be an issue for professional programmers, given the right
tools.

But there are plenty of people who would recommend Python over JS as a first
programming language for exactly this reason. Python gives better error
messages and has fewer WTFs.

I think JS could be a good teaching language if it were not for the confusion
over types, which is an important thing for a beginning programmer to
understand.

------
Roboprog
One issue I have with this JS tutorial is that it spends little to no time
talking about FP, just OOP (functional vs object-oriented programming).

What text it does devote to Closures makes them sound like a "problem" to be
worked around. Funny, I thought "this" was the problem (to be worked around,
or avoided entirely whenever possible).

Class based languages such as Java do an excellent job of modeling how I
thought about programming back in 1990. It's how we were taught in school, so
as to be able to manage mutable data in a turing tar pit. (remembering a
lecture about garbage collection, which essentially scoffed at the
overhead...)

Having learned a good deal more about FP in the last 10 or 15 years (beyond
the little bit of Lisp I did in an AI class back in the 80s), Javascript
really starts to shine in many ways, whereas Java (and other [Simula67 subset]
C++ derivatives) looks like the intellectual cripple in comparison.

I wish people would stop trying to turn Javascript into something more and
more like C++/Java. Just stop, already. It was supposed to be like Scheme
and/or Smalltalk, but The Management (marketing) got involved, and the rest is
tragedy, er, history.

~~~
yugoja
The last paragraph describes perfectly frustration JavaScript developers face
while going deep into the language.

------
brosky117
I also highly recommend Kyle Simpson’s “You Don’t Know JS” series. Very very
good.

[https://github.com/getify/You-Dont-Know-
JS/blob/master/READM...](https://github.com/getify/You-Dont-Know-
JS/blob/master/README.md)

------
vorpalhex
This is good, with one major critique:

> ECMAScript is an object-oriented programming language, having concept of an
> object as its core abstraction.

This is technically correct but misses that Javascript is not OO in the way
that many other languages are, but is instead prototypical in nature. That's
an important distinction because creating long prototype chains in JS is a
very bad and negative habit, where as the same behavior is absolutely fine in
Java.

------
tomclive
I've just been reading through this and it's surprisingly accessible to
someone without a CS background.

Anthony Alicea's Understanding Weird Parts of JS on Udemy was pretty good at
introducing some of these concepts and I would have thought most people
working with JS would be interested in finding out what's below the surface.

~~~
_cereal
True, I'm not much into client side programming, just learning and lectures
like this or Axel Rauschmayer's[1] are gold sources to understand Javascript.

[1] [http://exploringjs.com/es6/](http://exploringjs.com/es6/)

------
johnhenry
> "ECMAScript is an object-oriented programming language, having concept of an
> object as its core abstraction."

I'm curious as to whether or not this definition makes sense to other
developers? ECMAScript does have a built-in "Object" data type, though I
wouldn't say that this is it's "core abstraction". Further, firmly object-
oriented languages, such as Java, seem to lack this abstraction. Perhaps I'm
missing something in the definition?

~~~
FLUX-YOU
Huh? All objects in Java implicitly derive from java.lang.Object. Same for
.NET and System.Object. The exceptions being value-types and structs.

~~~
johnhenry
Sorry, as a Javascript developer, my understanding of the Objects in Java is
crude at best, so I may not have made a lot of sense here.

------
Roboprog
As many useful things as there are in ES2015 (and beyond!), it's probably
worth pointing out a few "corporate" environmental constraints that might
limit one to ES 5.1:

* IE11 isn't dead yet. MS still supports it.

* The "Nashorn" engine inside (Oracle) Java 8 only supports 5.1.

Scoff at them if you will, but some of us have to live with these things, and
aren't using a transpiler.

------
mariushn
Related, any Typescript guides that you found very useful?

~~~
joshuacc
I've found Basarat's TypeScript Deep Dive very helpful:
[https://basarat.gitbooks.io/typescript/content/](https://basarat.gitbooks.io/typescript/content/)

------
stdgy
Wow, this is great! I think it's the clearest, tersest explanation of JS
langauge fundamentals that I've seen.

------
aryehof
Does JavaScript have some special definitions for _delegation_ and _dynamic
dispatch_? The definitions provided in the article appear to particularly
relate them to inheritance - which is not the traditional definition applied
to either term in object-orientation?

~~~
Sawamara
I think that the article is actually correct, because the reason why in other
- mostly static, and better designed dynamic -languages, you knew that member
functions were bound to the object being called is because that is how the
functions were actually handled by that language's runtime. There is no such
assumption in JS, so where in C# you explicitly design a delegate, the reverse
is true here. You need to explicitly bind the function or declare the function
as a property with an arrow function and capture the execution context.

------
zhirzh
It bugs me that the use of the word "inheritance" overshadows "delegation". It
paints a false image of the language.

------
frik
I wish Douglas Crockford would update his great "JavaScript: The Good Parts".
It's still great and aged okayish, but doesn't cover ES2015+.

~~~
alexhutcheson
Is there a good similar book that covers modern JS?

~~~
tomclive
The 3rd edition of Eloquent Javascript (including ES6) should be online next
month. Marijn Haverbeke was fundraising and reached his target.
[https://eloquentjavascript.net/3rd_edition/](https://eloquentjavascript.net/3rd_edition/)

------
expertentipp
This article is useless for the modern web development. Nowadays the essential
is to know the nuances between Angular versions and how to defer a promise
returned by chained observables.

~~~
macspoofing
You can get away with treating a JavaScript Engine as a black-box but
understanding what is happening under the hood will make you better. It will
give you a mental model to draw on when you run into some edge case that
causes strange behaviour that is otherwise unexplained.

------
sAbakumoff
As much as I like dmitrysoshnikov's content, I think it can't compete with You
Don't Know JS series.

~~~
vog
Do you care to elaborate? What do you see missing, what should be improved?

~~~
sAbakumoff
I mean downvoters didn't care to elaborate, so why should I do that.

~~~
obstacle1
Because saying "X is worse than Y" is not useful unless you provide reasons as
to why you believe that.

Imagine being someone reading your post. What are they to think? "Oh, this
person says X is worse than Y -- I'll go ahead and take their word for it,
despite no justification"? That's them buying into an appeal to your
authority.

Now imagine if you'd actually provided reasoning. "Oh, this person says X is
worse than Y because Z -- Z is a good point, therefore this is useful!" How
different.

Providing baseless opinions is not useful, which is why you got downvoted; and
incidentally, it's the exact same reason why you should "care to elaborate".

