TypeScript
(7 minutes of reading time) TypeScript is an open-source programming language developed by Microsoft. It was built on top of JavaScript, to take better advantage of its main features. In TypeScript, it was possible to add static typing capabilities that didn’t exist in JavaScript. That is, you have all the JavaScript features in TypeScript plus several other features. Although Typescript is a “superset” of JavaScript, when compiling the code, all TypeScript is converted/transpiled to Javascript. Developers writing TypeScript code uses a simplified syntax that is clearer and supported by various TaskRunners or IDES, but your code will revert to JavaScript after transpiling. This happens because the browser does not understand the syntax of a programming language other than JavaScript. TypeScript was considered by the public to be the fourth "most loved" language, according to the Stack Overflow survey in 2018. And it is among the fifteen most popular languages, according to the survey conducted by RedMonk. Anders Hejlsberg, C# language architect and creator of Delphi and Turbo Pascal languages, worked on TypeScript development. TypeScript can be used to develop JavaScript applications both on the client side and on the server side. There are several options available for transcompilation. The standard TypeScript Checker can be used, or you can use the Babel compiler to convert TypeScript to JavaScript. TYPESCRIPT X JAVASCRIPT The main differences between them are: 1 - TYPESCRIPT - Static typing; - Object orientation; - Generics; - Namespaces; - Decorators 2 - JAVASCRIPT - Dynamic typing; - Structured programming; - Functions; - Prototypes; - Constructor functions By using the TypeScript “superset” we have better support for object-oriented programming, since JavaScript has been boosted with several possibilities that the pure language does not have. In its simple form, JavaScript does not allow the use of interfaces in a clear way, for example, in addition to presenting a weak typing, which harms the development of applications at scale. In this way, TypeScript aims to circumvent these problems by adding a series of functionalities, which will be lost, since the final code becomes JavaScript when transpiled. However, when programming, the developer will have greater possibilities and a simpler, clearer syntax, supported by all modern code editors. As TypeScript is a modification of JavaScript, any file that has been written with the .js extension can be used within TS, as it accepts JS code by default. This is very positive, as it makes it possible to update systems built in JavaScript. KEY ADVANTAGES OF TYPESCRIPT There are two main advantages of TypeScript: static typing and object orientation. Undoubtedly, the main characteristic of TypeScript is its strong typing, that's why it has the name Type. JavaScript, in most of its language design, is untyped and type inference only goes so far. Hence a greater need to use TypeScript if you want to overcome these deficiencies. Here are some of the advantages of using TypeScript: ENCAPSULATION Encapsulation can be understood as a way of structuring code so that certain blocks have access to specific points for the external environment. Thus, the visibility and accessibility of the internal elements of a class. That is, when using encapsulation, you can define which are the attributes of a class that will be visible to external users or that will be exposed to a public interface of the system. Programmers who already use languages such as Java, PHP and C# are already used to declaring private attributes within their classes, guaranteeing this control. Example in Typescript:
private _saldo: number;
HERITAGE Inheritance is also a well-known principle, and based on it, a child class can inherit, or not, the behaviors and characteristics of a parent class, without having to redefine all the functions again. In TypeScript the word used for inheritance is “extends” just like in Java. You must declare the new function by extending it from another, as in the example below:
module Escola { class Pessoa { ...código aqui.. } class Aluno extends Pessoa { ...código aqui.. } class Professor extends Pessoa { ...código aqui.. } }
TypeScript makes it easy to write this inheritance-based code, which will later compile into pure JavaScript. POLYMORPHISM We also have polymorphism, which allows objects to be used within the programming in different ways, according to the situation. That is, in a reverse-inheritance sense, we can assume that a parent class can use attributes from any of its child classes. ABSTRACTION Abstraction can be considered the ability to highlight only some features of elements in the real world. It is widely used in object-oriented programming. These characteristics are grouped in so-called classes, which represent parts of an element and its attributes for the solution of a given problem. There are also “abstract classes”, which do not have a representation in the real world but, perform functions necessary for the system. These are called interfaces.
export module Escola { export interface Nota { AlterarNota(nota: number); } export class Aluno implements Nota { AlterarNota(nota: number) { } } }
We can say that TypeScript is a potentiator of JavaScript and with it is possible to build complex systems without any problem and without being insufficient compared to other back-end languages, such as PHP or Java. As we said, there are several advantages of using TypeScript and another one is being able to discover bugs during the implementation of your project, since it is possible to use the IDE's Intellisense, which already visualizes improvement points and compilation problems. The focus of Typescript is to include static typing in JavaScript, also including some features that facilitate the application of OOP concepts. However, it is through typing that we can build much more secure applications, greatly improving productivity. Do you like our content? So, follow us on social media to stay on top of innovation and read our blog. Reference: https://bit.ly/3PvEilm https://bit.ly/38vYJOH https://bit.ly/3wpGdAB https://bit.ly/3lnMypH https://bit.ly/38vYYJB
Share this article on your social networks:
Rate this article:
Other articles you might be interested in reading
- All (184)
- Career (38)
- Competitions (6)
- Design (7)
- Development (112)
- Diversity and Inclusion (3)
- Events (3)
- History (15)
- Industries (6)
- Innovation (37)
- Leadership (8)
- Projects (23)
- Well being (18)
Tech in Education
(9 minutes of reading)
In the contemporary educational landscape, technology plays an increasingly crucial role, revolutionizing not only the way students learn, but also how educators teach. As we adapt to a digitally connected world, new trends are emerging that promise to further transform the way education is designed and delivered. Come read this text to learn about the latest trends in educational technology and explore their impact on student development and the evolution of teaching. Come with us!...
Ethical Software Development
(5 minutes of reading)
Developing software is a complex activity that goes far beyond simple coding. It involves a meticulous process of planning, design, implementation, testing and maintenance to create reliable, efficient, and secure systems. However, in addition to seeking functionality and performance, developers must also carefully consider the ethical aspects of the software they are creating. In this text we will talk about ethics and responsibility when developing software. Come read!...
Balance Between Professional and Personal Growth
(6 minutes of reading)
In a world driven by the constant search for professional success, we often find ourselves immersed in our careers, forgetting the fundamental balance between professional and personal growth. As we dedicate hours to coding, solving problems, and advancing our technical skills, it's essential to remember that our journey as human beings go beyond the lines of code. Come read our text and see super cool tips on how to achieve this balance!...
How to Highlight Programming Competition Awards on your CV
(6 minutes of reading)
In a field as dynamic as software development, it is crucial to stand out from the crowd. An exceptional way to do this is through recognition and awards won in competitive programming competitions. In addition to demonstrating your superior technical skills, these awards attest to your ability to solve complex problems, collaborate as a team, and deliver exceptional results under pressure. Today we will talk about the curriculum and competitions, are you interested? Come with us!...
Open Source and Collaboration
(5 minutes of reading)
If you're ready to start exploring the world of open source, be aware that you will encounter many learning opportunities and challenges. Collaboration is at the heart of this environment, driving innovation and influencing the direction of technology. Come read our text to find out more about this subject!...
Women in Programming: Celebrating Achievements and Inspiring the Future
(5 minutes of reading)
This March 8th we will talk about the inspiring impact of women on programming throughout history, from pioneers like Ada Lovelace to contemporary leaders like Doina Precup and Reshma Saujani. This text celebrates their achievements and highlights progress towards a more inclusive and diverse technology industry. Join us to inspire and empower future generations of women in coding, creating a more equitable and brighter future for everyone in the technology industry....
Would you like to have your article or video posted on beecrowd’s blog and social media? If you are interested, send us an email with the subject “BLOG” to [email protected] and we will give you more details about the process and prerequisites to have your article/video published in our channels
Headquarter:
Rua Funchal, 538
Cj. 24
Vila Olímpia
04551-060
São Paulo, SP
Brazil