ergo-services / ergo

An actor-based Framework with network transparency for creating event-driven architecture in Golang. Inspired by Erlang. Zero dependencies.
https://docs.ergo.services
MIT License
3.67k stars 143 forks source link

Map string <-> ettBinary, []byte -> ettBitBinary #68

Closed heri16 closed 3 years ago

heri16 commented 3 years ago

Implement encode/decode for the types below without affecting node logic. (All tests pass)

Mapping Types

Golang Type ETF Type
string binary
[]byte bitBinary

Pros:

Cons:

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

halturin commented 3 years ago

explanation https://github.com/halturin/ergo/pull/68#discussion_r680967840 why this approach can't be accepted

heri16 commented 3 years ago

First off, thanks so much for the great work on this library.

I hope to be able to bring to light the extensive research done by the Elixir team with regards to interoperability with Erlang: https://elixirschool.com/en/lessons/advanced/erlang/#strings

Please see https://github.com/halturin/ergo/pull/68#discussion_r681109604 on why this approach should be accepted.

heri16 commented 3 years ago

I'll let the creator of Erlang explain further:

image

https://elixirforum.com/t/why-are-charlist-and-string-co-existing-in-erlang/31566

heri16 commented 3 years ago

Two different erlang authors interfacing to lua<-> erlang.

Both came to the same conclusion independently, that erlang's binary-strings should be mapped to lua "string", and erlang's list-strings should be mapped to lua lists.

https://github.com/rtraschke/erlang-lua#value-translation-from-erlang-to-lua

https://github.com/rvirding/luerl/wiki/0.7-Data-representation#data-types

https://github.com/rvirding/luerl/wiki/0.7-Data-representation#strings

halturin commented 3 years ago

Because Lua doesn't have a binary type. Anyway, you may want to try my implementation in the 'otp2324' branch. See README file there.

heri16 commented 3 years ago

Ruby has byte arrays.

See how types are mapped: http://www.erlang-factory.com/upload/presentations/36/tom_preston_werner_erlectricity.pdf

halturin commented 3 years ago

Who said that's a good mapping? :) especially looking at

image

... let alone this project is on hold last 13 years ))

Feel free to make a fork with data mapping you like. This PR won't be accepted. I've made etf.String and etf.Charlist to support interaction with Erlang/Elixir and it should be enough so far

halturin commented 3 years ago

not valid any more