TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

BEAM languages, Hindley–Milner type systems, and new technologies

202 点作者 pyotrgalois将近 10 年前

5 条评论

rubyn00bie将近 10 年前
Nice article, and for an Elixir fan, provides a nice little snippet on something I&#x27;ve been having issues with but hadn&#x27;t really put my finger on until I saw it:<p>&quot;[...] and I really dislike that Elixir tries to hide immutability. That does make it slightly easier for beginners, but it’s a leaky abstraction. The immutability eventually bleeds through and then you have to think about it.&quot;<p>I don&#x27;t think it necessarily tries to hide it (at all), but it does have some instances where something feels like a mutable structure. Those can be, at least for me, a bit confusing to reason about if you&#x27;re expecting things both be and look immutable.<p>I suppose now that I know exactly what&#x27;s weird, I should just go dig through the code and figure it out. Problem solved?<p>... One other thing, because I see this in the comments already, is that BEAM isn&#x27;t the tool for every job-- but for some jobs, it is the only tool to do it well. Is the JVM faster at general tasks? Hell yes, but that&#x27;s not the point, it&#x27;s not even why BEAM is around.<p>It&#x27;s about:<p>* Small concurrent workloads. Really long running CPU intensive tasks aren&#x27;t going to be good.<p>* Low latency. Not just low, but with a very very small standard deviation. Your application&#x27;s performance will be consistent.<p>* Fault tolerant.<p>The list goes on, and here&#x27;s a nice summary of it (both bad and good):<p><a href="http:&#x2F;&#x2F;blog.troutwine.us&#x2F;2013&#x2F;07&#x2F;10&#x2F;choose_erlang.html" rel="nofollow">http:&#x2F;&#x2F;blog.troutwine.us&#x2F;2013&#x2F;07&#x2F;10&#x2F;choose_erlang.html</a><p>There are times when I choose the JVM, there are times when I choose BEAM or MRI. I just try choose the right tool for the job, but some tools, make some jobs, very difficult.<p><i>cough</i> ruby <i>cough</i> concurrency <i>cough</i><p>Edit: One thing for people not familiar with BEAM, a &quot;process&quot; is not a Unix process, from the Elixir documentation:<p>&quot;Processes in Elixir are extremely lightweight in terms of memory and CPU (unlike threads in many other programming languages). Because of this, it is not uncommon to have tens or even hundreds of thousands of processes running simultaneously.&quot;
评论 #10030489 未加载
johlo将近 10 年前
It&#x27;s surprising that the BEAM support for operations and management is very rarely mentioned. To me this is the key selling point for using BEAM vs JVM or something else.<p>Being able to open a remote console and do system introspection&#x2F;tracing&#x2F;profiling&#x2F;debugging is a huge advantage when running in production. And all languages running on top of BEAM ofc get this for free.<p>In my experience, running JVM in production with tools like JProfiler&#x2F;VisualVM&#x2F;jconsole, etc. does not come close to the BEAM when trying to understand what is happening in the system.
评论 #10033480 未加载
abrgr将近 10 年前
&quot;It’s not going to be too much longer before we declaratively describe out systems as well as our code. I am looking forward to that.&quot;<p>Amen! Been doing that to the extent possible for a while and it is terrific!
评论 #10029048 未加载
jdimov9将近 10 年前
Here&#x27;s a tool that you can play with to see how well Elixir scales with an embarrassingly parallel task (matrix multiplication) when throwing more CPU cores at it: <a href="https:&#x2F;&#x2F;github.com&#x2F;a115&#x2F;exmatrix" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;a115&#x2F;exmatrix</a>
评论 #10029513 未加载
pron将近 10 年前
BEAM is a very nice VM (albeit rather slow compared to HotSpot or V8), but I don&#x27;t understand why every mention of BEAM has to spread misconceptions about the JVM:<p>&gt; In many systems, Java included, the Garbage Collector (GC) must examine the entire heap in order to collect all the garbage. There are optimizations to this, like using Generations in a Generational GC, but those optimizations are still just optimizations for walking the entire heap. BEAM takes a different approach, leveraging the actor model on which it is based: If a process hasn’t been run, it doesn’t need to be collected. If a process has run, but ended before the next GC run, it doesn’t need to be collected<p>Well, how does BEAM know which process ran (so that its garbage should be collected)? Bookkeeping, of course, and that is also &quot;just an optimization&quot;. Similarly, if a JVM object hasn&#x27;t been touched since the last collection -- it doesn&#x27;t need to be examined.<p>&gt; If, in the end, the process does need to be collected, only that single process needs to be stopped while collection occurs<p>And new HotSpot GCs rarely stops threads at all for more than a few milliseconds (well, depending on the generation; it&#x27;s complicated), collecting garbage <i>concurrently</i> with the running application, and other JVMs have GCs that never ever stop any thread for more than 20us (that&#x27;s microseconds or so).<p>While BEAM&#x27;s design helps it achieve good(ish) results while staying simple, the fact is that the effort that&#x27;s gone into HotSpot gets it better results for even more general programs (collecting concurrent, shared data structures -- like ETS -- too).<p>I&#x27;ve said it before and I&#x27;ll say it again: Erlang is a brilliant, top notch language, which deserves a top-notch VM, and the resources Erlang&#x2F;BEAM currently have behind them are far too few for such a great language. Erlang&#x27;s place is on the JVM. JVMs are used for many, many more soft-realtime (and hard-realtime) systems than BEAM, and yield much better performance.<p>An implementation of Erlang on the JVM (Erjang) done mostly by one person, was able to beat Erlang on BEAM in quite a few benchmarks, and that was without the new GCs, the new (or much improved) work-stealing scheduler and the new groundbreaking JIT (which works extremely well for dynamically-typed languages[1]).<p>OpenJDK could free Erlang programs from having to write performance-sensitive code in C (so many Erlang projects are actually mixed Erlang-C projects). While Erlang can be very proud of how much it&#x27;s been able to achieve with so little, instead of fighting the JVM (or, rather, JVMs), it should embrace it. Everyone would benefit.<p>[1]: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;chrisgseaton&#x2F;status&#x2F;586527623163023362" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;chrisgseaton&#x2F;status&#x2F;586527623163023362</a> , <a href="https:&#x2F;&#x2F;twitter.com&#x2F;chrisgseaton&#x2F;status&#x2F;619885182104043520" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;chrisgseaton&#x2F;status&#x2F;619885182104043520</a>
评论 #10028312 未加载
评论 #10028326 未加载
评论 #10029062 未加载
评论 #10029112 未加载
评论 #10029349 未加载