TypeScript Is a Perfect Choice for Serverless

Arseny Yankovsky
Mar 27 · 2 min read

As a mainly Java developer I found myself in a tough situation coming to the serverless world. I was hoping to use Kotlin because of a nicer syntax, its null-safety and all the other features, but the cold starts made it almost impossible to use JVM-based languages. So I went to explore different options and I think I found a perfect solution.

Low Cold Start

One of the issues you usually deal with in serverless world is cold starts. It’s no secret that some runtimes are slower to start than the others. TypeScript uses Node.js runtime and its cold start is almost negligible.

The Community

One of the issues with new programming languages is a small an immature community.

One of the nice things about TypeScript is the ability to use JavaScript libraries, essentially allowing it to piggyback on a vast JavaScript community.

With JavaScript being the biggest and TypeScript being 7th biggest programming languages by the number of contributions on GitHub there is no shortage of libraries to choose from.

IDE options are strong as well. There is nice TypeScript support in JetBrains products (IntelliJ IDEA, WebStorm) and of course there is a free Visual Studio Code developed by the same company as the TypeScript — Microsoft.

Typing

I generally like strong typing, especially when building something big. I also like weak typing for quick prototyping. Good thing about TypeScript is that you can get both. You can configure how strict you want a compiler to be.

Null Safety

I really love the trend for null safe languages. Saves you from a lot of production issues on compile stage. Don’t agree? Just like with typing, you can configure TypeScript compiler to do strict null checks or to not.

Same Language as Your Frontend

Having both your frontend and backend written in TypeScript could be useful. Apart from reusing your code it allows your backend developers write frontend code easier and vice versa. Or makes life easier for your fullstack developers.

When Not to Use TypeScript?

TypeScript is not the best at number crunching. You also might consider using some compiled language like Go or Rust for lambdas that are called very often. It will make them faster and more cost-effective.

50