Which programming language in AWS Lambda should I use?
Tags: serverless, lambda, aws, node
Published: 2021-06-16 02:27:42

One of most question I receive is "which programming language is the best for serverless?". People want to know what's the best choice to create their functions in AWS Lambda. But for me, the answer is not that simple just looking for technical stuffs.

In terms of performance, there are programming languages that perform better than others. The main characteristic that differs to those programming languages is the *cold start*. If you don't know, *cold start* is an amount of time that your cloud provider spent to start a new instance of your function. Once your function instance is started, the *cold start* will not occur for the next execution (until the timeout).

It's known that programming languages based on JVM, like Java, have a higher *cold start*. But Java has a good performance when the function is warmed up. It's also known that interpreted languages and compiled languages have a better performance in terms of *cold start*. That's the case of NodeJS and Python. These two programming language have a lower *cold start*.

So, if we think only technically, the answer is simple: use NodeJS or Python. But, as I said before, it isn't that simple.

For me, developing a serverless application isn't only a technical choose. It's especially about **lead time**, **time to market** and a better use of resources.

When I talk about lead time and time to market, that means it's important to care about how much time you need to develop your application. It's common to hear quotes like "faster companies won over big companies" and, because of that, it's important to think about how to build your application faster.

About better use of resources, when we develop our application faster it means we use less development resource. It's also important to think about maintenance, because once launched the application you need to keep that in the air, fix possible bugs, etc.

Thinking on all those things, I decided to create a diagram that help you to choose a programming language for your serverless function.

# Choosing a programming language

First of all, I want to clarify that's my own opinion, and it isn't a *bullet silver*, but I believe it will help you in most cases.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/szyf1k2uwa7krc1zlrrp.png)

According to the image above, I prefer to use a programming language that the team knows instead of a "better programming language". I did that because I believe in most cases the **time to market** is more important than the performance. There are many cases when we use functions in an event based architecture and those events are asynchronous. Besides that, even when the function in synchronous, for many times those functions will be *warmed up*, so we mitigate performance problems.

Using a programming language known by your team, you will develop your application faster (better time to market and less resources), and you will maintain easier because the programming language is in the comfort zone.

If you need to rewrite some function in the future because of performance, it's easy, just because serverless functions are decouple by design.

# Conclusion

Of course, if we have an opportunity to use an appropriated programming language in terms of performance it will be great, but I really believe in *time to market* first.

Cover image by Luis Gomes on Pexels.