Eloquent JavaScript 4th edition (2024)(eloquentjavascript.net) |
Eloquent JavaScript 4th edition (2024)(eloquentjavascript.net) |
In 2015, I was consulting for a distance learning program, administered by a major California University, that wanted to replace their current textbook (one of those “Head First” O’Reilly books) with something that had a bit more meat but was very approachable. I immediately recommended this and it was fawned over by both the advisors and instructors. It was also the cheapest option they had in the running (even excluding the fact it can be read for free) as it was competing against traditional text books. One year later, students were polled on it and it was met with a lot of positivity as well.
I got the same feeling and it's very off-putting. KS seems like a dick. It's ironic that so much of his dickishness seems to be reacting against what he takes as Doug Crockford's dickishness. Ah the irony.
I've gotten rid of lots of old programming books over the years, but I've held on to my first edition copy of Eloquent Javascript. Lots of thanks to Marijn for writing this!
I haven't read eloquent JS though, you say it's a different level of learner. Can you expand a bit? Is Eloquent for after "you don't know js" or vice-versa?
Edit: nevermind, reading the TOC of eloquent JS gave me a good enough idea
I know this is off topic but do you, or anyone passing, have a system or tips for how y'all do this? I've got so many programming books but they only collect dust after I read through them without benefit.
https://github.com/getify/You-Dont-Know-JS?tab=readme-ov-fil...
If the second edition is not available, you can read the first edition, just be aware some small things may be slightly out of date.
I'm also glad to see the asynchronous programming chapter significantly reworked - it was materially weaker than the rest of the book because of some weird analogies involving crows and their nests that didn't seem to make any sort of sense to me.
The third edition also gave me the impression that it was a reasonable book to learn JS and the DOM (and a sprinkle of Node.js, for good measure), but that it was a book aimed primarily at experienced people who were transitioning to JS and the web - not beginners (despite the book's efforts at claiming suitability for beginner programmers).
I am glad I am not the only one. I believe he over-abstracted it to it's own detriment.
I went to purchase a paperback earlier this week. Now I will wait for this one to hit print.
It's quite complete and detailed. But as if it wasn't enough the author wrote a second (smaller book) named “Deep JavaScript: Theory and techniques”[2].
Both are free to read online!
I was trying to find what's new in the 4th edition, and following links from the author's website https://marijnhaverbeke.nl/ found this on Mastodon (https://mastodon.social/@marijn/112020092273623390):
> The FOURTH EDITION of Eloquent JavaScript is now online, adjusted to the realities of 2024 and generally touched up.
[1] https://www.amazon.com/JavaScript-Definitive-Most-Used-Progr...
This was an interesting line of thought to digest. He's right, of course. Programming is probably still in it's infancy.
Studying and learning about programming however, can make you believe it's some ancient art mastered by the giants of our recent past, the perfection of which is never to be surpassed again.
(even though you do need a namespace when creating svg elements through createElementNS, both "of course" and "unfortunately", and of course you need namespaces if you're creating an actual stand-alone SVG document)
I really like the Deno approach so far. I prefer TS mostly these days as well as the esm stroke modules. I think node just made usage harder in their approach. I understand why, I still disagree on the solution.
This is from the chapter on HTML and JS (emphasis mine). It is funny to see how govt agencies and criminal organisations are mentioned in the same breath. How did we end up here?
another good one for my learning was "secrets of the javascript ninja"
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.
A distinction should be made between errors and exceptions. In JavaScript and many languages, we conflate the two and use exception handling as logic flow control. In my experience, this can end up being a headache and encourage unnecessarily weird structuring of code.
Look at this example from the page on errors:
---
function getAccount() {
let accountName = prompt("Enter an account name");
if (!Object.hasOwn(accounts, accountName)) {
throw new Error(`No such account: ${accountName}`);
}
return accountName;
}---
The possibility that a user will enter a account name that doesn't exist is not an exception, but we are treating it like one in this case. In order to handle this exception when getAccount is called, we have to wrap it or some higher level scope in a try-block and then regex-match the error message if we want to handle it differently from other errors.
You might be saying "it's just an example", but there's plenty of production code in the wild that is written this way. Maybe this could be improved by subclassing Error, but now you're having to manage a bunch of clutter and using object-oriented features as a way to reliably determine what kind of exception you're dealing with.
I find this pattern to be preferable:
---
const ACCOUNT_NOT_FOUND_ERROR_CODE = 1;
function getAccount() {
let accountName = prompt("Enter an account name");
if (!Object.hasOwn(accounts, accountName)) {
return {
accountName: null,
error: {
code: ACCOUNT_NOT_FOUND_ERROR_CODE,
message: `No such account: ${accountName}`,
}
};
}
return { accountName, error: null };
}---
Then we can call the function like this:
---
const { accountName, error } = getAccount();
if (error) {
if (error.code === ACCOUNT_NOT_FOUND_ERROR_CODE) {
errorModalService.show(error.message);
}
} else { // do something with the account name
}---
No doubt, you may still want to catch exceptions at a higher level scope, but at the nice thing here is that exceptions (almost) always represent actual unexpected conditions that aren't being handled properly while return values with error codes represent expected conditions and can be handled like any other logic in your code. It also reduces any ambiguity of how an error should be handled but without subclassing. An error can even contain more information than just a message if you want it to.
Also, if you really want to ignore an error for some reason, then you can just pretend that the error doesn't exist. No need to use a try-catch where the catch-block is a no-op.
I wish we'd encourage this sort of pattern, but maybe that's one of many pipe dreams of mine.
I learned JS from the second edition.
Incredible resource.
CH 5 : "Higher Order Functions" seems a nice segway into one of my favorite, lesser known js util libraries Ramda.js
When I was just starting out I read this book and noticed a small mistake, I was really proud that one of my first contributions to any open source project was a PR to this repo.
I don't work in JS at all professionally but this book has intrigued me for a while at this point after seeing it recommended so often. I think I'll pick up a copy once the paperback is released.
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 they face problems that require that understanding.
And I dispute the claim that "boxes" are the right abstraction for anything in JS. (Boxes may work for primitive values, but nothing further.) Directly seeing names as bindings ("tentacles") not only skips the incorrect "boxes" step, but also causes no confusion or problems whatsoever at any point. (If you have an example, I'd be curious to see it.) (There are some differences in the language between primitive values and Object, but none of them are particularly helped treating variables as boxes AFAICT.)
It's a higher level concept than the variable - a mutable binding is what people usually refer to as a variable, and an immutable binding is the correct term for what people refer to an "immutable variable" (an oxymoron, if you think about it).
2) the ‘binding/tentacle’ metaphor works just fine for primitives and the ‘boxes’ model adds more complexity.
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 by Ned Batchelder, which has more examples and elaboration: https://nedbatchelder.com/text/names1.htmlIt is true that exceptions "bubble", and plenty of developers take advantage of that behavior. In my opinion, it is not helpful for errors that are expected to happen as part of normal application behavior. Bubbling of errors creates a sense of logical indirection. Errors as return values communicate that likely nothing " wrong" actually happened. Good communication through code reduces the amount of time developers spend using the wrong assumptions when debugging.
There is also no reason why errors in a return value can't be returned by the caller. When you learn to love objects/hashes as return values, you can get the same benefits of bubbling but with a more clear path to follow when getting a picture of where a value is coming from and why.
In the case of actual exceptions, like accessing a property on undefined, an error being thrown is appropriate because, like you say, it can be bubbled up. The nice thing about reserving exceptions for this sort of thing is you might get away with a single try-catch at the highest scope and have a single straight forward error modal for when an unexpected problem occurs. Then you can otherwise implement errors in your code without the possibility that they will escape through bubbling and trigger behavior that is not immediately obvious when following the path of execution.
This is not to say that the tradition of using errors and try-catch for normal application control flow is inherently bad. Its just another tool. I do subjectively believe they are counter productive when used that way, and encourage others to try something like my approach. I think we would benefit by making it a standard practice.
Javascript was not my first language, but I have refered to javascript.info from time to time and it seems to have a gentle introduction.
It’s *nix specific but a great introduction to all kinds of programming concepts with great working examples in a variety of languages you’ll use every day
The actual diagnostic itself is better educated:
$ set -u
$ asdasdf
$ echo $asdasdf
bash: asdasdf: unbound variableI wonder sometimes at how much my whole line of reasoning should matter at all. In other words: if it as you describe (and I agree with your representation of the issue) then KS can be as dickish as he wants, he's providing awesome information that I can then use as I like. His actual personality should be irrelevant.
And yet, to me, it isn't. I suppose it's deep-seated social processing at work that's hard to override.
From my personal experience I think he's actually a really nice guy. He's also been unemployed for quite a while now and seems to be struggling with something. Doesn't seem very kind to kick him while he's down even if it's a virtual kicking.
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/ecmascript-data-types-and-...
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 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 :)
A variable binding can disappear entirely. If you bind var x = 42 and never use it, the variable need not exist. If it doesn't exist, then there is no pointer.
If you do use it, constant propagation/folding can again make the variable disappear. If the variable is never assigned, all uses of it can be replaced with 2.
Variables that care captured by lexical closures can be treated differently from ones that are not. Variables captured by closures but not shared among different closures, or not mutated, can be treated differently from mutated variables shared among closures.
The abstraction of binding is more complicated than "every variable is a memory pointer" because it allows more possibilities, which can coexist.
Nothing changes in last few years. We still go in with what we incorrectly assumed at the start.
According to the author, Marijn Haverbeke.
Given so many are just on Github and very well known/linked-to I doubt they even put any special effort into getting these specific resources.
The 'Eloquent JavaScript 4th edition (2024)' in Dark Mode
Also how this person is so productive? I really would love to read on how he manages his time and priorities.
>2**57
144115188075855870
>2n**57n
144115188075855872nhttps://github.com/python/cpython/blob/d864b0094f9875c5613cb...
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
I've been having to do some hacky things to represent numbers on an astronomical scale for my star system/planet generators.
From a quick browse:
- # for private properties
- ESM imports in node
- hasOwnProperty -> hasOwn (TIL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...)
- Math.pow -> **
- coverage of `function*` generators (https://eloquentjavascript.net/11_async.html#h-o+cFzGGhnz)
https://github.com/marijnh/Eloquent-JavaScript/compare/3rd_e...
It was challenging and made me question whether or not I had it in me to code. Turns out, I could, and, vis-a-vis my peers, exceptionally well.
Well, I took me, but this book was my first real introduction to computer science.
Funnily enough, I didn't then and don't now personally care for the author (he seems untalented as a teacher), but I feel he accidentally made a good resource in his hubris.
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guid...
JavaScript doesn't have integers. Everything is a float. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Although it has BigInt now.
(Like expecting that just because you declared something as type X, that it guarantees at runtime it will always be type X, but it won't. You may get data from an API that _says_ it returns type X but the contents don't match. That can be valid code that compiles and has weird runtime behavior)
This is exactly why I never recommend TypeScript to new developers.
A similar problem (that used to be worse) with people learning JavaScript is the lack of separation between JavaScript and the DOM + browser APIs. 10+ years ago, people have told me how much they hated JavaScript and when probed about it further, would admit that it’s actually the DOM or new/inconsistent browser APIs that have caused issued.
JS has a number of its own flaws and quirks, yes, but there are two fundamental issues that make it harder to approach as a new learner (as opposed to, to say, Python) are how tightly coupled it has historically been to it’s primarily application case and how high or low level is this language?
The idea that someone is good at another language so they'll automatically be good at another is a common misconception. In fact, they're likely to be worse because they're less likely to spend time trying to learn things from the ground up and less likely to write idiomatic code.
It's especially bad with js/ts because of it's popularity (so lots of new programmers that complain about how NaN doesn't equal itself), and because it's the defacto web language so lots of people are forced to use it as a secondary language that don't want to spend time learning it.
Why is that? If you want them to learn JS, teach/recommend them to learn JS?
Compile-to-JavaScript languages come and go, but JavaScript has remained. First learning vanilla JavaScript makes sense, and then add TS on top if you really have to. At the very least they'll be prepared for when TypeScript goes out of favor.
This is both a curse and the secret behind its success - it's arguably not a separate language, but instead an annotation layer on top of the existing language for encoding and checking your static reasoning and assumptions.
The chances of it going out of favour are very slim, there's a giant ecosystem built on it and the language is very well loved by devs (should be second only to Rust).
Microsoft has 50 people on payroll working only on TS. Any competitor needs a gargantuan investment.
An anecdote: I was sold a similar story on CoffeeScript back in the day, stressed myself out learning it, only to discard it a couple years later. TS won't have an identical fate as its shepherded by Microsoft, but eventually it will go the way of the dodo (whereas core JS will still be humming along).
It breaks down with the simple `let a = 22; let b = a` example where the tentacle/binding metaphor can lead to wrong intuition of why a change to the value of a is not reflected in b.
> When a binding points at a value, that does not mean it is tied to that value forever. The = operator can be used at any time on existing bindings to disconnect them from their current value and have them point to a new one
In this case:
let a = 22;
The binding a points to the value 22. let b = a;
The binding b points to the same value that a points to, namely 22. a = 23;
The binding a now points to a different value 23. The binding b is not affected.I've linked it a few times in this thread, but see the equivalent article for Python, which explains it clearly: https://nedbatchelder.com/text/names1.html
(It cannot break down because it's how the language works.)
This is exactly what I’m talking about:
> The binding b points to the same value that a points to
It may look obvious to you, but someone will interpret “the same value” as literally the same. So they might expect a change in a to reflect on b. Whereas if you tell them the “a box contains 22” and “the b box also contains 22” you prevent that misunderstanding. They might not have any concept of references/pointers yet and are just trying to make sense out of everything. These are the kind of silly mistakes people make when learning programming, or a new language.
It’s not about being right or wrong but providing a safe path to understanding that can be built upon. I did not mean the binding/tentacle abstraction is wrong, just that there might be a simpler one to introduce the concept. The book is still great regardless.
Binding refers to associating a name with a value. Assignment is a case of binding, but not the only one; two other examples are positional arguments in a function signature, and ESM imports. A binding can be mutable (let assignment, function arguments) or immutable (const assignment, ESM import).
Value mutability is orthogonal. You can mutably bind a primitive value as "let a = 22" and then mutate the binding via reassignment, but you can't mutate the value itself; you can immutably bind a reference value as "const b = {}" and mutate the referenced object via property access, but you can't mutate the binding.
I refer to bindings all the time, where it's useful to be clear in meaning. I also make sure to introduce the concept to mentees who aren't already familiar with it, and by all reports thus far it's proven as valuable an abstraction for them as it did for me when I first learned of it.
Programming or any technical learning is a hands on experience. Take notes and apply techniques, using pen-and-paper or the keyboard, as they are presented.
If you really have to just "read" a technical book, IME a less-is-more approach works best. 5-10 minutes at a time, not even a chapter at once. Maybe a few paragraphs if its something really information dense. Funny aside, I find my morning "business" is the perfect time to this sort of reading using the Kindle app on my phone.
- never in bed. never as audiobook. But sitting. At a table or desk.
- no distractions. At most "focus music".
- read a chapter through. Then read it again and do all excercises (on a computer without wifi)
- make copious notes, highlight quotes, summarize. Most important for me is to write down why I made that note.
- a time (years sometimes) later, do it again. E.g. when having worked on the concepts from a book in real prod projects.
- at most an hour. I have ADHD and my mind often flies everywhere suddenly; time to give up and grab a beer or coffee.
Very few of these work as ebook (Kobo) for me. The formatting of code is poor and diagrams unreadable. Prefer paper or PDF (but read on a computer or tablet without network).
~ Yes, always do all the exercises. It's important how you do them. No copypasting. Enter all the code examples in your text editor of choice and run them if possible. Experiment liberally and don't be afraid of errors; instead, adjust the program in response to the errors. Create a directory and save all your files; don't just keep overwriting the same exercise. This is so you can go back and review if necessary.
~ If possible, always use the PDF formatted version of the book. EPUB and other formats too often don't look good and aren't formatted as the author(s) intended, and PDFs tend to be easier to follow because the page is formatted the same as the print version.
~ I use the Pomodoro technique of working intensely on the book for 25-30 minutes and then taking a short break before continuing. This tends to help me focus and retain more of the book.
Back when I was learning Python, I used two books in sequence, "Python Crash Course" by Matthes and "Think Python" by Downey. This turned out to be fortuitous, because until I started working through them I didn't know they are two completely different approaches: PCC teaches you how to program in Python and TP teaches you computer science using Python. Working through both books consecutively gave me a much better scope and understanding of the language to build on than using one book alone and stopping there.
> Very few of these work as ebook (Kobo) for me. The formatting of code is poor and diagrams unreadable. Prefer paper or PDF (but read on a computer or tablet without network).
My ancient (2011) Kindle is borderline useless for technical material but the iPhone app renders diagrams and equations acceptably well (my experience, of course). The small form factor of the phone is helpful too - more desk or table space for notebooks. Mind you, I make heavy use of app limits and downtime so its not the distracting experience of typical smartphone use.
And make sure you are typing the code, and not just copy pasta. Writing it out helps most people process it.
My ears perked at this. Great advice!
In bed, phone out of reach and reading one hour, sleeping half an hour was super efficient for me. You only process material while sleeping anyway.
Beware of hemorrhoids later in life if you’re spending too much time sitting on the throne.
In this stage, I don't sweat the parts I don't get, I just note for later, that, if these turn out to be important, will require some care, patience and time. I also build some sort of "map" in my mind about the elements that exist, to get an overview.
After doing so, I feel a lot more confident to tackle the topic of the book "properly", doing exercises, etc.
Also, realistically you probably won't remember most of what you read. I suck at that as well, but you do build up a lot of peripheral knowledge. You may not remember how to do that one thing, but maybe you do remember that it exists, or that it was in a particular book. Just that type of knowledge has worked well for me.
2. If feasible for you, consider getting a neuropsychological evaluation to rule out any learning disabilities like adult attention deficit disorder.
1) I buy physical textbooks and absolutely destroy them with notes in the margins, highlighting, etc. It helps me to interact with the material instead of letting it wash over me, which means I'm both thinking about it more in-depth and as side effect I'm less bored. Otherwise I'll fall asleep and won't learn anything. 2) I accept that I'm not going to remember the entire book. A lot of books are most useful as references anyway. But if you ever find yourself going, "Oh that's really handy to know," then you can make a special note of it or even put it into flashcards. I've been using Anki. The trick is to recognize what is actually worth doing this for. 3) If something is especially worth knowing, (see point 2), see if you can either do problems from the book or try out the concept in some way if there are no problems available.
If you're reading something just because you feel like you should, you won't get anything out of it (or a least I don't).
“Reading a book from the beginning to the end is like insisting on marrying every woman (or man) you fall in love with.”
And that opened my eyes and now i no longer feel in debt to the book or the author :)
Unlike others here, I never take notes, and rarely do suggested exercises. But I read and think through examples; and as to exercises, I do think of "how I would approach it" and "what is that the author wants me to learn from this exercise".
Here's an example of how to use it to learn quantum mechanics, but you can imagine how it would translate to technical books for software developers: https://www.youtube.com/watch?v=OFuu4pesKf0
Start from chapter 1, study the concepts and play with the code examples a few times till you understand. Usually there are exercises at the end of each chapter. Try to work on those.
The first step is figuring out what your learning style is.
https://www.youtube.com/watch?v=rhgwIhB58PA
Personally I find a multi-pronged approach is necessary to really learn anything. Read it. Read it again. Visual guides are helpful. Work some examples. Make some mistakes, debug them, find the corner cases, write tests. Eventually when I've poked around the material for a while it starts to bed in.
Three months later it's forgotten, but when I learn it the next time I move a lot faster!
All of this is possible with video and audio in principle, but much less natural and much less convenient; also video somehow "hypnotize" me and I don't feel the urge to think about what I see and hear at the moment; perhaps only afterwards if at all. I have a feeling "oh I get it", but not much remains afterwards.
So I absolutely prefer text to audio or video when learning.
It’s easy to fully internalize generalizations that someone has presented to you, usually because it’s wrapped up in a way that is mostly compatible with how you see the world. Because someone has done the work of distilling this information, you are not able to share in most of the intellectual benefit. It’s the process of having a question, discovering an answer, internalization of the concept, and synthesizing a summary that brings you closer to understanding. It feels like a series of “lightbulb moments” when we consume this content, but it is often shallow and fleeting because the genesis of the idea was not your own. Airport/self-help books are a good example of this mental candy that makes us feel good when reading it but, unless you are able to fully internalize it, are just empty mental calories.
Comprehension and understanding are derived from amassing knowledge a little bit at a time as your mind is ready to advance your understanding. In other words, you really have to be “primed” for knowledge found in books. This is the reason that information you obtain after an adequately-informed struggle stays so salient: your mental model had all the scaffolding around a concept but there was a clear “void” where this answer fits, and if you find that fits super cleanly, it’s extra satisfying.
When consuming information-dense material, you end up with this knowledge back-pressure where it’s floating around your short term memory but won’t be committed to long term memory because there is just no place for it yet. When recalling information in order to create new content with it, and assuming you are challenging yourself, you will end up in situations where there is information starvation (the opposite of back-pressure) where you must either find answers (to fit in your mental model) or find a workaround (ignore the gap).
Some people can just read books and create efficient mental models. Others (myself included) have a limit of how much they can learn in one sitting because our brains need to be fully ready to accept this information.
The last piece of this is the dopamine response cycle that is a positive feedback system (positive as in “more creates more”). Dopamine makes us feel good by rewarding behavior that evolution deemed necessary for species survival (over simplification). Dopamine indirectly triggers long term memory retention because we need to remember why we felt good in that moment so we can replicate it. This used to be, “this berry tastes good, I should remember where this bush was and what the berry looked like.” In the modern context, it ultimately delivers motivation to us because we have adapted to using it to learn new information that is less relevant to survival. Achieving goals and solving problems at hand causes a huge amount of dopamine release. The problem is that we’ve found ways to hijack these systems and short-circuit this feedback cycle so everything had to become way more stimulating.
This got long, but my advice is to work on a project of your choosing that you are intrinsically motivated to do. Begin work on that project and read some of the book that relates to the problem at hand. Repeat this cycle of reading and working, trying to incorporate patterns and concepts you find while reading into your project. Make little goals for yourself every day before your start, and really hold yourself accountable in finishing them.
read a page, keep a notebook next to you and rewrite each paragraph in your own words. it forces you to engage more deeply with the material
But it is literally the same? Numbers are immutable, so there is a performance optimization where you can avoid using pointers internally, but the fact that they are immutable also means there is no way to distinguish between them being the same value and them being "different instances".
If you do `let a = []; let b = a; a = [1]` would your students expect that b equals [1] or would they understand that a and b now contain different arrays? If the latter, then why would think that after `let a = 22; let b = a; a = 50;` b also equals 50?
I have actually, so I understand what you mean, that all sorts of confusions are possible no matter what. I agree with you on that part; I just disagree that the “boxes” metaphor is something that is necessary or “needed later” (what I understood from the wording “This method spares the reader one step, but might cause confusion once they face problems that require that understanding” or “breaks down”).
Yes, the student needs to understand that “let b = a” assigns to b the value of a, and does not make b a permanent alias for a. To some students that misconception may never arise, but to others it might and that is something to watch out for. (This is the part explained here for instance: https://nedbatchelder.com/text/names1.html#:~:text=I%E2%80%9... — sorry if you cannot see the highlighted part e.g. if you're using Firefox (https://caniuse.com/url-scroll-to-text-fragment), look before and after "Reassigning one of them".) But if you explain this as “the a box contains 22” and “the b box also contains 22”, this is an understanding that only applies to primitive values and therefore will break down pretty soon and cause confusion (given how widely non-primitive values are used in JS/Python/etc), while if you say that “let b = a” makes the “b tentacle” point to the value that the “a tentacle” points to, this is a uniform understanding that bypasses the incomplete “boxes” understanding. With the understanding that names are one kind of thing and values are another, and names can only point to values (not to other names), there is no problem with “the same value” being interpreted as literally the same: it is literally the same value (a Platonic ideal “22” that lives out there and that both a and b point to), and a re-assignment like a = 23 does not change the value (the notion of changing a value would not even arise without the boxes metaphor, as value 22 and value 23 are simply different things on the values side).
But I guess ultimately this is an empirical matter: we can try the different paths on different sets of students and over time see which one takes better. My intuition is that the “tentacles” metaphor is just as easy to understand as “boxes” without the latter's problems (there are risks common to both, e.g. "let b = a" neither makes the b tentacle point to a itself, nor does it put the a box inside the b box), but until we actually try it out (I have not tried to compare), I guess we just have different intuitions for now. :-)
I can definitely learn faster from a video as long as there are no talk heads in it, and only content.
Trouble is, all the instructional videos I had tried up to that point were crap. I can't think of even one highly recommended programming instruction video that is any good for me.
And turn off copilot. The code from the book is very likely in its training set. It will produce it almost verbatim. And you learn nothing.
I've seen interns that are better than some of my 15+ year colleagues.
I'm better than most of them myself, but I've also seen interns better than me -- better problem solving skills and attention to detail I suppose. Very inconsistent correlation in terms of time spent outside of filtering people. Of course, you used to have a knowledge advantage that would hold for a bit, but intelligent usage of GPT-4 removes even that.
I'm pretty sure the whole enterprise is a combination of being gifted intellectually, with maybe a sprinkle of actual effort and abilify to sustain your attention on supremely boring tasks -- but mostly just your innate gifts at work.
When I say "better than"... well, here's my opinion: In programming, someone more talented can be up to 10x more productive at each tier of competence, shall we say. My least productive (senior and junior) colleagues are 10-100x less productive than me. My most productive colleagues (senior and junior) are probably 10x more productive than me.
This is an interesting discussion to me because I used to believe the whole tiered conception of programming knowledge until I learned that this wasn't the case through experience.
It's all just problem solving, and you're either smarter or less smart and you can't change this with even 1000 years of study.
Knowing what rabbit holes not to go down is the true 10x. Not the faster typing part.
When you say "don't overwrite", di you mean to start from scratch every chapter? I can imagine this would work for me: repetition is key. But also to get frustratingly boring after a few chapters.
I'll just treat is as any trunk based git repo. Commit significant progress, several times per hour. Then rebase to "summarize" my learnings into a history. I'll commit them to a public repo and treat as if that annoying colleague is going to review. Not that anyone will ever read them. I probably won't myself. But the art of rebasing, amending and pulling apart helps me with what would have been the perfect eLearning history.
Care to provide what you mean?
Strict TS won't compile pretty much any type-unsafe operation.
It's not perfect, the standard libraries are a bit too unsafe type wise, exceptions are untyped and need Either/Result-like data types to be handled but it's an extremely powerful language if you know it and it's ecosystem.
Most people though don't even bother reading the docs and can't tell you what a mapped type is or what is a disjointed union, etc.
As soon as you have third party code calling your methods all bets are off. It could be JS calling your methods, or there simply is a hidden cast somewhere.
This is the moment that you realize that type annotations really are just a compile-time fiction, much like Python. At least in my definition, this is weak typing as the variable is physically capable of changing to any type at runtime, despite its type annotations.
I think that's besides the point. My point was more that people who are supposed to learn JavaScript, should do so by learning vanilla JavaScript first, then they can move on to learning whatever is currently hyped by the zeitgeist (which happens to be TypeScript currently).
Most CoffeeScript will simply syntax error if you feed it into a JS interpreter (and vice versa), and there's no trivial syntactic transform to get around that (i.e. it's not just a new surface syntax over JavaScript). Various features in CoffeeScript have no equivalent in JS, so new code needs to be synthesized for them; even fundamental features that are shared by the two languages are different - for just one example, this [0] article shows that how a function is compiled in CoffeeScript is non-local - the compiler is tracking variable scopes to get around the fact that CoffeeScript and JavaScript have different scoping semantics.
With TypeScript, the "compilation" process is (almost):
parse(typeScriptCode) -> treeMap(removeTypeAnnotation) -> write
That's it! TypeScript code is syntactically valid JavaScript code, just with added type annotations (and, as mentioned, soon that'll still count as syntactically valid JavaScript code); JavaScript code is syntactically valid TypeScript code without any type annotations - which doesn't make it syntactically invalid! Indeed, if you turn down the strictness settings on tsc to permit untyped code, the compiler doesn't even complain about it....but that's mostly just what I say to JavaScript devs, to be polite - to not tell them that their JavaScript code is bad, too. Code that's difficult to reason about statically is strictly worse, in my opinion, than code that's easier to reason about statically. And in that sense, TypeScript is just guiding you to write better JavaScript, which maybe undercuts its claim to being a language of its own.
Adding this just in case someone is tempted to get a Remarkable for reading PDFs.
I had this the biggest iPad back in the days it was introduced, but gave it to a friend as it felt too big for me, and way too expensive for what I wanted from an iPad. (Basically just a YouTube streamer, and my long obsolete iPad 3 from 2012 still does the job, surprisingly.) I checked iPad Pro 12.9 and there are justifiable prices for used ones, so I think I’ll replace my iPad 3 with this big one, which will allow me to read PDFs more comfortably as well.
Btw, I tried printing some PDFs and I don’t like it that way. I know to each their own, someone likes the books printed, but I’m the opposite of that. So much that I had donated all the physical library of my dad’s books I had in the house after his passing out, as I realized I would never read them in paper.
But I guess a neurotypical zoomer can code fine with a TV in the background, a podcast in one ear, insta and DMs ploinging into their notifications and slack nagging in the status bar. I cannot.
Also. Notes have always been a mess. I note a lot with pen and paper. Most even. I have piles of random paper. Pen drives with markdown. And large gaps.
If anything, adhd is terrible for consistency in this kind of stuff. Which is why I go full on plain text formats. Any binary, SQLite, cloud whatevs will rot within weeks after me loosing interst. Yet my diary.md and my bookkeeping.ledger, albeit gapped with years, still goes strong.
It really isn't, but I guess that's really context specific. What country and sector are you talking about? For US-SaaS, what you're saying is probably true, but there is a whole world outside of that, and JavaScript is with 99% certainty much more wildly used than TypeScript.
> and it has killed all of the other compile-to-js languages.
Also it hasn't. I've been writing ClojureScript for the last 5 years, almost exclusively. And while the community is small, I wouldn't say it's "dead" or been killed. There are a bunch of compile-to-JS languages that haven't "been killed", besides ClojureScript.
But it serves basically the opposite niche compared to TypeScript.
> The chances of it going out of favour are very slim
Same has been said about everything, always, and it's always not true. Winds change, and surely so shall the winds of TypeScript. Not being able to see that it's possible, will put you at disadvantage.
Any valid JavaScript is valid TypeScript and you're gonna write and read TS anyway in the industry.
They aren't in competition, but coming back to the first comment it sounds reasonable to start directly with TS for many users.
I'm not sure you're 100% right about it overtaking JS for most of the industry.
I wouldn't recommend it to beginners until they've learned JS because it's a lot of stuff to learn on top of JS to achieve basically the same outcomes (with fewer bugs). Chapter 5 in the Eloquent JavaScript book gets to higher order functions, which in TS means Generics. Nobody needs to learn Generics in Chapter 5 of their programming journey.
You also don't really appreciate how useful TS is until you've battled at least one project in plain JS.
(Arguably you can go a long way without HoF too, but perhaps not if you're hoping to understand other people's code.)
https://npmtrends.com/@babel/preset-flow-vs-flow-bin-vs-type...
In case of C++ this would lead to desastrous memory corruption. If all data is dynamic you can't have a safe program as data on the stack must be monomorphic or you corrupt nearby memory.
Naturally, you can defend against hostile input via excessive defensive programming (asserting against nulls, asserting against wrong types etc.). Or you simply use a strong static typed language.
That kid that blows you away will likely stagnate like all of us, he might pick up a few tricks, though.
Also, if one hasn’t read the historical literature such as Petzold’s Code, Mythical Man Month, High Output Management, McConnell *, etc they have a long way to go. No amount of bit-twiddling proficiency can make up for that. Unless you’re in the twiddling business. :-D
Making things seems to do the trick there.
Compare it with typescript [1] contributions if you want.
[0] https://github.com/facebook/flow/graphs/contributors
[1] https://github.com/microsoft/TypeScript/graphs/contributors