Node 的 Web Workers 会破坏 erlang 吗?

发布于 2024-10-09 12:37:46 字数 341 浏览 10 评论 0原文

我很好奇 Erlang 是否会被 Node.js 杀死,因为 Node.js 非常流行、速度很快并且拥有 网络工作人员 。是否可以?为什么?

但是多处理器呢 并发?线程不是必需的吗 将程序扩展到多核 电脑?流程是必要的 扩展到多核计算机,而不是 内存共享线程。这 可扩展系统的基础是 快速网络和非阻塞 设计——剩下的就是消息传递。在 未来的版本中,Node 将能够 派生新进程(使用 Web Workers API )非常适合 当前设计。

I'm curious if Erlang could be killed by Node.js which could be extreme popular, fast and have web workers. Is it possible? Why?

But what about multiple-processor
concurrency? Aren't threads necessary
to scale programs to multi-core
computers? Processes are necessary to
scale to multi-core computers, not
memory-sharing threads. The
fundamentals of scalable systems are
fast networking and non-blocking
design—the rest is message passing. In
future versions, Node will be able to
fork new processes (using the Web
Workers API ) which fits well into the
current design.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

明月夜 2024-10-16 12:37:46

Node.js 和 Erlang 是大草原上截然不同的野兽。

示例:

Node.js 以协作多任务模型为中心,让人想起 Python Twisted 或 Rubys EventMachine。相反,Erlang 是一个抢占式多任务系统,配有调度程序等。

Node.js 实现了 JavaScript,这是一种基于原型的 OO 语言,具有命令式基础和多种功能思想。 Erlang 本质上以通常的函数式风格实现了增强的 lambda 演算。

Node.js 主要以一台机器为中心,每个请求都按顺序处理。即将推出的 Web Worker 和多节点扩展让您可以使用机器的所有 CPU。 Erlang 旨在无缝集成多个节点,这些节点旨在让一组(多个)Erlang 物理机彼此无缝通信。

Node.js 采用大多数语言中常见的主动故障缓解立场。另一方面,Erlang 采取反应式故障缓解立场:系统的构建是为了即使发生无法解释的错误也能生存。最坏的情况是让另一台物理机器接管。

Node.js 严重依赖 JIT 来获得速度。 Erlang 是一种更标准的编译语言。其后果是,Erlang 可能更适合软实时,因为一段代码的挂钟时间通常更可预测。

讨论:

您应该清楚,两种语言解决所提出问题的方法有很大不同。因此,出于这个原因,保留两者可能是值得的。换句话说,我不认为一种语言会完全取代另一种语言。 Node.js 具有熟悉度。 Erlang 在鲁棒性方面具有独特的优势。

免责声明:我破解了 Erlang。

Node.js and Erlang are quite different beasts on the savannah.

Examples:

Node.js is centered around a cooperative multitasking model, reminiscent of Python Twisted or Rubys EventMachine. Erlang, on the contrary, is a preemptively multitasked system complete with schedulers and so on.

Node.js implements JavaScript which is a prototype-based OO language with an imperative base and several functional ideas. Erlang implements, essentially, an augmented lambda-calculus in the usual functional style.

Node.js is centered mostly around a single machine, where each request is handled in order. The coming Web workers and the multi-node extension let you use all CPUs of the machine. Erlang is designed to seamlessly integrate multiple nodes, which are meant to be used to let a cluster of (more than one) Erlang physical machine be seamlessly communicating to each other.

Node.js takes the usual stance of proactive fault-mitigation found in most languages. Erlang on the other hand takes a reactive fault-mitigation stance: the system is built to survive even if errors otherwise unaccounted for occur. In the worst case by letting another physical machine take over.

Node.js relies heavily on JIT to obtain speed. Erlang is a more standard compiled language. The ramifications is that Erlang may be better suited for soft-realtime as the wall-clock time of a piece of code is usually more predictable.

