some patterns in questions.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

some patterns in questions.

Benoit Chesneau-2
Hi all, 

I'm polishing an api for a library that will be used by a lot of consumers. It seems important for me to respect much of the current expectations of Erlang developers, so I was wondering what people expect these days when using recent versions of Erlang > 20. 

* passing options to a function: would you still expect to use a `propslist` or a `map`? In which case are you using one or the other?

* database names for database embedded in an Erlang VM: would you expect to still use atoms like for `ETS` or `Mnesia` or would you use any of the following types: atoms, strings, binary? I'm thinking atoms are more optimised in their usage, but is this still true?

Any feedback is welcome :)

Benoît

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: some patterns in questions.

Dmitry Kolesnikov-2
Hello,

Thank you for asking ;-) I’ll put my comments in-line

>
> I'm polishing an api for a library that will be used by a lot of consumers. It seems important for me to respect much of the current expectations of Erlang developers, so I was wondering what people expect these days when using recent versions of Erlang > 20.
>
> * passing options to a function: would you still expect to use a `propslist` or a `map`? In which case are you using one or the other?

I am still using `proplists` in few of public projects. However, internally I do have trend of switching to maps. Proplists has a good feature of supplying a boolean property, e.g. `read`. It might looks more awkward with maps #{read => true}. However, the usage of dict is preferable approached in competing languages (e.g. Go, Python, etc).


> * database names for database embedded in an Erlang VM: would you expect to still use atoms like for `ETS` or `Mnesia` or would you use any of the following types: atoms, strings, binary? I'm thinking atoms are more optimised in their usage, but is this still true?

I would like to see a support for binary at embedded database. Atoms works fine if database is global or node-wide defined at boot time. However, I am also dealing with use-case where I need to create databases dynamically based on external input. I would prefer to use binaries for this, instead of converting binary to atom and back.

>
> Any feedback is welcome :)
>
> Benoît
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions

I hope it helped!

Best Regards,
Dmitry


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: some patterns in questions.

Andreas Schultz-3
In reply to this post by Benoit Chesneau-2
Benoit Chesneau <[hidden email]> schrieb am Di., 23. Okt. 2018 um 14:51 Uhr:
Hi all, 

I'm polishing an api for a library that will be used by a lot of consumers. It seems important for me to respect much of the current expectations of Erlang developers, so I was wondering what people expect these days when using recent versions of Erlang > 20. 

* passing options to a function: would you still expect to use a `propslist` or a `map`? In which case are you using one or the other?

I usually prefer the readability of a maps match in a function head or guard for options over the more complex use of proplists. However, for compatibility reason I tend to support proplist for options as well.
Converting proplists to maps is straight forward, so the coast of supporting both should be quite low.

Andreas

--
--
Dipl.-Inform. Andreas Schultz

----------------------- enabling your networks ----------------------
Travelping GmbH                     Phone:  +49-391-81 90 99 0
Roentgenstr. 13                     Fax:    +49-391-81 90 99 299
39108 Magdeburg                     Email:  [hidden email]
GERMANY                             Web:    http://www.travelping.com

Company Registration: Amtsgericht Stendal        Reg No.:   HRB 10578
Geschaeftsfuehrer: Holger Winkelmann          VAT ID No.: DE236673780
---------------------------------------------------------------------

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions