Kyle Simpson says:
Whenever there's a divergence between what your brain thinks is happening, and what the computer does, that's where bugs enter code
In particular, if you've ever wondered:
- What exactly is the difference between
===? (hint: if you think that
==doesn't check the types, you are mistaken!)
- Why were
constintroduced and what do they actually do that's different to
- What's the difference between a function declaration and function expression? What is this "hoisting" you keep seeing?
- Where should you use arrow functions and where should you avoid them?
- Should you use
this? Or should you architecture your code to avoid using it?
- How are classes implemented with prototypes? And what's a prototype anyway?
This series will hopefully prove useful.
Most other popular languages of the past twenty something years can't boast the same claim. Python programs written in say 2005 would have been written in Python 2, and they would need to be ported to Python 3 (which is not backwards compatible with Python 2) to continue working today. The PHP folks similarly went through huge pains going from PHP 5 to PHP 6 (which was abandoned) and now PHP 7. Perl 6 similarly diverged from Perl 5 so much that the people behind it decided to spin it off as a different programming language. This is not to disparage these programming communities. Breaking backwards compatibility has huge benefits: it allows the language designers to clear out the bad parts of a language, or to re-architect it to move with the times.
- Primitive Types
- Abstract Operations
- Statically typed supersets e.g., TypeScript
- Nested Scope
Each section will end with a practice exercise to solidify the topics covered in the post. In the latter sections, we will develop a library checkout system and implement the same program using various different structures: using functions, modules, classes and prototypes. This will enable us to clearly see the pros and cons of each, and where each structure might be preferred.