Re: Idiomatic Erlang?

zxq9 <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <[email protected]>
On 2021/07/26 19:19, Benjamin Scherrey wrote:
> Been a couple of decades since I did any Erlang coding from scratch and 
> it seems to have improved significantly (didn't have proper strings back 
> then for example). I have a little hobby project I'm using to get myself 
> up to snuff so I can do some more serious work for an upcoming project.
Hi, Ben.

I noticed ROK gave you a fairly in-depth response already that addresses 
your specific code example and addresses both syntactic and structure 
issues. "Do what ROK says" is a good rule of thumb, and whether or not 
you follow specific advice there is always a lot of good stuff to 
consider carefully though sometimes specific suggestions don't always 
make sense until later.

As an appendix to that answer I have been writing a few example projects 
(and doing horribly boring but complete videos on them, as not everyone 
learns the same way) to give newcomers/returners an idea about how 
programs can be structured to work smoothly with OTP concepts and in the 
process following a syntactic style that we use internally at Tsuriai 
that was originally developed with a lot of input from this particular list.

Style example (a UUID generator):
https://gitlab.com/zxq9/zuuid
* `case` vs `if` vs function head matches and guards
* Indentation
* Spacing
* -spec then @doc then function
* Use of edoc and its output posted

Similarly trivial one-module JSON encoder/decoder:
https://gitlab.com/zxq9/zj

Tetris implemented in Erlang/Wx:
https://gitlab.com/zxq9/erltris
Blog/video posts:
Part 1 https://zxq9.com/archives/1882
Part 2 https://zxq9.com/archives/1886
Part 3 https://zxq9.com/archives/1894

A simple telnet chat server with channels:
https://gitlab.com/zxq9/trash_talk
Blog/video post: https://zxq9.com/archives/1872

Hopefully the above don't put you completely to sleep.

If you are interested in pursuing the MUD/game-server angle 
specifically, I've got a bit of experience in this particular niche area 
and we can discuss issues that come up specifically in the realm of 
writing Erlang game servers.

-Craig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.