<p>Hi all<br/>
What is the difference between Erlang and Golang concurrency?<br/>
Thanks</p>
<hr/>**评论:**<br/><br/>vruin: <pre><p>If you mean the programming model: </p>
<blockquote>
<p>Processes in Elixir/Erlang are the equivalent of Goroutines in Go, lightweight threads of execution independent from the system’s thread. But Elixir implements Erlang’s actor model in which the lightweight threads are the main entity which is directly addressable. When you spawn an Elixir process you get a PID that you can use to send messages to that process, the process can pattern match the messages received to decide what it is and what to do.</p>
<p>The channel of communication is completely transparent to the processes, and in fact multiple VMs can be connected in a mesh network so you can send messages transparently to other processes in any other computer in your network. Multiple processes can be bundled in process groups allowing you to send messages to the whole group in order to distribute the load. Since the network is transparent to the processes, there is no debate microservices vs monolith, you can switch between the 2 models with minimal effort.</p>
<p>This actor model contrasts with Go’s CSP model, in which the communication channel is the main addressable entity and the goroutines are anonymous and can not be addressed directly.</p>
</blockquote>
<p><a href="https://texlution.com/post/elixir-concepts-for-golang-developers/#processes" rel="nofollow">https://texlution.com/post/elixir-concepts-for-golang-developers/#processes</a></p></pre>itsamemmario: <pre><p>Thanks, I never looked at it that way.</p></pre>SulfurousAsh: <pre><p>Great explanation! Thanks for sharing</p></pre>sybrandy: <pre><p>That is a fantastic explanation. I'm glad it touched on the fact that processes in Elixir/Erlang are addressable whereas goroutines aren't. If there was one feature that I wish could be added to Golang with respect to goroutines it would be to be able to directly address them so they could be monitored. E.g. supervisor pattern.</p></pre>ecmdome: <pre><p>Any idea of a library/initiative in Go that tries to mimic the communication of the actor model?</p></pre>zero_coding: <pre><p>then I feel erlang has better concurrency then go? </p></pre>vruin: <pre><p>CSP vs Actors? That's a matter of taste. </p>
<p>If you mean the whole network transparency thing, depends on what your app does. Erlang is a higher level language designed for distributed "control plane" applications, the abstractions it provides can have big performance costs when applied to other problems. Go is a lower level, more general purpose language.</p></pre>mickael: <pre><p>In both cases, inspiration is taken from Communicating Sequential Processes (CSP) paper from Tony Hoare.</p>
<p>They have slight semantic difference but can achieve satisfy the same type of properties.</p>
<p>I recommend watching Rob Pike explaining the origin of Go Concurrency: <a href="https://www.youtube.com/watch?v=3DtUzH3zoFo" rel="nofollow">https://www.youtube.com/watch?v=3DtUzH3zoFo</a></p></pre>joshburgess: <pre><p>Elixir (Erlang with nicer syntax) is Go's main competitor right now when it comes to high traffic, high performance web servers, IMO. Of course, like others have said, it's not as good for CPU heavy tasks, but for most web stuff it's very promising... It's a totally different language though. Completely functional (not multiparadigm) and embraces modern FP language features. I think a microservices approach that leverages both languages for things they excel at could be very powerful.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传