Is it possible to use piqi in js_of_ocaml or bucklescript?

16 views
Skip to first unread message

Metin Akat

unread,
Jul 1, 2018, 2:48:40 PM7/1/18
to piqi
Hi,

I'm trying to figure out how to write the following system

1. OCaml native as an erlang port
2. Erlang for orchestration and transport
3. Web UI using js_of_ocaml or bucklescript (or quite possibly a mixture of both)

Will I be able to use piqi for this setup and what kind of difficulties/tradeoffs will I be having (to make)?

Thanks,
metin

Anton Lavrik

unread,
Jul 3, 2018, 4:05:34 AM7/3/18
to pi...@googlegroups.com, Metin Akat
Hi Metin,

Based on my experience, 1, 2 works really well. Piqi was pretty much created for this use case. It offers excellent support for both OCaml and Erlang. Protobuf serialization is pretty efficient in both runtimes. It has a non-0 overhead obviously, but it beats any ad-hoc protocol in terms of usability and extensibility. There are libraries out there for decoding External Erlang Term format in OCaml, but unless your protocol is trivial or you have unique performance constraints, Piqi/Protobuf is a better option.

Speaking of 3, I have no experience with using Piqi with js_of_ocaml/bucklescript. Protobuf stubs should in theory compile with bucklescript, but I would assume it would be way less efficient than using JSON. Piqi/JSON and Piqi-RPC/JSON works wonderfully when served by Eralng server. Piqi does not offer stubs generation for Bucklescript, so you'd have to encode/decode JSON manually. I've seen this working -- it is not too bad (it mainly relies on native JS JSON parser). Also -- I'd imagine that for someone who knows how to do it manually in Bucklescript, it would be rather trivial to add automated stubs generation for decoding Piqi/JSON for bucklescript to piqic-ocaml. I would be happy to include such functionality in the piqi-ocaml project if somebody contributes it.

Anton

--
You received this message because you are subscribed to the Google Groups "piqi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to piqi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Metin Akat

unread,
Jul 3, 2018, 3:57:51 PM7/3/18
to Anton Lavrik, pi...@googlegroups.com
Thanks, I’ll think about what I’m going to use and if i go thr piqi way, I’ll probably contribute any reusable code.

To unsubscribe from this group and stop receiving emails from it, send an email to piqi+uns...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages