CUSTOMISED
Expert-led training for your team
Dismiss
Typescript Training Course

8 June 2021

Front End Choices: Typescript vs Javascript

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:

  1. It is more reliable than JavaScript and easier to refactor – helping you to avoid errors and making code management easier
     
  2. It will increase performance and let you focus on how the system is built (which is very important in large-scale systems) – rather than just focussing on the code
     
  3. TypeScript and JavaScript are essentially interchangeable, so given the above benefits of TypeScript – why wouldn’t you use it?

 Three Drawbacks of TypeScript

Nothing in the world is perfect though, and even TypeScript has its drawbacks. Here are three of them:

  1. Everything comes with a price – and to start using TypeScript you have to make some upfront scarifies (mainly in terms of time)
     
  2. The typing system is a great tool – but it can add a bit more complication to the set-up
     
  3. TypeScript can certainly spot errors – but you may become over reliant on it, and develop a false sense of security

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:

 

 

FIND OUT MORE

EMAIL US

About the author: Craig Hartzel
Craig is a self-confessed geek who loves to play with and write about technology. Craig's especially interested in systems relating to e-commerce, automation, AI and Analytics.

CONTACT
+44 (0)20 8446 7555

[email protected]

SHARE

 

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

POPULAR

Rust training course                                                                          React training course

Threat modelling training course   Python for data analysts training course

Power BI training course                                   Machine Learning training course

Spring Boot Microservices training course              Terraform training course

Kubernetes training course                                                            C++ training course

Power Automate training course                               Clean Code training course