构建商业系统:纯 Erlang 还是 Erlang/OTP?
我即将用 Erlang 构建一个系统(使用多个 CPU 可以更好地解决我的问题)并且我已经浏览过:
- 学习一些 Erlang;
- Erlang/OTP 实际应用
- Erlang 编程 (Armstrong);
- Erlang 编程(Cesarini)。
《Erlang/OTP in Action》一书 (2) 说:“……编写非 OTP Erlang 代码确实是一个高级主题,只有当您确实必须这样做时才应该这样做。所以也许从来没有这样做过非 OTP 方式是一种祝福,因为您将立即养成关于 OTP 的正确习惯...”
(2) 坚持认为商业系统应该仅使用 OTP 构建,而 (4) 温和地表明 OTP 不是做到这一点的唯一方法。
此外,通过阅读 (4),我发现从 Erlang 的基础知识构建知识有助于理解 OTP 的工作原理(但不是相反)。
所以,问题是: 我应该选择 Erlang/OTP 来构建商业系统还是可以用纯 Erlang 来完成?
I am about to build a system with Erlang (my problem can be solved better with multiple CPUs) and I have skimmed through:
- Learn You Some Erlang;
- Erlang/OTP in Action
- Programming Erlang (Armstrong);
- Erlang Programming (Cesarini).
The Erlang/OTP in Action book (2) says: "...writing non-OTP Erlang code is really an advanced topic, and something that should be done only when you really really have to. So perhaps not ever having done it the non-OTP way is a blessing because you will pick up the right habits straight away with regard to things OTP..."
(2) insists that commercial systems should be built with OTP only, whilst (4) gently shows that OTP is not the only way to do this.
Additionally, by reading (4) I have found out that building the knowledge from the very basics of Erlang helps to understand how OTP works (but not in the opposite way).
So, the question is:
Should I choose Erlang/OTP to build a commercial system or can it be done with pure Erlang?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
与纯 Erlang 一起学习和玩耍。
在 Erlang/OTP 中构建系统。
Learn and play with pure Erlang.
Build systems in Erlang/OTP.
是的,可以,但要遵守 Greenspun 的第十条规则:您的系统将包含广告一半 OTP 的临时、非正式指定、错误缠身、实施缓慢。
Yes, it can, subject to the analogue of Greenspun's Tenth Rule: your system will contain an ad hoc, informally-specified, bug-ridden, slow implementation of half of OTP.
OTP 是用 Erlang 编写的,因此它绝对可以在纯 Erlang 中完成。话虽这么说,OTP 为您提供了许多有用的功能,否则您需要自己编写这些功能。 @Alexey 是对的,你最终会实现 OTP 的一部分。问题在于,OTP 提供的构建容错系统所需的框架本身必须非常无故障。
我也会回应@Mazen,在纯 Erlang 中进行实验可以让您很好地了解 OTP 内部发生的情况以及如何在 Erlang 中构建容错系统。之后您将更好地利用 OTP。您将更好地理解何时不使用 OTP 以及原因。
OTP is written in Erlang so it definitely can be done in pure Erlang. That being said OTP provides you with a lot of useful functionality which you would otherwise need to write yourself. @Alexey is right than you will end up implementing a portion of OTP along the way. The problem is that the framework you need for building fault-tolerant systems, which OTP provides, has to itself be very fault-free.
I will also echo @Mazen in that experimenting with doing it in pure Erlang gives you a good feel for what is going on internally in OTP and how you can build fault-tolerant systems in Erlang. You will make better use of OTP afterwards. You will come to a better understanding when not to use OTP, and why.
如果您通读“学习一些 Erlang”(就像您所说的那样),您会注意到作者花费了 设计并发应用程序章节在“plain Erlang”中构建了一些半有用的东西。然后在接下来的两章中,他基本上抛弃了所有这些,并使用 OTP 以少得多的代码实现相同的事情(此外,因为它是 OTP 代码,所以它是标准的 - 所以其他熟悉 OTP 的开发人员将会有更好地了解从哪里去了解它!)
OTP 已经与大量开发人员一起开发和完善了很多年(根据维基百科,最初发布于 1998 年),并且一家大型国际公司(爱立信)的支持,并经过同行评审,因为它都是开源的。我认为假设您可以单独构建同样强大且可扩展的东西有点大胆!
因此,请使用 OTP。即使对于“玩”项目,仍然使用 OTP,因为它只能帮助您学习如何使您的“商业”代码变得更好:)
If you read through the "Learn You Some Erlang" (like you said you have) you'll notice the author spends the Designing a Concurrent Application chapter building something half-useful in "plain Erlang". Then in the next 2 chapters, he basically throws it all away, and uses OTP to achieve the same thing with far less code (add to that the fact that because it's OTP code, it's standard - so other developers with familiarity with OTP will have a much better idea of where to look to understand it!)
The OTP has been developed and refined over a lot of years (initial release 1998 according to Wikipedia) with a large number of developers, and the backing of a large international company (Ericsson), and peer reviewed as it's all open source. I think it'd be a little audacious to assume you could single-handledly build something equally robust and scalable!
So use the OTP. Even for "play" projects, still use the OTP as it can only help you learn to make your "commercial" code better :)