Skip to content

cloudstreet-dev/REST-gRPC-in-33-Languages

Repository files navigation

REST APIs and gRPC in 33 Languages

A comprehensive guide and working examples of REST and gRPC API implementations across 33 programming languages.

About This Project

This repository contains the complete source code and manuscript for the book "REST APIs and gRPC in 33 Languages: A Polyglot's Guide to Modern API Creation, Implementation, and Usage" by David Christian Liedle.

The project demonstrates how to implement the same Task Management API using both REST and gRPC protocols in 33 different programming languages, providing a unique comparative perspective on API development across the modern programming landscape.

Project Structure

REST-gRPC-in-33-Languages/
├── book/                   # Book manuscript and documentation
│   ├── manuscript/        # Chapter content in Markdown
│   │   ├── frontmatter/  # Foreword, preface, acknowledgments
│   │   ├── chapters/     # 33 language chapters
│   │   └── appendices/   # Installation guides, tools, etc.
│   └── resources/        # Images, diagrams, references
├── code/                  # Working code examples
│   ├── shared/           # Shared protocol definitions
│   │   ├── protos/      # Protocol Buffer definitions
│   │   └── openapi.yaml # OpenAPI 3.0 specification
│   └── [language]/      # Per-language implementations
│       ├── rest/        # REST API implementation
│       │   ├── server/
│       │   └── client/
│       └── grpc/        # gRPC implementation
│           ├── server/
│           └── client/
└── LICENSE

The Task Management API

All implementations provide the same Task Management API functionality:

REST Endpoints

  • GET /tasks - List all tasks with filtering and pagination
  • GET /tasks/{id} - Get a specific task
  • POST /tasks - Create a new task
  • PUT /tasks/{id} - Update a task
  • PATCH /tasks/{id}/status - Update task status
  • DELETE /tasks/{id} - Delete a task

gRPC Services

  • ListTasks - Server streaming: list tasks with filters
  • GetTask - Unary: get a single task
  • CreateTask - Unary: create a new task
  • UpdateTask - Unary: update an existing task
  • DeleteTask - Unary: delete a task
  • WatchTasks - Bidirectional streaming: real-time task updates

Languages Covered

🎉 All 33 Languages Complete! (v1.0.0)

Languages with Full gRPC Implementation (17 languages)

JavaScript (Node.js with Express and gRPC)
TypeScript (Deno with Oak and gRPC)
Dart (Shelf framework and gRPC)
Go (Gin and native gRPC)
Ruby (Sinatra and gRPC gem)
PHP (Slim Framework and gRPC)
Python (FastAPI and grpcio)
Java (Spring Boot and gRPC)
Rust (Actix-web and Tonic)
Kotlin (Ktor and gRPC)
Swift (Vapor and gRPC-Swift)
C# (ASP.NET Core and gRPC)
F# (Giraffe and gRPC on .NET)
C++ (Crow and gRPC++)
Scala (Akka HTTP and ScalaPB)
Objective-C (GCDWebServer and gRPC-ObjC)
Elixir (Phoenix and grpc-elixir)
Clojure (Ring/Compojure and Protojure)
Erlang (Cowboy and grpcbox)
Haskell (Servant and grpc-haskell)

Languages with Partial gRPC Support (5 languages with examples/documentation)

Crystal (Kemal - gRPC alternatives discussed)
Perl (Mojolicious - Grpc::XS documented)
Lua (OpenResty - lua-grpc limitations shown)
R (Plumber - grpc package examples)
D (Vibe.d - gRPC binding challenges explained)

Languages with REST Only (11 languages - gRPC not feasible)

C (Custom HTTP server - gRPC requires C++)
Zig (Built-in HTTP - awaiting gRPC ecosystem)
OCaml (Dream - ocaml-grpc immature)
Nim (Jester - no production gRPC)
Julia (HTTP.jl - gRPC.jl experimental)
Gleam (Mist - too new for gRPC)
V (vweb - young language, no gRPC)
Io (Socket-based - niche language, gRPC infeasible)

Getting Started

Prerequisites

  • Docker (recommended for consistent environments)
  • Or native development tools for each language

Quick Start with JavaScript

# Clone the repository
git clone https://github.com/cloudstreet-dev/REST-gRPC-in-33-Languages.git
cd REST-gRPC-in-33-Languages

# Start JavaScript REST server
cd code/javascript/rest/server
npm install
npm start

# In another terminal, start gRPC server
cd code/javascript/grpc/server
npm install
npm start

# Test with clients
cd code/javascript/rest/client
node client.js

cd code/javascript/grpc/client
node client.js

Using Docker

Each language implementation includes a Dockerfile:

cd code/javascript
docker build -t task-api-js .
docker run -p 8080:8080 -p 50051:50051 task-api-js

Book Contents

Part 1: Foundations

  • Introduction to REST and gRPC
  • Protocol Buffers vs JSON
  • API Design Principles
  • The Task Management Domain

Part 2: Language Implementations

33 chapters, each covering:

  • Language overview and philosophy
  • REST API implementation
  • gRPC implementation
  • Performance comparisons
  • Best practices and patterns
  • Quick reference guide

Part 3: Appendices

  • Installation guides for all languages
  • Development environment setup
  • API testing tools
  • Enterprise considerations
  • Framework comparisons

Features Demonstrated

Each implementation showcases:

REST Features

  • RESTful resource design
  • HTTP status codes
  • Request/response headers
  • Content negotiation
  • CORS handling
  • Authentication patterns
  • Error handling
  • Pagination
  • Filtering and sorting

gRPC Features

  • Protocol Buffer definitions
  • Unary RPC calls
  • Server streaming
  • Client streaming
  • Bidirectional streaming
  • Error handling with status codes
  • Metadata handling
  • Interceptors/middleware
  • Load balancing patterns

Performance Comparisons

Each chapter includes benchmarks comparing:

  • Latency (REST vs gRPC)
  • Throughput
  • Payload size
  • CPU usage
  • Memory consumption
  • Streaming performance

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Areas where help is needed:

  • Additional language implementations
  • Performance optimizations
  • Security enhancements
  • Documentation improvements
  • Test coverage
  • Docker optimizations

Authors

David Christian Liedle

With AI Co-authorship by Claude (Anthropic)

This book represents a collaboration between human expertise and AI assistance, with Claude helping to implement code examples, write documentation, and ensure consistency across all 33 language implementations.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • The open-source community for the amazing tools and libraries
  • My children, Tegan and Solomon, for their patience and inspiration
  • All who have supported this ambitious project

Project Status

Version 1.0.0 Complete! 🎉

All 33 language implementations are complete with comprehensive REST API examples and gRPC implementations or documentation where applicable.

Completed Milestones

  • Project structure and shared specifications
  • All 33 programming language implementations
  • REST API implementation for all languages
  • gRPC implementation for 22 languages with mature support
  • gRPC considerations documented for 11 languages with limitations
  • Complete manuscript with all 33 chapters
  • Comprehensive documentation and code examples
  • Performance comparisons and best practices
  • Tagged v1.0.0 release

Future Enhancements

  • Additional shell/scripting language supplements
  • Enhanced performance benchmarks
  • Video tutorials and walkthroughs
  • Interactive online playground
  • Community contributions and optimizations
  • Publisher review for print edition
  • Translations to other languages

Resources

Documentation

External Links

Support

For questions, issues, or discussions:

  • Open an issue on GitHub
  • Email the author
  • Join the discussion in the repository's Discussions tab

"The best way to learn is to teach, and the best code is written to meet one's own needs."

This book is a labor of love, created to be the reference I wish I had on my desk.

About

A reference

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •