ruby elixir
I have been writing Elixir full-time for about a year, but I came to it from Ruby. As you probably know, Elixir was created by a former Ruby developer, José Valim, and his idea was to keep the beautiful syntax of Ruby in Elixir.
我一直在专职撰写Elixir,但我是从Ruby来的。 您可能知道,Elixir由前Ruby开发人员JoséValim创建,他的想法是将Ruby的漂亮语法保留在Elixir中。
In the company I currently work for, we created an Elixir School to help other colleagues start developing in Elixir. They’re mainly Ruby developers, but also some front-end developers want to study it.
在我目前工作的公司中,我们创建了一家Elixir学校,以帮助其他同事开始在Elixir中发展。 他们主要是Ruby开发人员,但也有一些前端开发人员想要研究它。
For one of the lessons, I created slides with a syntax comparison of Elixir, Ruby, and JavaScript. In this article, I would like to share that with you.
对于其中一课,我创建了具有Elixir,Ruby和JavaScript语法比较的幻灯片。 在本文中,我想与您分享。
串 (String)
![Image for post](https://img-blog.csdnimg.cn/img_convert/3fe2c48d8520573d698a1f0b68206de0.png)
原子 (Atom)
![Image for post](https://img-blog.csdnimg.cn/img_convert/d0d6080fc6c1093196428f1c02d547fa.png)
布尔型 (Boolean)
![Image for post](https://img-blog.csdnimg.cn/img_convert/9689adc2fa6b499363585b8b2c15430a.png)
列表与元组 (List vs Tuple)
Lists are stored in memory as linked lists, meaning that each element in a list holds its value and points to the following element until the end of the list is reached. This means accessing the length of a list is a linear operation: we need to traverse the whole list in order to figure out its size.
列表以链接列表的形式存储在内存中,这意味着列表中的每个元素都保留其值并指向下一个元素,直到到达列表的末尾。 这意味着访问列表的长度是线性操作:我们需要遍历整个列表才能确定其大小。
You will find a good explanation in AppSignal article about this, I highly recommend you read it, as it is important to understand.
您将在AppSignal文章中找到关于此的很好的解释,我强烈建议您阅读它,因为它很重要。
地图 (Map)
![Image for post](https://img-blog.csdnimg.cn/img_convert/9fbeb787d3d6d3da103a38daca426e4c.png)
零 (Nil)
![Image for post](https://miro.medium.com/max/9999/1*rWiI4rJLnQePLj24k9Vk_w.png)
插补 (Interpolation)
![Image for post](https://img-blog.csdnimg.cn/img_convert/39f81199cbea289b43c602cdc0a890a0.png)
串联字符串 (Concatenation String)
![Image for post](https://img-blog.csdnimg.cn/img_convert/4cdfce71e281b4b31e6ff2a80bcf226e.png)
串联列表 (Concatenation List)
![Image for post](https://img-blog.csdnimg.cn/img_convert/7fdddb0da92cce36436ba3aa4f5437d9.png)
范围 (Range)
![Image for post](https://img-blog.csdnimg.cn/img_convert/3681afb074788ed2ffa03c9abdc7ed06.png)
If语句和三元运算符 (If statement and Ternary operator)
![Image for post](https://img-blog.csdnimg.cn/img_convert/1d06cf750716df0030ca2a912d3119b2.png)
![Image for post](https://img-blog.csdnimg.cn/img_convert/116c45ac437d5576231352f0c7c7103d.png)
![Image for post](https://img-blog.csdnimg.cn/img_convert/c2ca34cd60cbcc6c11338faa7edf70e3.png)
案例陈述 (Case Statement)
![Image for post](https://miro.medium.com/max/9999/1*hH6uzmbIJwzVtX6WkTsQOg.png)
![Image for post](https://img-blog.csdnimg.cn/img_convert/9151abbf63cb3e210325795e984de8ca.png)
![Image for post](https://img-blog.csdnimg.cn/img_convert/2a0cd9451ce808dc75170e2370fc88ea.png)
管道操作员 (Pipe Operator)
![Image for post](https://miro.medium.com/max/9999/1*aQALwQz97iXwl7_VI-FpGg.png)
理解 (Comprehension)
![Image for post](https://img-blog.csdnimg.cn/img_convert/e90c3f14fda97131e67acaabade69a17.png)
匿名函数 (Anonymous Function)
![Image for post](https://img-blog.csdnimg.cn/img_convert/696f48e714074e60994559b3b7ae0b78.png)
定义模块和功能 (Define Module and Function)
![Image for post](https://img-blog.csdnimg.cn/img_convert/d474d24de499a56d7d014c3b69c79f52.png)
![Image for post](https://img-blog.csdnimg.cn/img_convert/e4c2c9c2477b4f72fd0b6afbccdc4144.png)
![Image for post](https://img-blog.csdnimg.cn/img_convert/030d888cad9bcbf987edf3852626fd38.png)
The links that helped create this article:
有助于创建本文的链接:
翻译自: https://medium.com/better-programming/compare-elixir-with-ruby-and-javascript-syntax-61cf599f262d
ruby elixir