Live data from Hacker News

Eloquent JavaScript 4th edition (2024)

eloquentjavascript.net

101–110 of 249 posts

Re: Eloquent JavaScript 4th edition (2024)

#102
I have Zakas' Professional JavaScript for Web Developers and ECMAS 6 update. Was very happy with them (easy to read) but both are getting long in the tooth and the author seems to have lost interest in updates.

How does this one compare as an all-in-one? Being up to date is a win, but I'm wondering about the quality of the writing.

Re: Eloquent JavaScript 4th edition (2024)

#103

Earlier quoted context omitted.

It's a great explanation, but I've never heard the term 'binding' used to describe variables. It's usually reserved to function binding or bridge APIs like the DOM. The tricky thing is that "boxes" are the right abstraction for primitive values. After that you need to explain how references work, and that's pretty much the same 'tentacle' concept. This method spares the reader one step, but might cause confusion once…

"binding" is pretty standard terminology in some oldtimey languages; lisp, ML, etc.

Bash documentation says that "set -u" traps variables that are "unset".

The actual diagnostic itself is better educated:

  $ set -u
  $ asdasdf
  $ echo $asdasdf
  bash: asdasdf: unbound variable

Re: Eloquent JavaScript 4th edition (2024)

#104
post #84

I'm currently going through a hard copy of the book's third edition. But I'm wondering whether the description of the language in the book is detailed enough. Could you share some opinions on whether it will be good to go through some other JavaScript books after it? I'm considering going through "JavaScript: The Definitive Guide"[1] or "The Modern JavaScript Tutorial"[2] after it. [1] https://www.amazon.com/JavaScri…

"JavaScript: The Definitive Guide" does go deeper, with thorough examples in all the topics mentioned in the index. It also provides examples of static types using Flow instead of TypeScript.

Re: Eloquent JavaScript 4th edition (2024)

#106
post #80

Earlier quoted context omitted.

I'm curious - could you expand on why it's a pitfall to think of variables as boxes?

Because that's not how variables work in JavaScript/Python etc (though it may be fine for say C++ in the case of value types and copy constructors). For example: I'm typing on phone so for a quick example: let a = []; let b = a; a.push(1); and consider the value of b now (or the fact that we could write "const" above because the binding is constant, even though we mutate the value). Or see the equivalent for Python b…

I knew that in Python all variables are really references to objects (even when we're using a number) - is JavaScript the same way?

Also, does anyone have a link/reference to the place in the spec where it specifies this? I briefly skimmed through parts of [1] but couldn't find anything that says that JavaScript treats numbers this way.

[1] https://tc39.es/ecma262/multipage/#sec-intro

Re: Eloquent JavaScript 4th edition (2024)

#108
post #78

Earlier quoted context omitted.

Immutable variable isn't a oxymoron. It can still vary between instantiations. If you have (a)=>{const b = a}, b can have different values even though it can't be reassigned.

In the case of the code that you have cited, these are all different elaborations of the binding at the invocation of the lambda, due to the interplay between activation records and scope rules. It's not really an "immutable variable" - it's a local binding getting bound to different values on each scope entry. EDIT: By the way, the `b` binding in your code can be modified. Did you mean `const b = a;` ?

> it's a local binding getting bound to different values on each scope entry.

It is, I just wanted to point out that the term "immutable variable" is sensible. I think a good way to put it is that b is a variable, and when the statement runs a value is bound to b. So the value bound to b varies yet b can be immutable, in contrast to a constant which is a binding to always the same value.

> Did you mean `const b = a;` ?

Fixed, thanks :)

Re: Eloquent JavaScript 4th edition (2024)

#109
post #80

Earlier quoted context omitted.

Because that's not how variables work in JavaScript/Python etc (though it may be fine for say C++ in the case of value types and copy constructors). For example: I'm typing on phone so for a quick example: let a = []; let b = a; a.push(1); and consider the value of b now (or the fact that we could write "const" above because the binding is constant, even though we mutate the value). Or see the equivalent for Python b…

I knew that in Python all variables are really references to objects (even when we're using a number) - is JavaScript the same way? Also, does anyone have a link/reference to the place in the spec where it specifies this? I briefly skimmed through parts of [1] but couldn't find anything that says that JavaScript treats numbers this way. [1] https://tc39.es/ecma262/multipage/#sec-intro

As I understand it, JavaScript does have a distinction between the primitive types and Object, but this does not show up in any significant way to the programmer / in any way relevant to how to view variables. To put it differently, the "boxes" view only applies to primitive values, while the "tentacles" view applies to all values, so the former is unnecessary and need not even be considered/taught.
Post reply on HN