dprint / dprint

Pluggable and configurable code formatting platform written in Rust.

Home Page:https://dprint.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: alternative process plugin communication format

bradzacher opened this issue · comments

Binary communication is super duper performant as a communication style because it's as compact as can be. However it's also not something that's easy to do in a lot of languages.

For example - handling binary sent from stdin in JS is a pain in the butt.
I'd love to see an alternative specification that uses jsonlines as its message format. Whilst it is more IPC bytes sent/received - most languages have easily accessible JSON parsers and can easily construct objects from JSON.
It's also much easier to construct a plugin which does
"read line from stdin, parse json, action, json stringify response, write line to stdin"
rather than
"read 4 bytes from stdin, interpret as u32, read 4 bytes from stdin, interpret as u32, read 4 bytes from stdin, interpret as u32, read n bytes from stdin where n = last u32 read, read 4 bytes from stdin and assert it's [255,255,255,255], action, write 4 bytes to stdout........"


Another option that would maintain the binary format would be using a standardised, schema-backed binary format like protobuf/flatbuffers so that consumers can more easily generate the serialisation/deserialisation code rather than manually building and maintaining it.