I'm actually working through this book right now. I've been away from front-end coding for a bit and my weekend/evening project over the next month is to brush up on modern Javascript and ReactJS. This book is very well written and great re-introduction to JS/programming fundamentals.
For those interested--Besides this book, my current learning plan includes:
Javascript 30 by WesBos
Exploring ES6 [http://exploringjs.com/es6/]
Learning React-2nd Edition on O'Reilly Learning
The Beginners Guide to React on Egghead
Data Structures and Algorithms in JavaScript on Egghead.
I also used Kent C. Dodds' excellent "JavaScript to Know for React" article as an outline.
Whoa! You’re going to finish all seven (six?) of those books over the next month? Just on nights and weekends? How are you so productive? How do you not burn out, given that (I assume) you do software during the day? Honest question, from someone who is often down on themselves for being a slow coder, slow reader, and easily burned out.
Definitely don't get down on yourself--going through periods of low- and high-productivity is normal. I get burned out at work multiple times each year (I do mostly technical writing, training, and support). It just depends on how you look at things and how you measure success. I'm not a 10x developer, so I don't measure myself against 10x tech bloggers or other "experts". I just break my learning goals down into small, manageable tasks and revise as needed.
My measure of success is being able to understand development at a lower-level. Learning new languages, frameworks and building side projects helps me through the low periods and enables me to work more fluently with developers.
I have experience with Javascript and VueJS from a couple of years ago, so my goal is to catch up with modern JS (ES6+), brush up my JS core knowledge (not just frameworks) and learn ReactJS. It's very likely that I won't finish everything on my list this month, due to other obligations, but that's ok. I'm not competing with the experts out there, I just want to learn new skills and build things that I couldn't before. I also have a bit more time now that I'm stuck at home on evenings and weekends.
The docs are great for a given tidbit, but for structure and "why" I personally don't always get that from the docs and I end up reading something from Kent that tells me why.
I guess (online) books speed up the learning, but I've learned all those techs by practice over a few months, official docs (mdn, nodejs docs, react docs, googling, github issues & stackoverflow) and IRC
The MDN and React docs are amazing! I consistently refer to them while working through the books for a deeper dive into the API's. I tend to have three MDN pages open at any given time.
JavaScript is very expressive and powerful language. Maybe hard to learn. The prototypal inheritence and 'this' were confusing to me and took much time to understand those.
Then I learnt that prototypal inheritance is a superset of ''class''ical inheritance [1] as well as this [2]. Hmm.
With Reflect, Proxy etc. you have great metaprogramming capabilities that make this language much powerful.
Still, there are some (many?) edge/corner cases and unfixable bugs (aka features) that the language is stuck with for the sake of backwards compatibility and developers have to learn these. (The most famous of these might be typeof null === "object")
When I look at the amount of features added to the language specification, sometimes it seems like it is going to become another incarnation of the C++ specification.
I still like its expressiveness and power, but if it becomes another C++ in future, I have to look somewhere else. (TypeScript maybe.)
I'm convinced that prototype object systems represent a poor set of requirements.
Those requirements are chosen because they lead to ease of implementation: prototype objects are the quickest and dirtiest way to enhance an interpreter such that programs can be written in it that are discernibly OOP-ish.
They don't represent a set of requirements that amount to a good OOP system.
They're most obviously a bad design because now any part of the code in your entire program can change the behaviour of any other bit of code. It means you can't understand code in isolation.
I would consider myself pretty close to an expert with JavaScript. I've been using it for 5 years professionally, currently use ES2020. Fairly familiar with Node 12, V8, etc. But I'm always worried about those situations where you dont know what you dont know. This might sound strange, but would anyone recommend any reading material or blogs for someone at my level?
I am not a full blown Javascript developer (backend developer here), but had been using JS and other frameworks for about 10 years now. I subscribed to Dan Abramav's "Just Javascript" [1] email. It is really good to read/follow and has one concept and idea explained well.
I think the sentiment of "you dont know what you dont know" is especially cumbersome with JS, since its usability is so much defined by its extensions (WebAPIs, runtimes etc.)
Reading into specs (ECMAScript[0], W3C[1]), some more approachable explanations[2] of them and some implementations[3, 4] of embedded engines seem to be my approach.
I've been using JavaScript professionally for about 12 years.
You're going to have to look for talks and really technical posts. Consider whitepapers and source code for JavaScript engines at this point. You'll probably want to start reading up on the things attached to JavaScript, rather than the language itself. Browser rendering, event loop, V8 things, garbage collection, etc.
I was lucky enough to see this live - https://v8.dev/blog/elements-kinds - but I recommend watching and reading for anyone. Half because is pretty interesting and accessible at the same time. And half because you might use it .
I definitely wouldn't consider the first video 'advanced' material (an excellent talk btw), JavaScript event loop is something beginners should know about and intermediate developers know very well.
Have you ever read through this annotated ES5 spec? Even annotated it's still pretty dense, but it's a nice way to both dive deeper into the language and as a 'minimap' to guide you through the parts you have yet to totally master. It definitely helped me level up more.
if you can't find something you didn't already know in the free book series "you don't know javascript" then I'd imagine you might not have any gaps in your knowledge. (at least for 99% of it)
(you can buy a hard copy of it if you want but it's open source)
Some of the TC39 proposals might be worth looking at. The ES spec too.
If you really want to go all out, you could write a simple JS interpreter. Probably don't want to go full spec compliant but you could implement a decent subset. Especially if you skip the parsing step with Acorn https://github.com/acornjs/acorn
Big scare quotes there, you can't really 'prove' much in typescript. Don't get me wrong, it's a nice type system they've tacked on to JS, but it's far and away from proofs of correctness. At best, it's an optional type system with escape hatches.
read "you don't know JS" series of books, also second edition https://github.com/getify/You-Dont-Know-JS I find the workshops very helpful as well, which I've watched through my oreilly membership don't know if you can find them elsewhere, I would suggest combine this with reading the specs.
on edit: one reason the specs are not enough is generally specs will tell you what needs to be implemented but a good book, like these ones, will tell you how it has been implemented or what the spec implies for implementation and what all that will mean for you as a user of the language.
> But I'm always worried about those situations where you dont know what you dont know. This might sound strange, but would anyone recommend any reading material or blogs for someone at my level?
It's not very clear what you are asking, neither what's your background. In your situation I wouldn't spend more time learning stuff about JavaScript, I would just improve my skills in software engineering (design patterns, code quality, refactoring, etc) and diversify my knowledge (learn other languages (python, go, or some FP language to learn something really different); databases and SQL; web servers and REST; etc).
Not sure how it holds up, but Secrets of the Javascript Ninja was the book I read when I felt like that, and it significantly helped me understand a few concepts I had struggled with. By John Resig (created jQuery). But it's a few years old now, so likely won't cover much if any ES6+ stuff. But I'd bet the concept stuff is still very valid.
Also the You Don't Know JS series. And Elliot's Programming Javascript Applications.
I don't know you, so I don't know if this applies or not, but be careful not to fall into the "expert beginner" trap (i.e. Dunning Kruger). Your first sentence starts to feel that way, but the fact you're asking for more resources and aware there are things you don't know are good signs. Always keep learning, the rabbit hole goes ever deeper.
humble opinion: N years of using any language won't make you an expert.
There's knowledge about how to express certain patterns in a given language, more like an application design expertise. There's knowledge and familiarity with the APIs. And then there's the deep language knowledge, the one that pretty much only someone implementing a language VM, parser, compiler and other tools may acquire with time. Also, there are a lot of specifics about every particular JS implementation.
Great read, though his writing style is less intuitive if you are fairly new to JavaScript and trying to grasp some of its concepts. For example, in his reduce function [0] example, he names his variable "current" to bind the accumulated value the reduce function is going to eventually return. That is a totally fair name, but I don't know if it really "clicks" if you were reading over this for the first time. I think it would be faster to grasp the reduce function's purpose if it was simply named "accumulated" or something alike, especially when this snippet is advertising the idea of higher order functions and callbacks.
Little things like this I am nit-picky about, but overall, great book.
> This much anticipated and thoroughly revised third edition of Eloquent JavaScript dives deep into the JavaScript language to show you how to write beautiful, effective code. It has been updated to reflect the current state of Java¬Script and web browsers and includes brand-new material on features like class notation, arrow functions, iterators, async functions, template strings, and block scope. A host of new exercises have also been added to test your skills and keep you on track.
Does anyone have a book recommendation (free or paid) that is modern and up-to-date, preferably regarding typescript, that talks about best practices and patterns for large-scale project design and code structure?
For example, a book that could go into details of code practices at companies like Airbnb, Facebook, or Google.
Typescript is relatively new, and I think a lot of those companies are still trying new things and experimenting with what works. I expect that we will see more refined content and books about TS-at-scale in the near future though.
However, for those looking for a great way to learn Typescript from a beginner's perspective I can fully recommend Execute Program[1].
At the speed of javascript though, it's pretty mature now. When I tried searching on Amazon I was getting back $30+ dollar ebooks with chapters on how to use Gulp (superseded by webpack or babel)...
> patterns for large-scale project design and code structure
I would be particularly interested in this. The OP has a chapter on "Program Structure" but it seems like more a toolbox of language constructs.
It would be nice to see a book that went through a few archetypes of common JavaScript programs (command-line script, daemon, enhanced webpage, single-page app) and gave a basic blueprint for what parts are needed and how they interact.
Not quite what you're asking for, but I really liked this book since it was beyond introductory material and had concrete examples of what and why to do things:
A project in TypeScript is not much different from one in JavaScript structure wise. The biggest difference might be the explicit work on types and modeling your problem to make good use of composite types. In the source code you'll have some type definitions where implementation and usage sit close to each other (to enforce a local implementation), and others where a type is more like a serializable DTO (data transfer object) between different domains and seen more global throughout your application. You'll get a feeling when mapped types should alter a type or when a local type definition might be better (TS is structurally typed for a reason).
Domain modeling can feel close to "type driven modeling" here. A good book in that regard is "Domain Modeling Made Functional"[0]. I see types and a functional paradigm closely related, but keep in mind that this is just one approach in your toolbox... there might be the case where a GoF OOP pattern works good as well[1]. I think it's also important not to try to trick the TS compiler into something, but rather to work with it. Keep in mind that the TS dev team is giving you a lot of freedom by not striving for a provable correct type system[2].
To really take advantage of TypeScript I think it's good to know where a type system is coming from, what it is that it's trying to solve and how it is doing that. I think it's helpful to have a look into other languages with a "strong" type system (Haskell[3], OCaml, rust) and see how they are doing it. Then you may get to see how Haskells phantom types will conflict with TypeScripts type inference, and OCamls type inference seems to work in fascinating ways compared to TypeScript. After working through the advanced types[4] in TypeScript it's good to understand what a "good abstraction" in case of a type system is and what isn't... this is when you discover the similarities to other languages through the common language of abstract mathematics (and abstract data types). In every program you'll encounter effects and monads are quite helpful to work with them, this is were a sound type system can really shine.
I feel with every JS/TS project you will build a lot of the projects toolchain yourself and you kind of need to discover what fits best. It's good to be able to catch possible bugs early with the TS compiler, quicktype[5] can help you in building some typed contracts to other projects.
A separation into packages with lerna[6] should encourage a good separation into packages and is seen in a lot of open source projects. Speaking of, reading into good open source packages will be a mandatory way to go in order to learn more.
I have avoided yield() and generators like the plague because they're hard to read and I've never seen them used except in examples explaining how they work. Yield feels like recursion - a neat trick for some corner cases but generally unnecessary.
JavaScript syntax for generators is clunky no doubt. But they let you do some things more naturally than anything else in JavaScript. They keep track of state "implicitly" you don't have to do an assignment to 'save a state", you just yield and your state is remembered.
I found generators useful for implementing my home-brew parsers. Parsers must try out all possible combinations of possible syntactic elements before they can say that parse failed. Generators are a good tool for that
This is how async/await is implemented. I think 'await' is almost just a synonym for yield. I didn't invent that part. I just made a faster, better encapsulated, promise free version.
So generators are used here because of the natural way of calling “next” and yielding a result.
How would this work for say, an XMLHttpRequest? Since you have to next into callbacks there I don’t think yield travels the function boundary...so you abuse next instead?
Wow I haven't used that directly in a long time. Ideally you would wrap it to be in continuation passing style.
This would look something like:
function fetchUrl(url,done){
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 400)) {
done(null,xhr.responseText);
}else{
done(new Error("something went wrong"))
}
}
}
xhr.open('GET', url, true);
xhr.send(null);
}
Then you could do:
let response=yield fetchUrl('http://example.com',next);
edit: In case this doesn't really answer the question: If you really don't want to wrap, it would work inline too. It would just be harder to read and follow:
var someFunction =casync(function*(url,next){
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 400)) {
next(null,xhr.responseText);
}else{
next(new Error("something went wrong"))
}
}
}
xhr.open('GET', url, true);
var response = yield xhr.send(null);
...
});
For those interested--Besides this book, my current learning plan includes: Javascript 30 by WesBos Exploring ES6 [http://exploringjs.com/es6/] Learning React-2nd Edition on O'Reilly Learning The Beginners Guide to React on Egghead Data Structures and Algorithms in JavaScript on Egghead.
I also used Kent C. Dodds' excellent "JavaScript to Know for React" article as an outline.
My measure of success is being able to understand development at a lower-level. Learning new languages, frameworks and building side projects helps me through the low periods and enables me to work more fluently with developers.
I have experience with Javascript and VueJS from a couple of years ago, so my goal is to catch up with modern JS (ES6+), brush up my JS core knowledge (not just frameworks) and learn ReactJS. It's very likely that I won't finish everything on my list this month, due to other obligations, but that's ok. I'm not competing with the experts out there, I just want to learn new skills and build things that I couldn't before. I also have a bit more time now that I'm stuck at home on evenings and weekends.
https://kentcdodds.com/blog/usememo-and-usecallback
Granted that's probably because on a good day my reading comprehension is not great and learning within a narrative works way better for me.
Then I learnt that prototypal inheritance is a superset of ''class''ical inheritance [1] as well as this [2]. Hmm.
With Reflect, Proxy etc. you have great metaprogramming capabilities that make this language much powerful.
Still, there are some (many?) edge/corner cases and unfixable bugs (aka features) that the language is stuck with for the sake of backwards compatibility and developers have to learn these. (The most famous of these might be typeof null === "object")
When I look at the amount of features added to the language specification, sometimes it seems like it is going to become another incarnation of the C++ specification.
I still like its expressiveness and power, but if it becomes another C++ in future, I have to look somewhere else. (TypeScript maybe.)
[1]: https://aaditmshah.github.io/why-prototypal-inheritance-matt... [2]: https://wiki.c2.com/?ClosuresAndObjectsAreEquivalent and https://www.crockford.com/javascript/private.html
Those requirements are chosen because they lead to ease of implementation: prototype objects are the quickest and dirtiest way to enhance an interpreter such that programs can be written in it that are discernibly OOP-ish.
They don't represent a set of requirements that amount to a good OOP system.
[1]: https://justjavascript.com/
Reading into specs (ECMAScript[0], W3C[1]), some more approachable explanations[2] of them and some implementations[3, 4] of embedded engines seem to be my approach.
[0]: https://tc39.es/ecma262/2020/ [1]: https://github.com/w3c [2]: http://dmitrysoshnikov.com/ecmascript/javascript-the-core-2n... [3]: https://bellard.org/quickjs/ [4]: https://v8.dev/docs/embed
[1] https://leanpub.com/javascriptallongesix/read
You're going to have to look for talks and really technical posts. Consider whitepapers and source code for JavaScript engines at this point. You'll probably want to start reading up on the things attached to JavaScript, rather than the language itself. Browser rendering, event loop, V8 things, garbage collection, etc.
I'm sure you've seen it, but things like this: https://www.youtube.com/watch?v=8aGhZQkoFbQ, and this: https://www.youtube.com/watch?v=SmE4OwHztCc
It might be time for you to start writing what you know about JavaScript.
Also Typescript is well worth learning.
https://es5.github.io/
https://www.youtube.com/watch?v=byNwCHc_IIM
(you can buy a hard copy of it if you want but it's open source)
https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/READM...
Knowing the internals of the engine really informs you on performance and resource utilization characteristics of various ways of writing code.
If you really want to go all out, you could write a simple JS interpreter. Probably don't want to go full spec compliant but you could implement a decent subset. Especially if you skip the parsing step with Acorn https://github.com/acornjs/acorn
on edit: one reason the specs are not enough is generally specs will tell you what needs to be implemented but a good book, like these ones, will tell you how it has been implemented or what the spec implies for implementation and what all that will mean for you as a user of the language.
when you're done, you'd have learnt enough on the way and know what you don't know
It's not very clear what you are asking, neither what's your background. In your situation I wouldn't spend more time learning stuff about JavaScript, I would just improve my skills in software engineering (design patterns, code quality, refactoring, etc) and diversify my knowledge (learn other languages (python, go, or some FP language to learn something really different); databases and SQL; web servers and REST; etc).
Also the You Don't Know JS series. And Elliot's Programming Javascript Applications.
I don't know you, so I don't know if this applies or not, but be careful not to fall into the "expert beginner" trap (i.e. Dunning Kruger). Your first sentence starts to feel that way, but the fact you're asking for more resources and aware there are things you don't know are good signs. Always keep learning, the rabbit hole goes ever deeper.
There's knowledge about how to express certain patterns in a given language, more like an application design expertise. There's knowledge and familiarity with the APIs. And then there's the deep language knowledge, the one that pretty much only someone implementing a language VM, parser, compiler and other tools may acquire with time. Also, there are a lot of specifics about every particular JS implementation.
Also, Dunning–Kruger :-)
On the internals of VMs, https://mrale.ph/ has a lot of blog posts on internals/optimizations on V8. https://www.wingolog.org/tags/javascript also has deep JS articles very freqently.
Little things like this I am nit-picky about, but overall, great book.
[0] https://eloquentjavascript.net/05_higher_order.html#h_fx3e34...
I now program JS for a living so i guess the book also really worked. Thank you for the third edition!
> This much anticipated and thoroughly revised third edition of Eloquent JavaScript dives deep into the JavaScript language to show you how to write beautiful, effective code. It has been updated to reflect the current state of Java¬Script and web browsers and includes brand-new material on features like class notation, arrow functions, iterators, async functions, template strings, and block scope. A host of new exercises have also been added to test your skills and keep you on track.
For example, a book that could go into details of code practices at companies like Airbnb, Facebook, or Google.
However, for those looking for a great way to learn Typescript from a beginner's perspective I can fully recommend Execute Program[1].
[1]: https://www.executeprogram.com/
I would be particularly interested in this. The OP has a chapter on "Program Structure" but it seems like more a toolbox of language constructs.
It would be nice to see a book that went through a few archetypes of common JavaScript programs (command-line script, daemon, enhanced webpage, single-page app) and gave a basic blueprint for what parts are needed and how they interact.
https://effectivetypescript.com
Domain modeling can feel close to "type driven modeling" here. A good book in that regard is "Domain Modeling Made Functional"[0]. I see types and a functional paradigm closely related, but keep in mind that this is just one approach in your toolbox... there might be the case where a GoF OOP pattern works good as well[1]. I think it's also important not to try to trick the TS compiler into something, but rather to work with it. Keep in mind that the TS dev team is giving you a lot of freedom by not striving for a provable correct type system[2].
To really take advantage of TypeScript I think it's good to know where a type system is coming from, what it is that it's trying to solve and how it is doing that. I think it's helpful to have a look into other languages with a "strong" type system (Haskell[3], OCaml, rust) and see how they are doing it. Then you may get to see how Haskells phantom types will conflict with TypeScripts type inference, and OCamls type inference seems to work in fascinating ways compared to TypeScript. After working through the advanced types[4] in TypeScript it's good to understand what a "good abstraction" in case of a type system is and what isn't... this is when you discover the similarities to other languages through the common language of abstract mathematics (and abstract data types). In every program you'll encounter effects and monads are quite helpful to work with them, this is were a sound type system can really shine.
I feel with every JS/TS project you will build a lot of the projects toolchain yourself and you kind of need to discover what fits best. It's good to be able to catch possible bugs early with the TS compiler, quicktype[5] can help you in building some typed contracts to other projects.
A separation into packages with lerna[6] should encourage a good separation into packages and is seen in a lot of open source projects. Speaking of, reading into good open source packages will be a mandatory way to go in order to learn more.
[0] https://fsharpforfunandprofit.com/books/ [1] http://loredanacirstea.github.io/es6-design-patterns/ [2] https://github.com/Microsoft/TypeScript/wiki/TypeScript-Desi... [3] http://learnyouahaskell.com/ (a bit dated though) [4] https://www.typescriptlang.org/docs/handbook/advanced-types.... [5] https://quicktype.io/ [6] https://lerna.js.org/
https://github.com/bessiambre/casync
I found generators useful for implementing my home-brew parsers. Parsers must try out all possible combinations of possible syntactic elements before they can say that parse failed. Generators are a good tool for that
How would this work for say, an XMLHttpRequest? Since you have to next into callbacks there I don’t think yield travels the function boundary...so you abuse next instead?
This would look something like:
Then you could do: edit: In case this doesn't really answer the question: If you really don't want to wrap, it would work inline too. It would just be harder to read and follow: