jstp icon indicating copy to clipboard operation
jstp copied to clipboard

Support different serialization formats

Open nechaido opened this issue 7 years ago • 4 comments

Now JSTP works only with one JSON5 like serialization format. While it would be much more extendable use abstract interface that provides such functions as:

  • parse()
  • serialize()
  • parseNetworkPacket()
  • serializeNetworkPacket()

This way will be able to add new formats, for example JSON or some binary format.

nechaido avatar Mar 31 '17 14:03 nechaido

Great suggestion. We'll still use "Record Serialization"/JSON5 syntax for custom DSLs like metadata, IDLs and stuff, but using pluggable serialization formats for protocol messages certainly gives us benefits.

When we'll send arrays with pure data only, and metadata being separated, there'll be nearly no difference in using our format or JSON. Except performance. A custom parser of JSON5-like format that only uses public V8 APIs is very unlikely to ever be even as fast as JSON, not to mention faster.

It will also be possible to use JSRS/JSON5 or JSON during development and a binary format for production mode and gain even more performance without sacrificing human-readable messages format when we need it.

aqrln avatar Mar 31 '17 14:03 aqrln

Yeah, I totally agree, that's a nice idea.

Having much faster message parsing and serialization can highly increase overall protocol performance. And if we are talking about V8 and Node, it is close to impossible to get parsing/serialization speed similar to that of JSON methods, because they are highly optimized and are deeply embedded into V8 internal structure. Not to mention the fact that almost every modern programming language has an optimized JSON implementation in standard libraries, which means that it can simplify creation of any new JSTP implementations.

@tshemsedinov, what is your opinion on this topic?

belochub avatar Mar 31 '17 15:03 belochub

Agree. We will have separated features divided by fixed interfaces: parser, transport, rpc, storage. So different implementations may be used in any combination.

tshemsedinov avatar Apr 01 '17 15:04 tshemsedinov

Paused because we don't need this functionality in near future

tshemsedinov avatar Jul 07 '17 18:07 tshemsedinov