Yishai Landau
4 min readMay 20, 2019

--

How I Missed on the JavaScript Revolution While Programming in That Very Language Every Day

For the last few months I’ve been interviewing for several job openings looking for senior programmers, either in Python or in server-side JavaScript (NodeJS). I’ve been programming for the web since the late 90’s and carry with me a resume rich enough to get me to the interview room pretty easily.

This experience has lead me to a wide range of companies and people. There were places where I got the impression that I could be the one on the other side of the table, and I might be over-qualified for this specific role; and other places where I would be willing to give up on salary and perks just to join the team and be part of what they were doing.

But one interview sent me home with a sensation which was a mix of a slap in the face and a punch to the stomach. In a good way.

This was a JavaScript job — join an existing growing team. The requirements were a few years of JavaScript programming, and general programming knowledge. This should have been a walk in the park. Until I entered the room.

The interviewer started with what seemed to him as simple set of questions, but for me were a deep look into a mirror that expands on every single blemish I have. I realized that whatever I’ve been doing in the past 5 years in Web programming, building applications which I am very proud of — I was just scraping the surface of the JavaScript/ECMAScript revolution.

I’ve been reading the documentation of Node.js, and learning what has been changing between the releases; I have fully adopted the new variable handling (let/const instead of var), writing code using arrow functions, working with async/await on asynchronous functions, and following more or less the rules defined by the .eslint file I’ve placed in the root of my projects. I’ve worked very hard to master the functional programming nature of the language, and held a good understanding of it’s asynchronous behavior.

But, this was only scraping from the top of the ES6 barrel.

As I’ve been programming for the web for over a decade, my relationship with JavaScript was as it should be to a scripting language that was written in 10 days — use with caution, with very little trust. The changes in the language where welcome, and I learned and adopted them, but I never treated it in the same respect as Python or Java.

And that is what I missed out, and why I approached the interview with a very warped understanding of the technology.

I took a 2-week online course, and learned that what is known as ECMAScript is a layer on top of JavaScript that completely changes the nature of the foundation it’s lying on. It is now not only a very fast-processing language, easy to learn, cheap to implement — it is also keeping up with changes and additions other languages are implementing:

Java introduced the Three Dots:
class Example {
public void printNames(String… names) {
for (String name: names){
System.out.println(name);
}
}
public static void main(String[] args) {
String name1 = “Mike”;
String name2 = “Bob”;
String name3 = “Lucy”;
ThreeDots threeDots = new ThreeDots();
threeDots.printNames(name1, name2, name3);
}
}
So JavaScript has Rest and Spread operators:function spreadNames(...names) {
console.log('Printing out every name received');
names.forEach((name => console.log(name)));
}
spreadNames('Mike', 'Bob', 'Lisa', 'Mary');

const arr = ['Larry', 'John', 'Sally', 'Lucy'];
console.log('1st array: ', arr);
const arr2 = ['Oliver'];
console.log('2nd array', arr2);
const arr3 = [...arr2, ...arr];
console.log('combination of 2 arrays', arr3);
# Python Unpacking
data = ("Mike", "History", 85)
(name, subject, score) = data
print (name, subject, score) # Mike History 85
// JavaScript Desctructors
const arr = ['John', 'Smith', 'USA'];
const [firstName, lastName, Country] = arr;
console.log(firstName, lastName, Country); // John Smith USA
const
obj = { name: 'Mike', subject: 'History', score: 85 };
const { name, subject, score } = obj;
console.log(name, subject, score); // Mike History 85

And last but not least, a different approach from other languages: String formatting:

Python:birthYear = 1977
print("Hello, my name is %s, and I was born %s" % ("Yishai", "A long time ago" if birthYear < 1980 else "quite recently"))
Java:Calendar cal = Calendar.getInstance();
System.out.println(
String.format("Hello, and good %s to you", cal.HOUR < 12 ?
"morning" : "afternoon"));
JavaScript - takes the above and adds:const decorate = (strings, ...vars) => {
const boldVars = vars.map(oneVar => `<b>${oneVar}</b>`);
let returnString = '';
strings.forEach((str, idx) => {
returnString += `${str} ${boldVars[idx] || ''}`;
});
return returnString;
};

const str = 'String';
const formattedString = decorate`This String is being decorated with ${2 * 2} as a math equation, ${new Date().getHours()} as an hour variable, and then just a string: ${str}`;

console.log(formattedString);

The course explained a lot more changes and additions added to JavaScript, some of which I’ve been using without fully understanding, and some that were completely new to me. I still find the Class/Object handling a bit quirky, and miss Java/Python in those aspects, but I came out of that course with an understanding that JavaScript has evolved into a ‘real’ language that can stand tall and proud with any other programming language on the market.

Personally, I don’t know if I would choose JavaScript/Node as my back-end language for every project, But I have learned that it’s a language that is capable of anything its veteran competitors can do.

The biggest lesson I take with me from this story is to take time to stop every so often, and take a course in a certain language/framework. Take that course not as a means to solve a given problem, but with a desire to truly understand how this language/framework operates, what is the logic behind it, and how to best use it’s strengths while avoiding/overcoming it’s weaknesses.

--

--

Yishai Landau

API Architect; Apigee Expert; All-Around Programmer since 2000;