JavaScript in 10 Days: Day 5
Today’s plan is, again, to make more progress on Atencio.
The absorption rate of information in a new domain falls off after a certain point without internalizing what’s already been seen. So I think it makes more sense to skim Atencio faster, just to have mental markers for topics and key concepts that can be revisited later. And spend time writing more code. That was a good lesson from the Recurse Center – when in doubt, write code.
Day 5 Talks / Articles
Eric Elliott, The Missing Intro to React
A concise and clear intro to React. The basic philsophy of continously updating and re-rendering pure state for consistency gurantees seems very similar to Elm!
JoJ
Chapter 7 Hooked on Metaprogramming
- symbols: unique value maintained by JS (unique regardless of the description provided at construction)
- symbols are copied by reference, not value
- local and global symbol registries (
Symbol.for
and Symbol.keyFor` for global) - statically defined global symbols (e.g.
Symbol.toStringTag
) - JS reflection APIs allow creation of custom decorators
Chapter 9: Linear Async Flows
- single-threaded architecture
- promise – similar to a task, runs in executor and managed by the event loop
- a promise is either fulfilled or rejected
- promises have identity and composition
- There are promise combinators:
promise.all
andpromise.race
- async / await is a different repreentation of promises (similar to Python
asyncio
) - async iterators – iterate through objects, emitting data asynchronously
Chapter 9 Streams Programming
- iterables – also covered in Eloquent Javascript chapter
- generators – denoted by
*
symbol after function name or before method name - async generators: yields promises, use
for await....of
to ocnsume - a stream is sequent of one or more events (which can be infinite), handled by a subscriber
- node has a stream library as part of
fs
module: https://nodejs.org/api/stream.html - observables
JoJ Code
None.
Other Code
None.
Wrapping Up
Today was a short day given real-world time constraints. As I set out to do at the start of day, I skimmed the rest of Atencio to get a sense of the contents of the remainder of the book, for future reference. The salient takeaways are that, at ~26 years old, JavaScript is a complex and dynamically evolving language. Compared to, say, Elm, the language spec is large and complex, adn the ecosystem is also meaningfully larger. With so many ways to solve problems, it really pays to have a fundamental understanding of what tools are best for which situations.
At the halfway point, I still don’t know much JS, but I feel somewhat better equipped to look for answers when I inevitably get stuck writing code. Since I don’t have a project in mind yet, my current plan is to tackle some of the larger exercises in the Eloquent Javascript book, probably in TypeScript. (So far, writing in TypeScript has presented its own problems as I’m not familiar with the type system. On the other hand, the type checker has helped point out problems that the JS tools have been silent about. The compiler has also been quite responsive, like Elm’s, but I’ve only written trivially short code.)
Todo / To Read
- More chapters of Atencio
- Eloquent JavaScript has exercises at the end of chapters, which might be worth exploring
- Figure out how to use
outDir
(?) to compile.js
files to separate subdirectory - Compiling with both TypeScript with Babel
- Kyle Simpson, You Don’t Know JS
- Composing Software, by Eric Elliott (https:// leanpub.com/composingsoftware)