How Typescript made nodejs available to me again

I’ve tried NodeJs a long time ago, if you factor-in that less than a year is a long time in thechnology. Time to check back on the ecosystem.

As a disclaimer, must say that I never particularly liked Javascript for many reasons. I learned programming with C and for the longest time, C++ was my favorite language. And for that reason, I really like Java today because it’s everything that’s good about C++ minus the bad aspects you don’t necessary want to worry about most of the time, like memory management. So about 5 years ago I learned Java and never looked back at C++, and I didn’t feel the need to.

I’m  working on a project right now that requires full bi-directional communication with the requirement of being cross-platform. The old obvious answer to that would have been sockets, but nowadays isn’t the browser a platform by itself ?

So I decided to try websockets, and what easier way to write websocket code than with Javascript. But here’s the thing: I don’t like Javascript. That’s when I decided to learn Typescript.

 

Microsoft fixed NodeJS for me …

So Microsoft is behind TypeScript and one of the best code editors for the web, which is Visual Studio Code. When you know that Intellisense is without a doubt the most powerful code completion tool out there it’s worth checking out VSCode by itself.

And what a pleasant surprise ! Coming from Java, I like clean and straightforward object oriented programming, and that’s exactly what TypeScript is all about. So I decided to port my old Javascript HTTP Polling project to Javascript and websocket. So far it’s been a blast.

But the most exciting change for me is the fact that I no longer have to worry about “what’s in this ?”. Because in javascript a variable can reference anything, on runtime you essentially don’t know what you’re dealing with. So for example if you decide some reference is a string and you deal with it like a string, it could have been a number to start with, and Javascript will not cry about it. Coming from Java my brain can’t process this nonsense.

They said “Javascript that scales” and they’re right. Big organizations like Microsoft and Paypal are migrating full fledged backends. For Paypal, their old backend was in Java and Microsoft is probably using some kind of ASP.net … whatever their ecosystem name is. But when you have developers coming from these technologies, you either bring your frontend developers to the backend or you give backend developers a proper tool to work with. TypeScript was born. I don’t believe in the fullstack thing. Every single developer can call itself “fullstack”, that doesn’t mean they’re good at front/ux and at backend.

I suspect that if Netflix, Twitter, Amazon, Wallmart, are all moving towards NodeJS, TypeScript has something to do with that.

 

 

 

 

 

Stephen B

Développeur informatique passionné de numérique et de technologie au sens large du terme.