Its 2024 and its time for a look at your Web API Tech Stack.
Tags: go, csharp, api, webapi
Published: 2024-01-08 06:00:09

Hello everyone, this is my first post for 2024 and I hope you all had a great break. 
Over the break I was thinking about some of the technologies I wanted to sink my teeth into in 2024. 
The main two I will be focussing on are .Net Core 8 and Go. 
For a full stack platform .Net/.Net Core is hard to beat and for pure backend API development you really can't beat Go.
When I was looking at some key features for any API development in .Net Core and Go I came up with this list that I thought I would share:
I have broken this down into a .Net Core Web API Vs. Go list with supporting links.

- **Native compilation** or as close to native compiled - Go Wins here. Although .Net 8 has AOT (Ahead of Time) compilation but not all libraries are supported. More info can be found [here](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/native-aot?view=aspnetcore-8.0).

- **Boilerplate/Starter templates** - I have two projects to help get you started here :-). [Go API Starter](https://github.com/AaronSaikovski/go-api-starter) and [.Net Minimal API Starter](https://github.com/AaronSaikovski/dotnet-min-api-boilerplate).

- **Web Framework** - Both support a rich web framework, but .Net core wins here from a full stack perspective. But from a pure speed and performance perspective GoLang wins, using the [Fibre](https://docs.gofiber.io/) framework is unbeatable.

- **Clean architecture** - Both support this.
[Clean Architecture In ASP.NET Core Web API](https://www.c-sharpcorner.com/article/clean-architecture-in-asp-net-core-web-api/)
[Go Backend Clean Architecture](https://amitshekhar.me/blog/go-backend-clean-architecture)

- **Logging** - Both support this but its important to ensure that any logging framework supports a zero allocation model. For .Net use [Serilog](https://github.com/serilog/serilog-aspnetcore) and for GoLang use [Zerolog](https://github.com/rs/zerolog).

- **gRPC** - Both support this.
[Overview for gRPC on .NET](https://learn.microsoft.com/en-us/aspnet/core/grpc/?view=aspnetcore-8.0)
[gRPC-Go](https://github.com/grpc/grpc-go)

- **Docker/Containers** - Both support this. Although .Net 8 has a much richer Docker integration (you can remove Docker files altogether) but the .Net docker image size is about 4 times larger. From a size and speed perspective GoLang wins here.
[Creating a Minimal API with Docker](https://matthewregis.dev/posts/8-steps-for-creating-a-minimal-api-with-docker)
[Containerize a .NET app with dotnet publish (new way..No Docker file)](https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container)
[Containerize the go language REST API using Docker](https://techwasti.com/containerize-the-go-language-rest-api-using-docker)

- **Rate Limiting** - Both support this but can be tricky to implement and depends on the algorithm used.
[Rate limiting middleware in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/performance/rate-limit?view=aspnetcore-8.0)
[Rate Limiting API Calls in Go](https://www.calhoun.io/rate-limiting-api-calls-in-go/)

- **Profiling** - Both support this.
[How to Use Mini Profiler in ASP.NET Core Web API](https://dotnetthoughts.net/using-miniprofiler-in-aspnetcore-webapi/)
[Golang Profiling: The Basics and a Quick Tutorial](https://granulate.io/blog/golang-profiling-basics-quick-tutorial/)

- **Github Actions** - Both support this.
[How To Build a CI/CD Pipeline With GitHub Actions And .NET](https://www.milanjovanovic.tech/blog/how-to-build-ci-cd-pipeline-with-github-actions-and-dotnet)
[GitHub Actions workflow for Go Continuous Integration](https://dev.to/chefgs/github-actions-workflow-for-go-continuous-integration-32id)

- **Databases/ORM**- Both support this but have different implementations.
[API Development Using Dapper and Microsoft Asp.NET Core Web API](https://www.c-sharpcorner.com/article/api-development-using-dapper-and-microsoft-asp-net-core-web-api/)
[Entity Framework](https://learn.microsoft.com/en-us/ef/)
[GORM (ORM library for Golang)](https://gorm.io/)
[SQLBoiler (database-first ORM)](https://github.com/volatiletech/sqlboiler)
[XORM (Simple and Powerful ORM for Go)](https://xorm.io/)

- **Tracing** - Both support this.
[Tracing in ASP.Net Web API](https://www.c-sharpcorner.com/UploadFile/2b481f/tracing-in-Asp-Net-web-api/)
[Tracing runtime activities in Go.](https://pkg.go.dev/runtime/trace)

- **Exceptions** - .Net has the more traditional exception handling approach whereas Go has error return/nil types.
[How to handle errors in Minimal API apps](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/handle-errors?view=aspnetcore-8.0)
[Error Handling in Go REST APIs](https://alexrichey.com/articles/2021-09-09-error-handling-in-go-rest-apis.html)

- **Health Checks** - Both support this.
[Health Checks In ASP.NET Core For Monitoring Your Applications](https://www.milanjovanovic.tech/blog/health-checks-in-asp-net-core)
[Healthcheck (RESTful Healthcheck API implementation for Go services)](https://github.com/etherlabsio/healthcheck)

- **Unit tests** - Both support this.
[How to test your C# Web API](https://timdeschryver.dev/blog/how-to-test-your-csharp-web-api)
[Testify](https://github.com/stretchr/testify)
[Testing REST APIs in Go](https://intercloud.com/our-resources/blog/testing-rest-apis-in-go)

- **Endpoint Grouping** - Both support this.
[Minimal APIs quick reference (Route Groups)](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-8.0) 
[EndPoint Grouping .Net](https://blog.treblle.com/how-to-structure-your-minimal-api-in-net/)
[Go Fiber – Route Groups](https://dev.to/percoguru/getting-started-with-apis-in-golang-feat-fiber-and-gorm-2n34)
[Fiber Framework in Golang](https://medium.com/@uzairahmed01/fiber-framework-in-golang-b5158499c9ad)

- **API Key security** - Both support this and have very similar implementations.
[Implement API Key Authentication in ASP.NET Core](https://code-maze.com/aspnetcore-api-key-authentication/)
[KeyAuth in Go Fiber](https://docs.gofiber.io/api/middleware/keyauth/)

- **API Versioning** - Both support this.
[.Net MinimalApiExample](https://github.com/dotnet/aspnet-api-versioning/tree/3857a332057d970ad11bac0edfdbff8a559a215d/examples/AspNetCore/WebApi/MinimalApiExample)
[Go Fiber Versioning Boilerplate](https://github.com/aofdev/fiber-versioning-boilerplate)

- **Authentication & Authorization (JWT)** - Both support this but depends on your use case and what you are authenticating against. JWT links are provided here:
[How to implement JWT authentication in ASP.NET Core](https://www.infoworld.com/article/3669188/how-to-implement-jwt-authentication-in-aspnet-core.html)
[jwt-go](https://github.com/golang-jwt/jwt)
 
So from the comparison above hopefully this will guide you in your decision. For pure speed and lightweight APIS with no startup delays, I recommend Go.
But .Net 8 isnt no slouch either and is a very close second.  Very close. If you are after a rich and mature ecosystem and really amazing tooling, go with ASP.Net 8 Core.
thanks!