The benefits of backward compatibility
These are benefits of staying backward compatible:
- It is trivially easy to migrate to new language versions. For example, all old code was already compatible with ES6 when it came out.
- Only ES modules are relatively difficult to adopt – but they kind of do break backward compatibility.
- It avoids versioned code. If you allow some code to be “old” and some code to be “new”:
- Language engines and tools become more complicated.
- Programmers need to be aware of versions.
- You can’t move code around, anymore (if a code base is mixed).
- Teaching and learning: you can mostly ignore old features, apart from what they look like and – roughly – what they do.
- Let linters help you with using the language properly.
- Let Prettier help you with formatting source code properly.
function. Use only arrows and method definitions. Benefit: handling
this becomes much simpler (details).
- Promises. Use only async functions. Learn what to watch out for (you can’t ignore Promises as completely as
- Iterating over objects. Use Maps, instead.
for-in (avoid always),
for (avoid if you can). Use
arguments. Use rest parameters (
Function.prototype.apply(). Use the spread operator (
- Constructor functions. Use classes, instead.
- IIFEs. Use blocks, instead.
instanceof is too complicated. This blog post describes a library for simplifying things.