Why am I NOT a fan of TypeScript

TypeScript

TypeScript is slower than JS, in simple iteration, the difference is only a few percent but when it comes to more complex ones, it is quite enormous. The reason comes from TS’s structure, which is transpired to JS (plus additional coating). Check efficiency here!

Personally, I think most important is the efficiency of the code and how to optimize it, comfort and speed of writing code come second. Especially in long-term projects that are supposed to work for a few years. Why is it so important? Because if we will not have enough computing power in vertical scaling (more and more powerful machine), we have to transfer to horizontal scaling (cloud hosting, clustering, etc.). The price of rewriting the 1-instance application to a cluster one may exceed 100% of the project’s cost. Additionally, the price of adding a new machine is not proportional to the growth of profits and a firm has to decide on losses associated with scaling or has to limit access to the service and stop the progress. Progress is a basic rule of every firm (without it the firm will die in the span of 5 years). Hence it is better to choose a quick language and write a code 2 times longer (one-time cost) than paying triple for hosting every month.

There is another issue

The security of typing. I mentioned this, a few times already, typing works only within our code. The problem is data coming to our app from the outside – either 3rd party API or from a user. Us typing some kind of variable to string does not mean the app will check by itself the type of a variable after transpiring. If we will not write code that will check variable type the app will show errors, the same goes for JS. Two real-life examples – outside API changes its structure daily, without updating to a newer version (existing endpoints change, unfortunately, it happens sometimes). If we will not write in a TS/JS code to check what kind we get will not get the app to work. The second one, the communication between Frontend and Backend. We made a joint interface for data exchange (ex. Email/password - 2 strings), In TS everything compiles in frontend and backend, but we did not type in a line to check the type and instead of strings we send objects. Bam backend error.

Retranspiling the code

Every change in the code means compiling the whole application, it takes only a few seconds, but during 8 hours of work we have to compile code about 300 times, we lose 15 to 30 minutes of waiting. And what if we have a serious error in code and we have to quickly fix production? When it comes to JS you can fix it in Git, throw it to the server, restart only one service, and if something is very urgent, we can change it directly on the server and do a quick restart - in an ideal world, this should not be done, but practice looks bit different. I personally fixed bugs in production versions this way many times. In TS we cannot directly edit code, we have to edit the source and compile it, which takes a lot of time. If we do not know if the change will help, we lose once again, a lot of time, and production is halted.

Typing is just great

But only if it is natively built-in into the language (Java, Rust). When it comes to transpiling code we are in deep shit. Additionally, I think best is the flexible languages, you type if you want, not because you have to. Deno is a promising option, a new baby from the creators of Node. In Deno, we have a natively built-in compiler TypeScript. We code in TS and the virtual machine transpile the code to Rust. No problems with efficiency unlike TS to JS to V8. Unfortunately, Deno is a starting project and we cannot be sure If we will one day see a stable version.

Afterthought, half in jest half-seriously, if you need typing because you are getting lost in code, you are not a programmer you are a dumb-dumb 😛

Content

Got a project?

Let's talk!

__wf_zastrzeżone_dziedziczyć
AI
Secure AI - Advantages
arrow icon
7.12.2024
2 min read
Technologies
What is AWS?
arrow icon
4.1.2024
2 min read
Technologies
What is HTML?
arrow icon
3.21.2024
2 min read
Technologies
What is TypeScript?
arrow icon
3.20.2024
3 min read
Technologies
What is PHP?
arrow icon
3.19.2024
1 min read
Technologies
What is Swift?
arrow icon
3.18.2024
5 min read
Technologies
What is Kotlin?
arrow icon
3.16.2024
4 min read
Technologies
What is JAVA?
arrow icon
3.13.2024
2 min read
Technologies
What is React Native?
arrow icon
3.13.2024
3 min read
Technologies
What is React.js?
arrow icon
3.13.2024
2 min read
Technologies
What is Node.js?
arrow icon
3.13.2024
1 min read
Technologies
What is JavaScript?
arrow icon
3.13.2024
1 min read
Knowledge hub
What is a fullstack developer?
arrow icon
3.13.2024
1 min read
Knowledge hub
What is frontend?
arrow icon
3.13.2024
2 min read
Knowledge hub
What is backend?
arrow icon
3.13.2024
2 min read
IT
How to get started in IT?
arrow icon
3.6.2023
7 min read
IT
WEB3 - What is it? Introduction
arrow icon
2.21.2023
4 min read
UX/UI
UX Design - a guide for programmers
arrow icon
1.18.2023
4 min read
Business
Team Augmentation- Benefits!
arrow icon
1.4.2023
11 min read
Business
How to choose a programming company?
arrow icon
12.22.2022
8 min read
IT
How do programmers test?
arrow icon
12.18.2022
2 min read
IT
How to find good programmers?
arrow icon
12.15.2022
4 min read
Startup
What is a startup?
arrow icon
12.7.2022
7 min read
Code
Rust is the future of Server Side
arrow icon
12.1.2022
1 min read
IT
How to make a mobile app?
arrow icon
11.30.2022
5 min read
Business
How to work in various time zones?
arrow icon
11.27.2022
7 min read
Business
Where to Invest money in 2021?
arrow icon
10.31.2022
4 min read
IT
IT outsourcing – what is it?
arrow icon
10.25.2022
4 min read
Code
React Basics - State and useState
arrow icon
10.18.2022
5 min read