TypeScript -- why not?
Tags: typescript, javascript
Published: 2021-01-19 02:29:24

---
title: TypeScript -- why not? 
published: true
description: What I think about TypeScript.
tags: TypeScript, JavaScript
//cover_image: https://direct_url_to_image.jpg
---

I just recently watched https://www.udemy.com/course/typescript-for-javascript-developers , 

While watching it, I could not help but to keep thinking that something is wrong with me...

 Googling for "typescript is horrible" revealed a lot of links where people passionately bash TypeScript -- what a relief, it's not me after all. Apparently, there is a lot of controversy around TypeScript.


Watching this Udemy class finally convinced me -- TypeScript really does not solve any issues, it just makes things even more complicated. 


In discussions with peer software engineers it always comes up, that, in order to be proficient with more advanced JS concepts, you  need to learn the basics first -- to appreciate JS as a language, you have  to understand the "weird" prototype inheritance model, you must master the "bind" keyword  (ironically, most of JS developers lack these essentials), you need to know and understand ways to define classes with functions, you need to learn and understand functional concepts of JS, you do need to  know what ES6/7 brings on the table and why is that an improvement over ES5. 


In my career I come across two kinds of software engineers. First will learn few basic programming constructs and start to  use Copy/Paste design pattern all over the place, which tends to produce a lot of code really fast, which some times works, but eventually will crumble under its own weight. And the Second type will put effort in understanding basic computer science concepts (such as Object Oriented and Functional programming), will dig deep into how to implement these concepts in particular language (JS in our case), when to use one vs the other. I typically define the second type as a Lazy developer -- a developer who puts effort in coming up with the most elegant solution, a developer who spends more time in order to produce less code.


Good example of Lazy kind of developers is React core team. Every couple of years or so they completely change the underlying core of the framework. Around 2015 they started with basic JS Mixins, few years later  they invented Higher Order Components which was an amazing innovation at the time, to finally ditching all these cool techniques and going with good old JS  Hooks approach based on functions rather than on Class components. In a way, hooks feel like a step back. But there a huge reason behind why hooks are so great -- they have smaller foot print, which makes your code a lot more elegant and efficient.


TypeScript is an attempt to hide the JS ugliness, which is indeed a good  intent . But, guess what, all these JS  nuances are not going anywhere -- you really, really, really need to know how all that works at a lower level. While it's not that difficult to learn yet another syntax, you still have to maintain deep knowledge of  JS. To make best of TypeScript you still need to understand how it transpiles to JS. You don't have to,  but you really should. Been able to write  a lot of code faster in new syntax does not make you a better developer (does not make you a Lazy kind). 


It's not that I'm stubborn -- if anyone wants to convince me that TypeScript is the future, let me know. But for now, JS still holds a lot  for present.


Originally reposted from here: https://www.echowaves.com/post/typescript-why-not