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 : 3697  
 
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 END DEVELOPMENT.

 
 
 

Related Posts

Javascript: what are callbacks and how to use them.

Today we are going to learn about a concept that is widely used in javascript and that is used quite a lot by today's frameworks, libraries, especially NodeJS. This is…

HTTP Cookies: how they work and how to use them

Today we are going to write about the way to store data in a browser, why websites use cookies and how they work in detail. Continue reading to find out how…

The package managers npm and yarn: main differences

Npm and yarn are package managers that help to manage a project’s dependencies. A dependency is, as it sounds, something that a project depends on, a piece of code that…

The Javascript asign() method to merge and clone objects

In this article, we will be covering Object.assign()method in javascript in detail with examples. A javascript object is a collection of key-value pairs. Keys are also known as properties of object. Keys…

All the javascript functions and methods to manipulate arrays

This article will show that the prominent JavaScript array functions are .map(), .filter(), and .reduce(), and will then go through examples of instances in which .every() and .some() would save…

Awesome JavaScript Games and Js Software to create Games

Best sites js13kGames 2019 - Highlights from the js13kGames 2019 competition. js13kGames 2018 - 13 Games in ≤ 13kB of JavaScript. js13kGames 2017 - Build a game in 13kB or less with js13kGames. Adventure Triangle:…

Is JavaScript good for machine learning?

One of the things you always hear when you are talking to someone related to the M.L. world is that, one must learn Python because the vast majority of the…

First steps into JavaScript – a practical guide 3

After we learned the basic ofaccessing DOM elementsandhow to modify them,we are ready for the more exciting parts – handling DOM events. This allows us to make our web way more…

JavaScript: Promises explained with simple real life examples

Handling asynchronous data flows is complex, who hasn't faced codes like this one?: checkWeather('palma de mallorca', (error, weather) => { if (error) throw error; if (weather === 'well') { return checkFlights('palma…

First steps into JavaScript – a practical guide 2

In the previous aticleFirst steps into JavaScript – a practical guidewe covered the basics of the DOM and its relation to us becoming JS literate. Now that we know how…

First steps into JavaScript – a practical guide

For those who are new to web development, surely the amount of new terminology can sometimes be discouraging. But when it comes to learning JS, some of the first new…

How to Install Node.js and NPM on Ubuntu 18.04

Node.js is a JavaScript platform for general programming that allows users to create network applications quickly. By leveraging JavaScript in both frontend and backend, Node.js makes development more uniform and integrated.…