TypeScript: The evolution of JavaScript

by Janeth Kent Date: 18-07-2020 javascript coding typescript

When you're involved in the development of a large project, programming languages like JavaScript don't seem to be the best solution. Their lack of elements such as Language Aids has created the need for code-friendly alternatives. Here we tell you about one of these options.

TypeScript, is a project developed and maintained by Microsoft (but don't worry, it's still Open Source). It arises from the need to make JavaScript a more robust programming language.

JavaScript is the de facto the lingua franca of the web. Its incredible flexibility means that this language is used in 96% of the 1.7 billion sites that populate the web today. So virtually any computing device (from a smartphone to a smart TV) is capable of processing a JavaScript instruction.

However, the nature of the language does not make it code-friendly when it comes to developing a large project. This is because JavaScript lacks elements such as Language Aids and automatic Refactors. This results in a 15% increase in system bugs.

 

A simple but effective solution

 

TypeScript is a superset of JavaScript , so it uses the same syntax and semantics known to all web developers. And, better yet, once the project is compiled, it is completely translated into the original JavaScript .

2012 was the year in which TypeScript appeared (after 2 years of development), a Microsoft solution for the development of applications with JavaScript on a large scale, for them and for their clients. Steve Lucco and a team of over 50 people including Anders Hejlsberg, Lead Architect of C# and creator of Delphi and Turbo Pascal developed TypeScript at Microsoft, a project that was originally known as Strada.

Originally, products such as Bing and Office 365 awakened in Microsoft the need for an improvement to JavaScript that would allow them to build scalable products.

TypeScript is the solution to many of the problems of JavaScript, it is designed for the development of robust applications, implementing features in the language that allow us to develop more advanced tools for application development.

 

Characteristics of this new language

 

As we have mentioned, TypeScript is a JavaScript superset. We can say that a technology is a superset of a programming language, when it can run programs from the technology, TypeScript in this case, and from the language it's superset of, JavaScript in this example. In short, this means that JavaScript programs are valid TypeScript programs, even though TypeScript is another programming language.

This decision was made at Microsoft under the promise that future versions of Ecmascript would bring interesting additions and improvements to JavaScript , this means that TypeScript is kept at the forefront with JavaScript improvements.

In addition, this allows one to integrate TypeScript into existing JavaScript projects without having to reimplement all the project code in TypeScript, in fact, it is common for projects to exist that introduce both TypeScript and JavaScript.

As well, one of the additional benefits of this language feature is that it makes available the huge ecosystem of libraries and frameworks that exist for JavaScript. With TypeScript you can develop applications with React, Vue, Angular, etc.

 

Static Typing

 

The main feature of TypeScript is static typing. We say that a language is static typing when it meets these main characteristics:

  • Variables have a data type.
  • Values can only be assigned to variables of the corresponding type.
 
let age : number; //We assign the type number for the age variable  
age = 20; // The variable can now only assign values of type number

From these two main characteristics, some others are derived, such as

- Interfaces
- Generic
- Data Casting (Rate Conversion)
- Arguments with type
- Return type for functions

etc etc.

The contrast of these languages are dynamic typing languages, such as JavaScript, these languages are usually much more flexible, allowing us to write less verbose code.

On the other hand, static typing languages lend themselves to the implementation of more advanced development tools, such as

- Auto-completion
- Recommendation of which arguments a function receives
- Recommendation of what type a function returns
- Self documentation of the code
- Better analysis to detect errors

 

Why TypeScript

 

The programming industry is incredibly diverse, even if you specialize in some area of programming, every day there is something new to learn, new technology, a new approach to problem solving, etc.

Every once in a while, a technology comes along that dazzles your eyes, that you immediately fall in love with, and you even wonder, how could you work without this technology? TypeScript is that kind of technology.

When you write a language with the intention that it will lend itself to the development of tools for developers, what do you get? A programming language with a development experience superior to others.

Developing in TypeScript is incredible, proof of which is the amount of development teams that have integrated the tool, as a substitute for the use of JavaScript, among them we have:

  • Google
  • Microsoft
  • Basecamp
  • Lyft
  • more and more companies
 

Frameworks JavaScript

 

The team that develops some of the most popular open sources use TypeScript for the development of these libraries. A couple of very popular examples are Angular and Stimulus.

This means that most of the documentation and examples of these frameworks, mainly Angular, are written with TypeScript. Eventually this means that applications developed using these libraries are made with TypeScript.

Angular is perhaps the most prominent example, virtually all applications in Angular are written using TypeScript, if you want to understand the framework in depth, you need to know TypeScript.

These decisions are not taken lightly, the teams that develop these frameworks take advantage of TypeScript features for the implementation of these frameworks and the development of web applications.

Learning and mastering this language is your gateway to other technologies.

 

CONCLUSION

Learning TypeScript introduces you to an incredible programming language, with even better development tools. Particularly, Visual Studio Code will offer an interesting number of improvements to your development flow.

Also, one of the great things about using TypeScript is that you can use it in different environments and for native, hybrid, web, desktop, and even web server application development.

 
by Janeth Kent Date: 18-07-2020 javascript coding typescript hits : 7304  
 
Janeth Kent

Janeth Kent

Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN AND DEVELOPMENT.

 
 
 

Related Posts

How to upload files to the server using JavaScript

In this tutorial we are going to see how you can upload files to a server using Node.js using JavaScript, which is very common. For example, you might want to…

How to combine multiple objects in JavaScript

In JavaScript you can merge multiple objects in a variety of ways. The most commonly used methods are the spread operator ... and the Object.assign() function.   How to copy objects with…

The Payment Request API: Revolutionizing Online Payments (Part 2)

In the first part of this series, we explored the fundamentals of the Payment Request API and how it simplifies the payment experience. Now, let's delve deeper into advanced features…

The Payment Request API: Revolutionizing Online Payments (Part 1)

The Payment Request API has emerged as the new standard for online payments, transforming the way transactions are conducted on the internet. In this two-part series, we will delve into…

Let's create a Color Picker from scratch with HTML5 Canvas, Javascript and CSS3

HTML5 Canvas is a technology that allows developers to generate real-time graphics and animations using JavaScript. It provides a blank canvas on which graphical elements, such as lines, shapes, images…

How do you stop JavaScript execution for a while: sleep()

A sleep()function is a function that allows you to stop the execution of code for a certain amount of time. Using a function similar to this can be interesting for…

Mastering array sorting in JavaScript: a guide to the sort() function

In this article, I will explain the usage and potential of the sort() function in JavaScript.   What does the sort() function do?   The sort() function allows you to sort the elements of…

Infinite scrolling with native JavaScript using the Fetch API

I have long wanted to talk about how infinite scroll functionality can be implemented in a list of items that might be on any Web page. Infinite scroll is a technique…

Sorting elements with SortableJS and storing them in localStorage

SortableJS is a JavaScript extension that you will be able to use in your developments to offer your users the possibility to drag and drop elements in order to change…

What is a JWT token and how does it work?

JWT tokens are a standard used to create application access tokens, enabling user authentication in web applications. Specifically, it follows the RFC 7519 standard. What is a JWT token A JWT token…

Template Literals in JavaScript

Template literals, also known as template literals, appeared in JavaScript in its ES6 version, providing a new method of declaring strings using inverted quotes, offering several new and improved possibilities. About…

How to use the endsWith method in JavaScript

In this short tutorial, we are going to see what the endsWith method, introduced in JavaScript ES6, is and how it is used with strings in JavaScript. The endsWith method is…

Clicky