Two Reaason To Use TypeScript?
TypeScript adds type checking to JavaScript, which can help you catch errors early and improve the quality of your code.
Why TypeScript?
Reason 1: Type checking: TypeScript adds type checking to JavaScript, which can help you catch errors early and improve the quality of your code.
Reason 2: Backward compatibility: TypeScript is fully compatible with JavaScript, so you can use your existing JavaScript code without any changes.
History
TypeScript was created by Microsoft in 2012.
TypeScript was released as open source in 2014.
Let me tell you little history of JavaScript -> there are some bugs and issues which are left when JavaScript (initially named Mocha) was created in 1995 by the company Sun MicroSystem for their web browser NetScape Navigator (very famous at that time, like Google Chrome is now). They tried to remove a lot of them in the version ES6 (ECMAScript6) [do you know why they call it ECMAScript and not JavaScript officially? If not, try to find out]. Sun MicroSystem’s main business was to sell hardware, later they got into the soware business too.
Q - Why did they created JavaScript in the first place?
Ans - Suppose you created a form in HTML and the user entered the wrong email (without @ in email) and pressed the submit button. Now this data will go to the server where backend code is running and it will check that @ in email is missing and send an error message to the user “Invalid Email Sent”.
Now Suppose the backend server is in California, US and the user is filling the form in Noida, India. So,
- First the request travelled from Noida to California, US.
- Then a response came back from California about “Invalid email” to Noida,
India.
The above two steps in computer terminology is called round-trip time. So 1 round-trip time is wasted if the user types incorrect email, phone number etc.
I took the example of only 1 user and now you can scale it up to 1000 of users if a website is used by 1000 users in Noida, India.
So, Brendan Eich who at that time worked at Sun MicroSystem thought why not make these checks at the user machine itself and we can save this round trip-time => And thus JavaScript is born,
Under: #tech , #javascript , #course