ES2015
If you haven’t already noticed, I haven’t touched on any futuristic javascript concepts or features in the history of the blog. And if I did… well, oops. I’ve been deliberately sticking to learning and advocating for the javascript stuff that you can do in-browser without a whole lot of fuss.
The “futuristic” part of javascript I’m talking about is called ES2015, or “ECMAScript 2015” or “ES6”. ES2015 is the direction that the ECMA-262 specification is going that will enable new features, syntax, and revolutionize code possibilities. Javascript as a language has been sitting mostly still for a while after the release of ES5, and it hasn’t had any devastating shake-ups that truly make the way we program easier or different. That changes with ES2015.
I love it, but at the same time I hate it. I love it because it finally feels like we’re really dancing on the apex of the javascript hype-train. I hate it because it’s so pervasive in our programming culture. It’s absolutely useful, but I think people would be better off using ES2015 alongside their well-rounded vanilla javascript knowledge.
ES2015 brings a whole new set of features to the table, including, but not limited to:
- Default parameters
function hello(name = "John") {
}
- Object destructuring
const traits = {
name: "Bradley",
eyes: "Blue",
dope: true
}
const {name} = traits;
name; //=> "Bradley"
- New variable keywords
letandconst
const constant = 5;
let changes = "hello"
- “fat-arrow” syntax
[1, 2, 3].map( (number) => {
return number * 2;
});
// or
[1, 2, 3].map( number => number * 2 );
- Additional data structures (
Map,Set) - New data type:
Symbol - Lexical scoping
- And much, much more!
This is great! These features mean we’re finally hitting our stride as javascripters! Except we can’t really write this new code in any of our current javascript unless we compile the “futuristic” javascript back into native, present-day javascript with something like babel, buble, or another build-step tool.
This is fine, and there are plenty of tools that will allow for this, but this is also where people start taking things for granted. I recently saw a question in Reddit’s learn javascript subreddit where someone suggested eschewing today’s javascript for the future.
“Oh hey dude it turns out your problem actually isn’t a problem with ES2015 just switch over and you won’t have this problem.”
Slow down, dude. This is where I have a problem. People are advocating the usage of ES2015 across the board,which is contributing to this idea of “Oh switch over here and you won’t have that problem” while the problem is perfectly valid, understandable, and able to be fixed in the javascript of today. While this wouldn’t be a bad thing if everyone in the world knew javascript, it pushed novices to automatically familiarize themselves with monolithic tooling and frameworks that they can’t fully understand in the first place.
The cognitive overload becomes incredibly frustrating.
Now, I’m not saying ES2015 isn’t great, because it is. but do you know why it’s great for me?
…because I already know how to program in javascript.
ES2015 is great at solving these problems that I already have the answers to, it makes my job as a knowledgeable programmer easier because I have a grasp on the various pitfalls that exist in this language. If you stick a person trying to learn javascript in this environment, you’re not teaching them javascript, you’re teaching them a language that looks like javascript and compiles down into javascript.
That’s not giving them a solid foundation. That’s giving them the apparatus to run before they even know how their legs work.
What happens if the team they join in their next career step doesn’t use ES2015 tooling? Suddenly they suffer as a result of not understanding closures, or how scoping works in javascript. They might not even know how default params are set in ES5, making their code slightly “if”-fier, and definitely uglier.
I’m not saying that it’s bad to learn ES2015, because it’s not. I’m saying it’s bad to learn ES2015 if you haven’t bothered to learn javascript as it lives and breathes today. Having a solid foundation is what’s going to make you a better programmer. It’s going to enable you to learn these new technologies as they come out and make your job easier because you bothered to learn javascript!
In fact, I know a few people who would much rather hire you if you were a competent javascripter than if you were knowledgeable about how ES6 syntax works.
Focus on the fundamentals, because they always have, and they always will get you the most mileage. Wowza this was a rant.
Happy Coding!