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 main
import (
"fmt"
"github.com/nitrictech/go-sdk/faas"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
mainApi, err := nitric.NewApi("main")
if err != nil {
fmt.Println(err)
return
}
mainApi.Get("/hello/:name", func(ctx *faas.HttpContext, next faas.HttpHandler) (*faas.HttpContext, error) {
params := ctx.Request.PathParams()
ctx.Response.Body = []byte("Hello " + params["name"])
return next(ctx)
})
if err := nitric.Run(); err != nil {
fmt.Println(err)
}
}
Encore
package hello
import (
"context"
)
//encore:api public path=/hello/:name
func Hello(ctx context.Context, name string) (*Response, error) {
msg := "Hello " + name
return &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 | 27 | 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 |