本文主要是介绍elixir开发的项目_对Elixir的看法:高负载开发人员最流行的工具的利弊,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
elixir开发的项目
Why is Elixir/Phoenix achieving such a high rate of adoption in the software development industry? What are the best use cases of this language? Are there any drawbacks when using it? We talked to Sergiy Kukunin, a full-stack developer at Spotlight and an Elixir expert, to find answers to these and other questions.
为什么Elixir / Phoenix在软件开发行业中获得如此高的采用率? 这种语言的最佳用例是什么? 使用时有什么缺点吗? 我们与Spotlight的全职开发人员和Elixir专家Sergiy Kukunin进行了交谈,以找到这些问题和其他问题的答案。
伊凡:为什么长生不老药如此受欢迎? (Ivan: why is Elixir becoming so popular?)
谢尔盖: (Sergey: )
Elixir features principles that are rarely met in other languages. Also, it is based on Erlang which is used for building telecommunication networks. As a result, we have a highly reliable tool for high-load projects that is proven over time.
Elixir具有其他语言很少遇到的原则。 而且,它基于用于构建电信网络的Erlang。 因此,我们为高负荷项目提供了高度可靠的工具,并且该工具已经过时的证明。
This is essential, as in recent years hardware technological progress is slowing down. The performance of one core of the CPU has reached the physical limit of 5 GHz. The only thing manufacturers have come up with to increase the performance of the hardware is to use more and more cores.
这是至关重要的,因为近年来硬件技术的进步正在放缓。 CPU的一个核心的性能已达到5 GHz的物理极限。 制造商唯一想提高硬件性能的方法就是使用越来越多的内核。
The problem with this approach is that you need software that is capable of working with multiple cores in parallel. The classic programming languages are poorly suited for such tasks. When talking about multithreading in, say, C, we know that there is shared memory and several threads that may compete for resources. In such conditions, it is tough to create a reliable code for high-load projects because of random race conditions and segmentation faults.
这种方法的问题在于,您需要能够与多个内核并行工作的软件。 经典的编程语言不太适合此类任务。 当说到C中的多线程时,我们知道存在共享内存和多个线程可能争夺资源。 在这种情况下,由于随机竞争条件和分段错误,很难为高负荷项目创建可靠的代码。
Elixir is effectively solving this problem by introducing a new approach to multithreading.
Elixir通过引入一种新的多线程方法有效地解决了这个问题。
这项技术的核心优势是什么? (What are the core advantages of this technology?)
The first essential characteristic of the language coming from its functional nature is immutability. Once we've created and loaded the data structure (there are no objects in functional languages), we are unable to alter it, except by recreating it from scratch again.
语言的第一个基本特征来自其功能性质,即不变性。 一旦创建并加载了数据结构(功能语言中没有对象),就无法更改它,除非再次从头开始重新创建它。
On the one hand, this peculiarity lifts the entry threshold for using Elixir, as you can't pick one part of an application and try to record something there repeatedly, and end up with everything up and running. On the other hand, this makes the engineer plan an app's architecture more thoroughly.
一方面,这种特殊性提高了使用Elixir的入门门槛,因为您无法选择应用程序的一部分并尝试在其中重复记录某些内容,并最终使一切正常运行。 另一方面,这使工程师可以更全面地规划应用程序的体系结构。
The Elixir virtual machine is literally a mini-OS, where each process has its own memory space. No other process can get into it, borrowing its resources. All a process can do is send a message to another process, with no control how it will process the message. Also, as it is a functional language, there are no data structures that cannot be transmitted between processes, even over the network (unlike the approach used in the object-oriented languages).
Elixir虚拟机实际上是一个微型OS,其中每个进程都有自己的内存空间。 借用它的资源没有其他过程可以进入它。 一个进程可以做的就是将消息发送到另一个进程,而无法控制它将如何处理该消息。 另外,由于它是一种功能语言,因此即使在网络上也没有无法在进程之间传输的数据结构(与面向对象语言中使用的方法不同)。
It is harder to write Elixir code due to the multiple restrictions the runtime applies, and it takes longer than composing something using Java. However, the overall reliability of an application is very high.
由于运行时存在多种限制,因此编写Elixir代码更加困难,并且比使用Java编写代码要花更长的时间。 但是,应用程序的整体可靠性非常高。
有什么药剂可以替代吗? (Are there any alternatives to Elixir?)
The most similar approach is the coroutines used in the Go language. Also, Python’s greenlets and fibers in Ruby provide a similar approach, but there is no runtime as robust and fast available to run them. The developer should decide how to run these coroutines, while Erlang handles that all itself.
最相似的方法是Go语言中使用的协程。 而且,Ruby中的Python的greenlet和fibre提供了类似的方法,但是没有运行时那样健壮和快速地运行它们。 开发人员应决定如何运行这些协程,而Erlang则自行处理。
任何工具都有其缺点。 他们为Elixir干什么? (Any tool has its drawbacks. What are they for Elixir?)
Elixir today is a production-ready tool, but the overall language ecosystem is still a bit too young. In particular, this means you cannot just log in to Stack Overflow and find an answer to any of your possible questions, as you can do for on Ruby, for example. Yes, there are books, courses, and some blogs, but you will need to continually conduct your research and experiments to solve a lot of everyday tasks. This is the main drawback for me.
今天的Elixir是可用于生产的工具,但是整个语言生态系统仍然太年轻。 特别是,这意味着您不能像在Ruby上那样仅登录Stack Overflow并找到任何可能问题的答案。 是的,有书籍,课程和一些博客,但是您将需要不断进行研究和实验以解决许多日常任务。 这是我的主要缺点。
Also, it is harder to test Elixir apps as unit tests are less helpful, and you need to focus more on integration ones. However, you should remember that almost all Elixir functions are clean, which makes unit tests simpler: there is a single output for each input.
此外,由于单元测试的用处不大,因此测试Elixir应用程序更加困难,您需要更多地关注集成应用程序。 但是,您应该记住,几乎所有Elixir函数都是干净的,这使单元测试更加简单:每个输入只有一个输出。
您能描述使用Elixir提供最大效果的情况吗? (Could you describe the case when using Elixir provides maximum results?)
If you do not have any real need for supporting high-loads with millions of requests processed by your app, then Elixir is not a tool you should bother using. However, Elixir is a perfect solution for a real high-load projects. You may not even write all your app using it, but using Elixir for the hottest parts of a system will always be a good idea.
如果您真的不需要通过应用程序处理数百万个请求来支持高负载,那么Elixir就是您不应该使用的工具。 但是,Elixir是真正高负荷项目的理想解决方案。 您甚至可能没有使用它编写所有应用程序,但是将Elixir用于系统中最热的部分总是一个好主意。
In the age of a dynamic internet when users expect very high speeds and an immediate response by any website, especially content-related resources. If you, say, have an online media outlet with lots of concurrent connections from thousands of readers who want to receive news updates instantly, then moving to Elixir will make your life a whole lot easier.
在动态互联网时代,用户期望非常高的速度和任何网站(尤其是与内容相关的资源)的即时响应。 举例来说,如果您拥有一个在线媒体渠道,其中有成千上万的读者希望立即接收新闻更新,同时存在大量并发连接,那么迁移到Elixir可以使您的生活更加轻松。
Personal experience: on one project we had a Node.js web app that was capable of maintaining up to 20,000 connections at one time. After moving to Elixir, this number grew to 80,000 with no changes in the business logic or smth. This result was possible solely because of the better efficiency of the language we used.
个人经验:在一个项目中,我们有一个Node.js Web应用程序,该应用程序能够一次维护多达20,000个连接。 转移到Elixir后,这个数字增长到80,000,而业务逻辑或规模没有变化。 仅由于我们使用的语言效率更高,才有可能获得此结果。
Elixir allows the making of things that were unthinkable just a few years ago, like creating online games that are fully rendered on the server-side using web sockets. There is even an example of the web Snake game written on Elixir with no JavaScript code at all.
Elixir允许制作几年前无法想象的东西,例如创建使用Web套接字在服务器端完全渲染的在线游戏。 甚至有一个用Elixir编写的完全没有JavaScript代码的网络Snake游戏示例。
However, developers should understand that there is no silver bullet. Elixir cannot give you more than the Erlang virtual machine was initially entitled to. It just translates new syntax so that the old-yet-good compiler created by Ericsson in the late 90’s is able to understand it. This is a perfect example of how time-proven technology combined with a new one can open up new possibilities for developers, but there are always some constraints.
但是,开发人员应了解没有灵丹妙药。 Elixir不能为您提供超过最初授权的Erlang虚拟机的收益。 它只是翻译新语法,以便爱立信在90年代末创建的老式编译器能够理解它。 这是一个完美的例子,它证明了经过时间验证的技术与新技术的结合可以为开发人员带来新的可能性,但是总是存在一些限制。
您开始使用Elixir时有何建议? 一个人应该学习哪种技术才能更快地启动和运行? (What is your advice when starting to use Elixir? What technology should one study to get up and running faster?)
Well, the syntax of Elixir has some things in common with Ruby. The languages are entirely different, but it is always good to see symbols and elements you are used to. The simplest thing is to use some of the new Elixir-compatible web-development frameworks. The most popular web framework for Elixir is Phoenix. You should definitely give it a try, especially if you are used to using Ruby on Rails. This will simplify development while still making the app faster and more reliable.
好吧,Elixir的语法与Ruby有一些共同点。 语言是完全不同的,但是最好看看习惯的符号和元素。 最简单的方法是使用一些新的兼容Elixir的Web开发框架。 Elixir最受欢迎的Web框架是Phoenix。 您绝对应该尝试一下,尤其是如果您习惯于使用Ruby on Rails。 这将简化开发,同时仍使应用程序更快,更可靠。
翻译自: https://habr.com/en/post/449522/
elixir开发的项目
这篇关于elixir开发的项目_对Elixir的看法:高负载开发人员最流行的工具的利弊的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!