Node.js 或 Erlang

发布于 2024-09-04 20:10:05 字数 211 浏览 3 评论 0原文

当谈到它们可以处理的并发级别时,我真的很喜欢这些工具。

Erlang/OTP 看起来是更稳定的解决方案,但需要更多的学习和深入研究函数式语言范例。看起来 Erlang/OTP 在多核 CPU 方面做得更好(如果我错了,请纠正我)。

但我应该选择哪一个呢?从短期和长期角度来看,哪一个更好?

我的目标是学习一种工具,使我在高负载下扩展 Web 项目比传统语言更容易。

I really like these tools when it comes to the concurrency level it can handle.

Erlang/OTP looks like much more stable solution but requires much more learning and a lot of diving into functional language paradigm. And it looks like Erlang/OTP makes it much better when it comes to multi-core CPUs (correct me if I am wrong).

But which should I choose? Which one is better in the short and long term perspective?

My goal is to learn a tool which makes scaling my Web projects under high load easier than traditional languages.

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

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

发布评论

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

评论(9

仙女 2024-09-11 20:10:05

我想尝试一下 Erlang。尽管这将是一个更陡峭的学习曲线,但您会从中获得更多,因为您将学习函数式编程语言。此外,由于 Erlang 是专门为创建可靠、高度并发的系统而设计的,因此您将同时了解如何创建高度可扩展的服务。

I would give Erlang a try. Even though it will be a steeper learning curve, you will get more out of it since you will be learning a functional programming language. Also, since Erlang is specifically designed to create reliable, highly concurrent systems, you will learn plenty about creating highly scalable services at the same time.

肩上的翅膀 2024-09-11 20:10:05

我不能代表 Erlang,但有一些关于 Node 没有提到的事情:

  • Node 使用 Google 的 V8 引擎将 javascript 实际编译成机器代码。所以节点实际上相当快。因此,这是事件驱动编程和非阻塞 io 提供的速度优势之上的。
  • Node 有一个非常活跃的社区。跳到他们在 freenode 上的 IRC 小组,你就会明白我的意思了。
  • 我注意到上面的评论推动了 Erlang,因为学习函数式编程语言是有用的。虽然我同意扩展你的技能并掌握其中一项技能很重要,但你不应该将项目建立在你想学习新的编程风格的事实之上。
  • 另一方面,Javascript 已经处于你认为的范式中写起来舒服!另外,它是 JavaScript,因此当您编写客户端代码时,它看起来和感觉上都是一致的。
  • Node 的社区已经推出了大量的模块!有 redis、mongodb、couch 等模块。另一个值得研究的好模块是 Express (想想 Sinatra 的节点)

查看 雅虎博客上的视频,由 Ryan Dahl 制作,他是 Node 的真正编写者。我认为这将帮助您更好地了解节点所在的位置以及它的去向。

请记住,节点仍处于后期开发阶段,因此已经经历了相当多的更改 - 这些更改破坏了早期的代码。然而,据推测,现在您可以期望 API 不会发生太多变化。因此,如果您正在寻找一些有趣的东西,我认为 Node 是一个不错的选择。

I can't speak for Erlang, but a few things that haven't been mentioned about node:

  • Node uses Google's V8 engine to actually compile javascript into machine code. So node is actually pretty fast. So that's on top of the speed benefits offered by event-driven programming and non-blocking io.
  • Node has a pretty active community. Hop onto their IRC group on freenode and you'll see what I mean
  • I've noticed the above comments push Erlang on the basis that it will be useful to learn a functional programming language. While I agree it's important to expand your skillset and get one of those under your belt, you shouldn't base a project on the fact that you want to learn a new programming style
  • On the other hand, Javascript is already in a paradigm you feel comfortable writing in! Plus it's javascript, so when you write client side code it will look and feel consistent.
  • node's community has already pumped out tons of modules! There are modules for redis, mongodb, couch, and what have you. Another good module to look into is Express (think Sinatra for node)

Check out the video on yahoo's blog by Ryan Dahl, the guy who actually wrote node. I think that will help give you a better idea where node is at, and where it's going.

Keep in mind that node still is in late development stages, and so has been undergoing quite a few changes—changes that have broke earlier code. However, supposedly it's at a point where you can expect the API not to change too much more. So if you're looking for something fun, I'd say node is a great choice.

寒江雪… 2024-09-11 20:10:05

我是一名长期的 Erlang 程序员,这个问题促使我看一下 Node.js。看起来非常不错。

看来您确实需要生成多个进程才能利用多个核心。不过,我看不到任何有关设置处理器关联性的信息。您可以在 Linux 上使用任务集,但它可能应该在程序中进行参数化和设置。

我还注意到平台支持可能有点弱。具体来说,您似乎需要在 Cygwin 下运行才能获得 Windows 支持。

不过看起来不错。


Edit

Node.js 现在具有对 Windows 的本机支持。

I'm a long-time Erlang programmer, and this question prompted me to take a look at node.js. It looks pretty damn good.

It does appear that you need to spawn multiple processes to take advantage of multiple cores. I can't see anything about setting processor affinity though. You could use taskset on linux, but it probably should be parametrized and set in the program.

I also noticed that the platform support might be a little weaker. Specifically, it looks like you would need to run under Cygwin for Windows support.

Looks good though.


Edit

Node.js now has native support for Windows.

2024-09-11 20:10:05

对于多个项目,我正在寻找与您相同的两种替代方案。

到目前为止,我想出的针对给定项目在它们之间做出决定的最佳剃刀是我是否需要使用 Javascript。我想要迁移的一个现有系统已经是用 Javascript 编写的,因此它的下一版本很可能是在 Node.js 中完成的。其他项目将在一些 Erlang Web 框架中完成,因为没有现有的代码库可以迁移。

另一个考虑因素是,Erlang 的扩展能力远远超出了多个核心,它可以扩展到整个数据中心。我在 Node.js 中没有看到一个内置机制可以让我向另一个 JS 进程发送消息而不用关心它在哪台机器上,但它是在 Erlang 的最低级别内置的。如果你的问题不够大,不需要多台机器,或者不需要多个协作进程,那么这个优势可能并不重要,所以你应该忽略它。

Erlang确实是一个需要潜入的深潭。我建议在开始构建网络应用程序之前先编写一个独立的功能程序。更简单的第一步是尝试以更函数式的风格编写 JS,因为您似乎对 Javascript 很熟悉。如果您使用 jQuery 或 Prototype,那么您已经开始走这条路了。尝试在 Erlang 或其同类之一(Haskell、F#、Scala...)和函数式 JS 中的纯函数式编程之间切换。

一旦您熟悉了函数式编程,就可以寻找众多 Erlang Web 框架之一;在这个后期阶段,您可能不应该直接将应用程序编写到诸如 inets 之类的低级内容。例如,看看之类的东西。

I'm looking at the same two alternatives you are, gotts, for multiple projects.

So far, the best razor I've come up with to decide between them for a given project is whether I need to use Javascript. One existing system I'm looking to migrate is already written in Javascript, so its next version is likely to be done in node.js. Other projects will be done in some Erlang web framework because there is no existing code base to migrate.

Another consideration is that Erlang scales well beyond just multiple cores, it can scale to a whole datacenter. I don't see a built-in mechanism in node.js that lets me send another JS process a message without caring which machine it is on, but that's built right into Erlang at the lowest levels. If your problem isn't big enough to need multiple machines or if it doesn't require multiple cooperating processes, this advantage isn't likely to matter, so you should ignore it.

Erlang is indeed a deep pool to dive into. I would suggest writing a standalone functional program first before you start building web apps. An even easier first step, since you seem comfortable with Javascript, is to try programming JS in a more functional style. If you use jQuery or Prototype, you've already started down this path. Try bouncing between pure functional programming in Erlang or one of its kin (Haskell, F#, Scala...) and functional JS.

Once you're comfortable with functional programming, seek out one of the many Erlang web frameworks; you probably shouldn't be writing your app directly to something low-level like inets at this late stage. Look at something like Nitrogen, for instance.

转瞬即逝 2024-09-11 20:10:05

虽然我个人会选择 Erlang,但我承认我对 JavaScript 有一点偏见。我的建议是,您评估以下几点:

  1. 您是否重用这些语言中的任何一种语言中的现有代码(无论是在源代码方面,还是在程序员经验方面!)
  2. 您是否需要/想要在不停止应用程序的情况下进行即时更新(这是Erlang 默认获胜 - 它的运行时是针对这种情况设计的,并且 OTP 包含所有必要的工具)
  3. 就单独的并发操作而言,而不是带宽而言,预期流量有多大?
  4. 您对每个请求执行的操作的“并行性”程度如何?

Erlang 确实对并发性和并发性进行了微调。网络透明的并行分布式系统。根据项目的具体内容,此类系统的成熟实现的可用性可能比学习新语言的任何问题更重要。还有另外两种可以在 Erlang VM 上运行的语言,即类似于 Ruby/Python 的 Reia Lisp 风格的 Erlang

另一种选择是同时使用两者,特别是在 Erlang 被用作“集线器”的情况下。我不确定 Node.js 是否有外部函数接口系统,但如果有的话,Erlang 有 C 库供外部进程与系统交互,就像任何其他 Erlang 进程一样。

While I'd personally go for Erlang, I'll admit that I'm a little biased against JavaScript. My advice is that you evaluate few points:

  1. Are you reusing existing code in either of those languages (both in terms of source code, and programmer experience!)
  2. Do you need/want on-the-fly updates without stopping the application (This is where Erlang wins by default - its runtime was designed for that case, and OTP contains all the tools necessary)
  3. How big is the expected traffic, in terms of separate, concurrent operations, not bandwidth?
  4. How "parallel" are the operations you do for each request?

Erlang has really fine-tuned concurrency & network-transparent parallel distributed system. Depending on what exactly is the project, the availability of a mature implementation of such system might outweigh any issues regarding learning a new language. There are also two other languages that work on Erlang VM which you can use, the Ruby/Python-like Reia and Lisp-Flavored Erlang.

Yet another option is to use both, especially with Erlang being used as kind of "hub". I'm unsure if Node.js has Foreign Function Interface system, but if it has, Erlang has C library for external processes to interface with the system just like any other Erlang process.

没有伤那来痛 2024-09-11 20:10:05

看起来 Erlang 在相对低端的服务器(512MB 4 核 2.4GHz AMD VM)中部署表现更好。这是来自 SyncPad 对比 Erlang 和 SyncPad 的经验虚拟白板服务器应用程序的 Node.js 实现。

It looks like Erlang performs better for deployment in a relatively low-end server (512MB 4-core 2.4GHz AMD VM). This is from SyncPad's experience of comparing Erlang vs Node.js implementations of their virtual whiteboard server application.

铜锣湾横着走 2024-09-11 20:10:05

在同一个虚拟机上还有一种语言就是 erlang -> Elixir

这是 Erlang 的一个非常有趣的替代品,看看这个。

另外它还有一个基于它的快速增长的Web框架-> Phoenix 框架

There is one more language on the same VM that erlang is -> Elixir

It's a very interesting alternative to Erlang, check this one out.

Also it has a fast-growing web framework based on it-> Phoenix Framework

同尘 2024-09-11 20:10:05

如果没有 erlang,whatsapp 永远无法达到可扩展性和可靠性的水平 https://www.youtube.com/watch ?v=c12cYAUTXXs

whatsapp could never achieve the level of scalability and reliability without erlang https://www.youtube.com/watch?v=c12cYAUTXXs

执笔绘流年 2024-09-11 20:10:05

相比 Node,我更喜欢 Erlang。
如果你想要并发,Node 可以用 Erlang 或 Golang 代替,因为它们的轻量级进程。

Erlang 不容易学习,需要付出很大的努力,但它的社区很活跃,可以从中获得帮助,这就是人们更喜欢 Node 的原因。

I will Prefer Erlang over Node.
If you want concurrency, Node can be substituted by Erlang or Golang because of their light weight processes.

Erlang is not easy to learn so requires a lot of effort but its community is active so can get help from that, this is only the reason why people prefer Node .

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