telestion-architecture

ADR-0007: Use Deno with TypeScript for backend services

Date: 2023-05-09

Status

Accepted

Context

Note that terms like “backend”, “service”, etc., are used as described in ADR-0004.

Historically, backend services for Telestion have been written in Vert.x/Java (while the frontend gets built in TypeScript). This has brought with it a number of challenges, including, but not limited to:

Following our decision to use NATS as a language-agnostic message broker, we now have the opportunity to consider using a language other than Java for backend services. Given that we already employ JavaScript/TypeScript for the frontend, it would be reasonable to use it for many parts of the backend as well. Doing so would allow us to leverage the same language for both frontend and backend, significantly reducing project complexity.

Although Node.js is a common choice for services written in JavaScript/TypeScript, it does have certain drawbacks. These include the necessity of compiling TypeScript files to JavaScript before execution, the need to install and maintain a variety of development tools (test runner, code formatter, linter, etc.), and the presence of a significant amount of boilerplate overhead (package.json, node_modules, configuration files, etc.).

Deno is a newer runtime for JavaScript/TypeScript that resolves many of these issues. We recently utilized Deno for building services during the Telestion Hackathon in May 2023, and the experience was overwhelmingly positive. As such, this ADR aims to evaluate Deno as a runtime option for TypeScript-based backend services.

Pros of using Deno over Node.js

Cons of using Deno over Node.js

Relative newness and limited adoption

Deno is newer and less widely adopted than Node.js, resulting in fewer available resources and experienced developers. However, Deno’s similarity to Node.js and growing adoption rate should mitigate this issue.

Limited compatibility with some npm packages

Deno uses a different module system than Node.js, resulting in limited compatibility with some npm packages. However, Deno has many built-in modules that are not available in Node.js, and a growing ecosystem of packages designed specifically for Deno. This may mitigate the issue.

Experience with Deno at the Telestion Hackathon in May 2023

During the Telestion Hackathon in May 2023, we used Deno for the first time in a production environment and built a fully functional backend service in under four hours. We found the developer experience to be very positive, and we were impressed with the ease of use and simplicity of the runtime.

We were able to write a couple of services without any prior knowledge about Deno in under four hours.

Based on our experience, we highly recommend Deno as a promising runtime for TypeScript-based backend services, and we believe it would be a great choice for future projects.

Decision

We will recommend that developers use Deno/TypeScript for backend services. We won’t require the use of Deno/TypeScript, but we will encourage it where it makes sense (if there are reasons to use something else for specific services, that continues to be supported). We will provide documentation and resources for developers to write and deploy Deno-based backend services in TypeScript.

Consequences

The decision to recommend the use of Deno/TypeScript for backend services will have several immediate consequences for our development process.

Firstly, we will need to update our project templates to include Deno and TypeScript as recommended options for backend services. This will involve modifying our documentation, scripts, and configuration files to ensure that developers have the necessary tools to write and deploy Deno-based services.

Secondly, we will need to provide training and resources to developers working on Telestion become familiar with Deno and TypeScript, particularly those who may be unfamiliar with these technologies. This will likely involve creating new documentation and updating existing resources to ensure that developers have access to the information they need.

Overall, these changes lead to a more efficient and effective development process even though there will be some immediate changes and additional effort required to implement the recommendation to use Deno/TypeScript for backend services.