<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Tue, Jan 10, 2017 at 10:58 AM, Bhag Chandra <span dir="ltr"><<a href="mailto:bhag.chandra.erl@gmail.com" target="_blank">bhag.chandra.erl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello,</div><div><br></div><div>I have been coding in Erlang for 2 years.  A wonderful language but not very big community, so I cant discuss my questions with programmers around me (Java, Python guys). I found out about this list today.</div><div><br></div><div>I have some fundamental doubts about the Erlang. It would be great if someone can help me clarify them.</div><div><br></div><div><br></div>1) "Strings in Erlang are internally treated as a list of integers of each character's ASCII values, this representation of string makes operations faster. For example, string concatenation is constant time operation in Erlang."  Can someone explain why?<div><div><br></div></div></div></blockquote><div><br></div><div>The description of a string's internal representation is correct, but concatenation is O(n). Most people end up using binaries of utf8 encoded text instead of strings (lower constant factors), and iolists to concatenate data for output (which is constant time, since you're just a rose tree of data to be traversed later).</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div></div><div>2) "It makes sense to use Erlang only where system's availability is very high".  Is it not a very general requirement of most of the systems? Whatsapp to Google to FB to Amazon to Paypal to Barclays etc they all are high availability systems, so we can use Erlang in all of them?</div></div></div></blockquote><div><br></div><div>You can use Erlang any time, but high availability in distributed systems is where Erlang is a better fit than many other options. Whatsapp in particular does use Erlang. The reasons not to use Erlang in these situations are generally related to familiarity and momentum.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>3) "Every message which is sent to a process, goes to the mailbox of that process. When process is free, it consumes that message from mailbox". So how exactly does process ask from the mailbox for that message? Is there a mechanism in a process' memory which keeps polling its mailbox. I basically want to understand how message is sent from mailbox to my code in process.</div><div><br></div><div>4) We say that a message is passed from process A to process B by simply using a bang (!) character, but what happens behind the scenes to pass this message? Do both processes establish a tcp connection first and then pass message or what?</div></div></div></blockquote><div><br></div><div>There's plenty written on these topics available in this list archive and various places online. I'd start by searching for "erlang scheduler" and then scan for the bits that talk about messages and mailboxes. TCP connections are only involved when sending messages between separate notes in distributed erlang, local messages are sent and received by manipulating local data structures.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>5) At 30:25 in this video ( <a href="https://youtu.be/YaUPdgtUYko?t=1825" target="_blank">https://youtu.be/YaUPdgtUYko?<wbr>t=1825</a> ) Mr. Armstrong is talking about the difference between the context switching overhead between OS threads and Erlang processes. He says, thread context switching is of order 700 words but Erlang process context switching is ... ?</div><div>I cant understand what he said, if someone could tell.</div></div></div></blockquote><div><br></div><div>Words is a measure of memory, an Erlang process (by default) has an overhead of 309 words according to the efficiency guide. <a href="http://erlang.org/doc/efficiency_guide/processes.html">http://erlang.org/doc/efficiency_guide/processes.html</a></div><div> </div><div>-bob</div><div><br></div></div></div></div>