Encore vs. Nitric
Nitric is a framework that empowers developers to build complete cloud applications on their preferred cloud platform, combining infrastructure declaration and application code in one place. On the other hand, Encore is a development platform tailored for building cloud backend applications using the Go language, with deployment options for AWS or Google Cloud Platform. Both serve the purpose of simplifying cloud application development but operate in slightly different ways and cater to different specific needs.
These are the main differences between the two:
- Cloud Provider Support: Nitric is provider-agnostic, capable of deploying to multiple cloud providers such as AWS, Google Cloud, and Azure. Encore currently deploys to AWS or Google Cloud.
- Language Support: Nitric provides libraries for TypeScript/JavaScript, Python, Go, C# .NET and Java, allowing developers to choose their preferred language. Currently Encore supports Go, with TypeScript scheduled for Preview.
- Infrastructure Provisioning: Nitric uses Pulumi by default for provisioning cloud resources, but also allows the use of custom providers. Encore uses a hosted provisioning engine via their online platform.
- Open Source: As an open-source framework, Nitric does not require a platform or subscription to deploy applications, while Encore requires sign-up and may involve additional costs.
Code Comparison
To get a deeper understanding of the differences, let's see the same app built in both Nitric and Encore.
Nitric
package mainimport ("context""github.com/nitrictech/go-sdk/nitric""github.com/nitrictech/go-sdk/nitric/apis")func main() {api := nitric.NewApi("main")api.Get("/hello/:name", func(ctx *apis.Ctx) {ctx.Response.Body = []byte("Hello " + ctx.Request.PathParams()["name"])})nitric.Run()}
Encore
package helloimport ("context")//encore:api public path=/hello/:namefunc Hello(ctx context.Context, name string) (*Response, error) {msg := "Hello " + namereturn &Response{Message: msg}, nil}type Response struct {Message string}
The Nitric example shows an API where HTTP request handling is achieved using faas.HttpContext
, providing control over the request and response objects. The Encore example demonstrates an API where HTTP request handling is reflected through the function parameters and return types, with defined structs for responses.
Differences
Nitric | Encore | |
---|---|---|
Language | Your choice | Go |
Lines of code | 26 | 15 |
Cloud Infrastructure | Inferred | Inferred |
Extensibility | Custom providers can be created | No |
Local simulation | Built-in local simulator | Built-in local simulator |
Cloud providers | AWS, Azure, GCP and Custom providers | AWS and GCP |
Provisioning engine | Pulumi by default, other custom providers can be created | Hosted provisioning engine |