Mappa Via Marconi 20, Bussolengo (VR)
Email info@devinterface.com

What is happening to TypeScript?

Index

As we saw in our article ‘Where is programming heading?’, five out of six of the top 10 positions of the analysed sources feature TypeScript in their ranking.

TypeScript is an open source programming language that is based on JavaScript and was released in 2012 by Microsoft, thus a technology that has been present and in use for over 13 years. Last March, however, Microsoft itself released a statement announcing the porting of the TypeScript compiler from JavaScript to Go, promising an incredible 10-fold improvement in performance. 

In the tech community, these statements raised a lot of interest, but also astonishment, in particular over the choice of GO and not technologies such as C++, C# or Rust. 

In this article, we give you a brief overview of TypeScript, GO and the innovations to come. 

TypeScript

TypeScript is a superset of JavaScript, which means that you can use JavaScript and have access to many features designed to create better code. TypeScript works by compiling itself into a performant and reliable JavaScript. This compilation phase is performed in TypeScript. Why has TypeScript been so popular and still continues to play an important role?

TypeScript was developed by Microsoft and released in 2012 as a superset of JavaScript, with the aim of solving some of the language's limitations, such as the lack of static typing.

Meanwhile, in 2011, Google launched AngularJS, a JavaScript-based frontend framework. Soon after, in 2013, Facebook introduced ReactJS, another frontend library that quickly gained popularity. Both were based exclusively on JavaScript. In 2016, however, Google released Angular 2, a new framework that, unlike its predecessor, was entirely written in TypeScript.

Over time, Angular (based on TypeScript) began to gain more and more acceptance, distinguished by its more organised structure and static typing, which helped to prevent errors and improve code maintainability. This helped the growing adoption of TypeScript, also prompting the React community to integrate support for TypeScript from 2020.

Currently, an increasing number of developers and companies have migrated from JavaScript to TypeScript due to its advantages in terms of security, productivity and scalability. It has become a standard for frontend and backend development, used in frameworks such as Angular, React and even Node.js.


GO

During the late 2000s, Google faced challenges in backend development for its large-scale services. The main language used for microservices was C++, which offered excellent performance but had a complex syntax and a steep learning curve for new developers. In order to better manage the team's scalability and productivity, some Google engineers started looking for alternatives.

The goal was to create a language that was easy to learn, highly performant and readable, while maintaining a high level of efficiency. At one point, a combination of C++ and Assembly was used, but the need for a new language more suited to modern requirements soon became evident.

On November 2009, Google officially announced Go (Golang) to be open source, developed by Robert Griesemer, Rob Pike and Ken Thompson. After various improvements, the stable version Go 1.0 was released in March 2012, which became the standard for development with Go.

Thanks to its simplicity, efficiency and competitive support, Go quickly gained popularity, becoming a pillar in the world of backend, cloud computing and microservices. Today, it is widely used by companies such as Google, Uber, Dropbox and Docker.


Why Go and not other languages?

As anticipated in the introduction, Anders Hejlsberg announced in March that the TypeScript compiler in its current form will be replaced by a new implementation written in Go. This does not entail a complete rewrite from scratch, but a porting of the existing code, currently written in TypeScript, to Go. Microsoft expects a performance increase of up to 10 times, as well as more efficient memory management and increased stability and reliability.

The execution of native code is generally faster and cheaper than depending on a JIT (Just-In-Time) compiler at runtime. But why was Go specifically chosen?

Rust was considered, but its complex memory management model (with concepts such as borrowing and ownership) would have made a one-to-one porting of existing code difficult. It would have been more suitable for a complete (greenfield) rewrite, but not for a direct migration.

C++ was evaluated too, as it offers outstanding performance, but it has many peculiarities and an outdated syntax, making it less suitable in terms of maintainability and development.

As far as C# is concerned, its classical compilation would require the use of the .NET runtime, which would be impractical: a compiler would have to work as a statically linked binary, while the AOT (Ahead of Time) compiler of .NET would not support all the desired platforms. For this reason, it was ruled out.

The advantages of Go for the new TypeScript compiler

Go was chosen because of its balance between performance, maintainability and ease of porting. Conceptually, Go is similar to TypeScript, simplifying migration. In addition:

  • Automatic memory management: thanks to garbage collection, there is no need for manual management.
  • Generation of static binaries: Go can produce stand-alone executables for different platforms, without depending on an external runtime.
  • Optimisation for performance and parallelisation: two fundamental aspects for a compiler.
Microsoft did not choose Go because it is the ‘fastest’ or ‘best’ language, but because it is the one that offers the most balanced solution for the needs of the project.

What will change for TypeScript developers?

If you are working with TypeScript there will not change much in the short term, TypeScript is currently at version 5.8, and 5.9 will be the next release. With TypeScript 6.0, the first deprecations and changes to prepare for the new compiler in Go will begin. The latter will debut with TypeScript 7.0, although there are no official dates yet.


Conclusion

Switching the TypeScript compiler to Go will bring numerous benefits, including faster builds, both locally and in CI/CD pipelines. In addition, the TypeScript language server will benefit from increased responsiveness, improving IDE performance and making the development experience smoother. A further significant aspect is that, as of TypeScript 7, Node.js will no longer be a requirement for compiling code, further simplifying the setup of development environments.

We too at DevInterface have adopted Go as part of our technology stack for quite some time now, appreciating its speed, scalability and efficiency in handling concurrency. Thanks to our experience with this language, we are able to realise robust and high-performance applications, ideal for high-performance backends, microservices and cloud-native projects.

If you are thinking of developing a project with Go, our team can help you exploit the full potential of this language. Contact us to find out how we can support you!