There was an old trick used by Angular and a few other libraries of using a function’s source code (which you can get using
.toString()) to get its argument names. Promisify-node used this technique to find arguments called
cb. Angular uses it for dependency injection, though there are other better ways of doing that.
We’ll start by laying out our code. I’ll be using closures, but you could — and my first version did — use a class instead. We’ll need a
parse_html function, inside we’ll put a helper function called
pull and a
parse_content function which we’ll fill in later.
If you’d like to follow along, the finished code is here: https://github.com/evan-brass/regex-html
The cursor will be a reference to a node in our DOM tree. Tag nodes will have a tag property for their name, an…
I’m excited about template elements. There’s no specified way of instantiating them, so let’s talk about where they come from, why we use them, and how to instantiate them.
Most likely, you won’t write them by hand. Instead, they’ll be generated from template literals, JSX, or something else. These generators will have to deal with template instantiation. By using template elements, these generators share the efficiency of using the built-in parser and cloning DOM sub-trees.
Where they will likely differ is in how they do reactivity. Template elements are a low level primitive and so low-level element access should be…
A great solution is type annotations. You probably know about TypeScript and Flow already, so I’ll just be mentioning pieces…
I’m a big believer in distributed systems. It is easy to see the need for distributed systems when we see the existing digital infrastructure being tested by COVID-19 levels of load. Unfortunately, distributing a system is not usually a simple task. Consistency no longer comes naturally and horizontal scaling is difficult. Distributing a system requires careful thought. It can be worthwhile though.
There are at least three desirable properties that distributed web apps can achieve:
Writing correct software is hard. Whether you’re using functional programming or finite state machines, understanding the problem you’re solving and understanding your code are both required for correctness. Async functions and generators are stateful syntax for which we can draw state diagrams so that we can understand them. If you know how to break your problem down into a finite state machine then this will show you one way of implementing it as well. Deciding whether doing so would be ergonomic for you and meet your requirements is something you will hopefully be able to do by the end. …
The Boolean is a data type with two values, True and False. Boolean’s are a core component of logic. Logic spreads over both math and philosophy. Logic — implemented by electrical components — is what…
How do you get started programming? You press control+shift+i if your on Chrome, Firefox or Edge. To open the developer tools for Safari I Googled it for you: http://wickedlysmart.com/hfjsconsole/. This brings up the developer tools, your new home for the first section of this tutorial. Next you’ll want to navigate to the console. This is where we’ll be typing in expressions.
Then press enter. You should see a little message in the console with the sentence you entered. …
Introduction to Programming 1: Background
Programming has its roots in mathematics. Every (sane) programming language has an underlying model of computation. Those underlying models have been proven to have equal power, that is that anything which can be done in one can be done in another.
Computation can be described by different models and performed by different machines. For example, your brain right now, as it reads these words is performing computation. Each individual neuron is comprehensible. It has dendrites which are its inputs, and an axon which is its output. The spaces between axons and dendrites are called synapses…
I write a lot of ECMAScript… enough to have plenty of mistakes to learn from.