Why use OTP with erlang?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 03:24:00

OTP is a battle-hardened set of design elements and idioms used in the creation of, as Jonas said, fault-tolerant systems among other things (like flexibility, live updates, etc.). In brief you want to use it for these environments, or environments that may grow into these, because a lot of the blood, sweat and tears of creating reliable, stable systems in Erlang is baked into the OTP behaviours and architecture. If you don't use them you'll either not have a fault-tolerant, flexible system or you'll recreate all of the decisions, one flub and error at a time, to create, in the end, what amounts to a clone of OTP.

So the question really is when don't you want to use OTP? You don't need OTP if you're not doing software that's intended to run for a long time with minimal interruption. You don't need OTP if you already have a framework that does its work that you're more familiar with. You don't need OTP if you want to learn (the hard way, perhaps) what decisions are behind OTP's designs. You don't need OTP if the cost of learning it (and there is a cost there!) exceeds the cost of system downtime for your software.

The best way to become familiar with the whys and wherefores of OTP is the OTP Design Principles User's Guide. Where the reasoning isn't directly stated, you can often read between the lines to discover the rationale for each component.

OTP contains some good design patterns for fault tolerant systems e.g. gen_server and supervising that may be interesting. It depends on what you want to do with Erlang.

E.g. If you want to run a website, you may be interesting to use Yaws and if you want a fault-tolerant website you may be using OTP with Yaws for supervision.

OTP also contains behavior patterns that can be useful.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!