Discussion:

It should be clear to you that the approach to the proposed problem is vastly different from the two languages. Hence, it is probably worth keeping both around for this very reason. In other words, I don't think one language will completely replace the other. Node.js has a familiarity strength. Erlang has a distinct strength w.r.t. robustness.

disclaimer: I hack Erlang.

深空失忆 2024-10-16 12:37:46

不太可能。

  • 由于 JS 的可变数据结构,在处理共享数据时有更多的搬起石头砸自己脚的方法。
  • Erlang 解决方案可以轻松、透明地进行集群; Node.js 似乎没有提供类似的支持。
  • Erlang VM 似乎提供了更多工具来查看正在运行的系统。
  • Erlang 是静态编译的,并且有一些静态类型支持;这通常会提高可靠性。
  • V8 运行速度快只是因为 JIT,而 JIT 往往会消耗大量内存。 Erlang 的 VM 可能可以在相同的 CPU 和内存预算下处理更多的负载。

Node.js 确实有很多优点,但这些优点似乎都无法取代 Erlang。我希望 Node.js 能够取代 PHP :)

Not quite probable.

  • With mutable data structures of JS, there are much more ways to shoot oneself in the foot while handling shared data.
  • Erlang solutions can be easily and transparently clustered; node.js doesn't seem to provide comparable support.
  • Erlang VM seemingly provides more tools to look at running systems.
  • Erlang is compiled statically and has some static typing support; this usually increases reliability.
  • V8 runs fast only because of JIT, and JIT often consumes lots of memory. Erlang's VM can probably handle more load at the same CPU and memory budget.

Node.js surely has a number of upsides, but none of these seem to be going to oust Erlang from its place. My hope that node.js will oust PHP instead :)

懒的傷心 2024-10-16 12:37:46

Node.js 是对“如何通过将事件循环连接到具有极少代码行的语言上来构建高效的并发系统”这一问题的答案。这个问题本身也很精彩。

Erlang 是对并发问题的更完整的答案,语言、编译器、库,一切都是从头开始围绕容错、分布和并发构建的。

Erlang 优点的完整列表?这是一个很长的清单,我没有那么多时间。一些示例:

  • 一种轻量级、可扩展的并发机制(进程),而不是轻量级并发机制(事件)加上重量级并发机制(Web Worker)
  • 进程之间的主管层次结构
  • 软实时功能(由于语言设计、编译器和运行时支持)
  • 进程维护一个调用堆栈,node.js 中的事件忘记它们来自哪里,这使得错误消息/堆栈跟踪变得不那么有洞察力,
  • 不需要以连续传递样式嵌套括号/缩进来创建回调,事件循环和连续传递是受管理的通过编译器/运行时

Node.js 具有使用 JavaScript 的明显优势,因此在 Node.js 足够好的地方(在很多地方),它可能会在受欢迎程度方面击败 Erlang。

Node.js is an answer to the question "How do you build an efficient concurrent system by bolting an event loop onto a language with ridiculously few lines of code". And the question itself is kind of brilliant, too.

Erlang is a much more complete answer to the concurrency-problem, the language, the compiler, the libraries, everything is build around fault tolerance, distribution and concurrency from the ground up.

A full list of Erlang's advantages? That's a long list, I don't have that much time. A few samples:

  • one lightweight, scalable concurrency mechanism (processes) instead of a lightweight one (events) plus a heavyweight one (web workers)
  • supervisor hierarchies among processes
  • soft real-time capabilities (due to language design, compiler and runtime support)
  • processes maintain a call stack, events in node.js forget where they come from, which makes error messages/stack traces a lot less insightful
  • no need to nest parentheses/indentation in continuation passing style to create callbacks, the event loop and continuation passing are managed by compiler/runtime

Node.js has the distinct advantage of using JavaScript, so it will probably beat Erlang in terms of popularity wherever node.js is good enough, which is in a whole lot of places.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文