Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between dynamically and statically generated grpc code?

Tags:

node.js

grpc

In the examples of the GRPC client there are two types of implementation, one where the .proto files are loaded and processed at runtime, and one where they are compiled using protoc.

My question is: what is the difference? The docs say nothing more than 'they behave identically', but surely there has to be a difference right?

like image 781
Sander Avatar asked Apr 04 '17 19:04

Sander


1 Answers

Fundamentally, the primary difference is the one you mentioned: with the dynamic code generation, the .proto file is loaded and parsed at run time, and with static code generation, the .proto file is preprocessed into JavaScript.

The dynamic code generation is simpler to use, potentially easier to debug, and generates code that accepts regular JavaScript objects.

The static code generation (using protoc) requires the user to create protobuf objects, which means that input validation will be done earlier. It is also a workflow that is more consistent with other languages.

like image 160
murgatroid99 Avatar answered Oct 06 '22 18:10

murgatroid99