8 June 2021
Should we be using TypeScript?
JavaScript is a fantastic programming language that is everywhere on the web. It was originally designed as a client-side language and tends to run very fast, and is extremely versatile with extended functionality. It also has rich interfaces that can be used to enhance the user interface and overall experience of a site. There are over 1.8 billion websites in the world, and JavaScript is used on 95% of them (according to Github's 2020 Octoverse Report). It is also increasingly used on server-side code.
Like everything however, JavaScript does have its downsides. It’s dynamically and loosely typed, for example, which can be bad for application reliability. This can lead to challenges when dealing with complex JavaScript code, especially when developing large-scale applications (like the ones on the modern web). De-bugging dynamic typed code can decrease programmer efficiencies and add costs to an overall project.
JavaScript is very powerful – but because it doesn’t incorporate types or compile-time error checks, it’s not ideal for complex server-side applications.
It was for these reasons that Microsoft started to develop TypeScript around ten years ago. It was first released in 2012 and has undergone a massive growth in popularity over the last few years.
What is TypeScript?
TypeScript is a strict syntactical superset of JavaScript that adds static typing to the language (as an option). It compiles to plain JavaScript. Static typing helps you avoid classic errors such as TypeError: 'undefined' is not a function, etc. It also makes it easier for you to refactor code and orientate yourself in large-scale, complex systems.
TypeScript should be treated as a JavaScript augmentation, rather than an attempt to fix a broken language. It can be used to increase your velocity in complex projects, without abandoning the core principles that make JavaScript so great. As Microsoft puts it – TypeScript is ‘typed JavaScript at any scale… By understanding JavaScript, TypeScript saves you time catching errors and providing fixes before you run code’.
Three Reasons to use TypeScript
TypeScript is essentially JavaScript with documentation that the compiler can understand. Types in it are optional, and every JavaScript file is a valid TypeScript file. TypeScript is compiled to JavaScript and can be used anywhere JavaScript is used – frontend and backend. Given this, here are three reasons to use TypeScript:
Three Drawbacks of TypeScript
Nothing in the world is perfect though, and even TypeScript has its drawbacks. Here are three of them:
Summary
In this article we’ve tried to give you a balanced insight into TypeScript versus JavaScript. JavaScript continues to be the world’s most popular programming language – but TypeScript is gaining in popularity and is now ranked at number 4 (with Python and Java separating it from the leader). Much of this growth is due to JavaScript programmers trying it out and liking what it does. Learning it can be an enjoyable and worthwhile endeavour – and we can help you with that.
Here at JBI Training, we provide a range of world class technology training courses including:
CONTACT
+44 (0)20 8446 7555
Copyright © 2024 JBI Training. All Rights Reserved.
JB International Training Ltd - Company Registration Number: 08458005
Registered Address: Wohl Enterprise Hub, 2B Redbourne Avenue, London, N3 2BS
Modern Slavery Statement & Corporate Policies | Terms & Conditions | Contact Us