[erlang-questions] Maze alternate example for Rosetta Code

Bill Durksen bdurksen@REDACTED
Fri Feb 12 16:31:53 CET 2016


Hi there,

To learn Erlang, I have recently switched from "learn you some Erlang" 
(http://learnyousomeerlang.com) to building actual programs.

My first real Erlang program was a multi-process, multi-host, 
wxWidgets-based file-transfer application with 768 lines of Erlang code.
I was surprised how simple it is to get this distributed functionality 
built, cleanly, in Erlang.
Much appreciation goes to [erlang-questions]-subscribers, who guided me 
to various solutions when I needed an Erlang implementation of the 
Singleton design pattern.
The 'ets' dictionary solution worked for me, after I figured it out.

Currently, I am finishing a Maze-generation program (114 lines of packed 
Erlang code), and have put the final version up on the Rosetta Code 
web-site.
(see the http://rosettacode.org/wiki/Maze_generation#Erlang 
...Alternative example (implemented with 2 diagraphs)).

 From doing this experiment, I have a few questions:

1. The original Erlang maze-generation code (same Rosetta web-site page) 
used a light-weight process for each vertex in the maze.
     This is a very good example of how the Erlang process architecture 
can support many light-weight processes.
     I was surprised that it actually worked, until I tried generating a 
bigger maze.
     When I used the original Erlang maze example to generate a maze of 
25 columns x 4000 rows, it brought my PC down to a crawl.
     I couldn't do anything (I am running Windows 7 64-bit on 9 GB of 
RAM) until I killed EPMD from Task Manager.
     Even after killing EPMD, it took quite a while for the computer to 
get back to normal again, which indicates that it may not have been EPMD 
causing the problem.

     Here is the question (part a): should I expect EPMD (or the WERL 
process) to slow to a crawl with 100,000 Erlang processes running on a 
single machine?
                                        (part b): If yes, what would be 
the Erlang programmer's defence tactic against this scenario?

2. 114 packed lines of Erlang code just seems to over-coded for such a 
powerful language.
     Not being an expert, yet, in all the nuances of Erlang, can someone 
suggest ways I can decrease maze.erl code down to 99 lines or less, 
without cheating (removing too many newlines)?

Thanks,
Bill

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160212/186990e2/attachment.htm>


More information about the erlang-questions mailing list