Idiomatic Erlang?

zxq9 zxq9@REDACTED
Wed Jul 28 01:27:05 CEST 2021

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):
* `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:

Tetris implemented in Erlang/Wx:
Blog/video posts:
Part 1
Part 2
Part 3

A simple telnet chat server with channels:
Blog/video post:

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.


More information about the erlang-questions mailing list