Why ES6 is an excellent language to kick-start your programming career.

Hai Le Gia
8 min readApr 11, 2019
Image by Gerd Altmann from Pixabay, edited.

I want to teach people to code. Some colleagues say I’m good at teaching, and I love it, too. So I’ve decided to build a website to do just that. However, I need to answer a question first, “What programming language should I choose to teach people?” It turns out to be a tough question.

I do have several choices. Java, Golang, and Python are my everyday languages. I don’t work that much with front-end web development, but I can use ES6, Typescript fluently. Also, I don’t believe in a “God language” as others might subscribe to. It was already a language war in my mind until I told myself to go back to the basics and rethink the question — “What language would bring the most benefits to my students? Assuming they don’t know anything about programming.” This article’s title already gives you a short answer. However, I don’t want you to read just that. As Steve Jobs once said, “the journey is the reward.” Let’s begin.

What is ES6?

As you know, our modern browsers can do many things, from beautiful animations, effects, to real-time multiplayer games, or even stealing your privacy, 😈. But everything was not that great at the beginning. The web used to be dull, with static texts (and some images). It was only until 1995, thanks to Brendan Eich that we have Javascript, the language that makes our web so vibrant. Javascript get standardized, and we have ECMAScript (ES). Fast forward 20 years, and we have ES6 (ECMAScript 2015) — a modern programming language that can be used almost everywhere, from website development to back-end services. This ubiquitous trait is why ES6 a great choice to start. There are still more reasons to convince you of.

You may already have an interactive shell to learn ES6

What is an interactive shell? I even have a nerdier word for it, a REPL (Read–eval–print loop) shell. You can think of it as a magic board that understands all the formulae you write, evaluates them, and then shows you the results. An interactive shell is useful to try out concepts quickly. Text editors or IDE (integrated development environment) are what you need to build programs, but they’re too slow to test a code snippet.

So, where is your magic board? Try right-clicking anywhere on this Medium website. If you’re using Chrome, you will see a context menu similar to the image below, click Inspect (for Firefox, it’s Inspect Element):

Context menu to open your interactive shell

I would expect you to see a new section like this on the right or bottom of your browser:

Inspect window

Now click on the tab Console to access your shell. From here, let’s type in your first spell as below and press Enter.

'The answer to the ultimate question of life, the universe and everything is ' + (6 * 7)

We just asked our interactive shell to multiply two numbers, append the result to the end of the text “The answer to the ultimate question of life, the universe, and everything is ” then print it. Feel free to try some other expressions as you like.

The first line of code.

You can learn object-oriented programming (OOP) with ES6

If you want to land a developer job, you better know OOP concepts and know them well. Typically, you would get asked about SOLID principles at the beginning of interviews. If everything goes well, the next questions are usually related to design patterns. Believe it or not, many candidates get rejected just because they failed these very fundamental questions.

Why is OOP fundamental so important? I won’t explain the OOP concepts here because they deserve their separate post. If you’re a newbie to programming, just imagine that building software is similar to building houses or roads or bridge. We’ll need paradigms, standardizations to make sure what we build are reliable, maintainable and extensible. In the world of software, OOP is one of the paradigms that all good developers should know. You are no exception.

In the old days, web developers need to use Javascript’s prototype to implement some OOP concepts, and this approach is unique on its own. You cannot see this anywhere else. Our new ES6 now uses similar OOP structures like most other OOP languages (Java, C++, C#…). For example, now you can define classes and extend them. Let’s try one example on your interactive shell:

By extending Pet, our Cat andDog can speak, which is defined only in Pet. Your shell now should look like this:

Simple OOP inheritance

You can learn functional programming with ES6

Image by PublicDomainPictures from Pixabay, edited.

Nowadays, Functional Programming (FP) is one of the hottest topics, just runner-up to Machine Learning. Consider this: Java, one of the most used, pure OOP languages, has been supported FP since 2014 with Java 8. However, FP is nothing new. We can trace its origin back to 1977 (yes, this is not a typo), when a distinguished computer scientist, John Backus gave a lecture named “Can Programming Be Liberated from the von Neumann Style? A Functional Style and Its Algebra of Program”. And yet only until recent years, developers and big companies start to use FP to build software. So, why now? There are many hypotheses for this, but I think 2 biggest reasons are:

  1. Our software is becoming more complex; using FP declarative style can make the code concise. Less code means fewer bugs in the program.
  2. The rise of distributed systems and parallel computing: FP favors immutability. This property makes it easier for developers to reason why their code works correctly. This sounds funny but it’s true. Sometimes, we don’t know why our programs show us the correct output.

Because ES6 supports FP, you won’t have to worry about missing the train. Let me show you an example illustrating conciseness of FP, okay? Assuming you have a list of numbers stored in an array and you want to print all the odd numbers. There are at least 2 ways to do this:

Traditional way

let a = [1, 2, 3, 4, 5, 6, 7];
for (let item of a) {
if (item % 2 === 1) {
console.log(item);
}
}

FP way

let a = [1, 2, 3, 4, 5, 6, 7];
a
.filter(item => item % 2 === 1)
.forEach(item => console.log(item));

Don’t worry if you don’t understand the code. The main point is, in most cases, FP declarative approach is more concise than the traditional imperative way.

You can pick up almost any languages after learning ES6

As a developer myself, extensibility is what I want. Don’t lock or limit yourself into one thing. This principle is not only applied to my code but it also affects almost any decisions I make. Could I do more if I choose this approach/product/framework over others? If the answer is “No”, I’ll try to find a different candidate, repeat the process until I get the best one I can find.

However, before I show you how similar ES6 is to other languages, let’s make one thing clear. Learning a programming language is not only about learning its syntax, control structures, but also its frameworks, libraries. If someone tells you that they’ve learned Java in the weekend, this means they can write a simple Java program. For some best people, they can even use Java for Google Code Jam after this. But they won’t be able to use the Spring framework to build a backend service. There is an exception though, Barry Allen. I’m quite sure The Flash can learn all Java frameworks in a weekend if he really wants to. For the rest of us, let’s not be deceived by the similarities of languages. Cool, now let’s see how other languages would implement our Pet above:

Java

Python

You can use ES6 in many places

I save the best for last. Let’s face it, we all need money in life. Our efforts need to convert to tangible or intangible assets. No matter what you did, they must have some purposes, right? In this case, you may want to land a new job as a developer. There are so many job titles on LinkedIn right now that sometimes I don’t even know what they are about. However, as a developer, mostly you are either (or all) a:

  • Front-end web developer: Build all the fancy UIs to interact with people on browsers.
  • Mobile App developer: Yep, build mobile applications running on your smartphones.
  • Game developer: Hey, who doesn’t love games?
  • Backend developer: Implement the business logic, data storage for the guys above.

There are a lot more, but in this article, we’ll only cover the basics. The good news is, ES6 is being used in all the above areas. Is that cool? Learn this one language and you can:

  • Use any web frameworks (Angular, React…) to build blogs, e-commerce websites…
  • Use React Native or Ionic to build apps that run across platforms.
  • Build games with Phaser (for smartphones, too).
  • Develop back-end services with NodeJS (one of the most popular runtimes).

Conclusion

Thanks a lot if you’re still reading. I know it’s a long article so let’s try to put everything into a summary. You should choose ES6 if you want to start a career being a developer. It’s a modern language that allows you to build strong fundamental in both OOP and FP programming. Once you have this nailed, you can learn any languages you want. Last but most important point, you will have all the options to pursue, from Web front-end, mobile apps to back-end services, even becoming an indie game developer. You choose.

I would like to thank Gwen Wong for her constructive comments on the manuscript of this article.

--

--