Hacker News new | ask | show | jobs
by jayd16 3346 days ago
But unless you control all client code, you can't check the client code at server compile time.

You're still breaking and forcing a refactor by all your clients and there's no way to track that with type safety.

That said, this use case seems to be for a single web front end and go back end but that part is left out of the title.

Protos are fine, google likes protos, gRPC works for Google because they have that insane CI system that builds every project at once...but any schema would work and you can be generating and checking against a schema for a JSON API as well. You don't need to move past REST and JSON to get what you're asking for.

2 comments

GP was a bad example. You probably wouldn't have an RPC returning a simple type. It would instead return a message (aka a Go struct, or an object in JS) which has various fields (or even just a single field). Protobuf messages have built-in backwards compatibility as long as you don't change field numbers. That way you can incrementally change your messages without breaking older clients.
I am aware this is not a real life scenario, I'm just saying what he calls type-safe, is actually something like cross-language-static-typing.