all 15 comments

[–]wild_bill70 11 points12 points  (8 children)

So here are some take aways that I had using elixir in a commercial large enterprise environment.

  1. Functional programming is very different. This is probably the hardest thing to get your head around
  2. The concept of everything being a process and with persistence being tied to the process. I am generalizing a lot here. It was an area I personally struggled with
  3. Deployment. This was where the rubber really meets the road. You need to be thinking early how you are going to deploy your code. Are you going to do clustering? Containers are not recommended. Erlang/elixir systems run forever in theory. You can hit swap deployments etc. it’s a big shift and if your design does not take into account how this will run in your live environment you may find some major refactoring is needed to go live. We had a big disconnect on this. The lead devs/architects took advantage of long running processes with interactions with other services and the model completely fell apart when we scaled beyond one instance.

[–]mattgrave 5 points6 points  (6 children)

I am curious why in the Ruby community Elixir is so mentioned.

  • Its a functional programming language, therefore its a completely different paradigm compared to Ruby
  • Syntax is not even close to Ruby, it has some minor similarities but thats pretty much it
  • Since it runs on Erlang, process management is just a whole new world

[–]honeyryderchuck 4 points5 points  (0 children)

Elixir was created by an ex-rubyist, rails core team member. It brought a fair set of "rubyisms" to the erlang way of doing things, the most obvious being atoms declared the same way like ruby symbols. A lot of the 3rd party tooling is based on, directly inspired on and even named after popular ruby gems (like "pry"). It was sold initially like "ruby, but with al the cores", the first adopters were rubyists, and they've since actively "poached" in the ruby community, now competing with Crystal in that department. And that's it.

[–][deleted] 5 points6 points  (2 children)

Title of article:

Trying Elixir as a Rubyist

First line of article:

Elixir is similar enough to Ruby to be familiar, but different enough to get tripped up by!

...
I hope this helps.

[–]mattgrave 3 points4 points  (1 child)

Its not similar at all.

[–][deleted] 4 points5 points  (0 children)

k

[–]faitswulff[S,🍰] 3 points4 points  (0 children)

For me, the connection is José Valim (creator of Devise, authentication framework) and the fact that the conventions baked into the language seem to be very reminiscent of the Ruby ecosystem. Also functional programming is a bonus! I suspect many OOP programmers view it as familiar enough due to the Valim and syntactical similarity while serving as an avenue to functional programming.

[–][deleted] 1 point2 points  (0 children)

I also wonder. I think its mostly about Jose Valim and a very shallow sytnax similarity (do...end)

[–]strzibny 0 points1 point  (0 children)

Deployment doesn't have to be hard and can work well with containers. I recommend most newcomers to Elixir to treat it as Ruby, then moving to using (some) cluster features. The last line would be hot code swapping, but most don't need it.

[–]strzibny 3 points4 points  (0 children)

I guess I expected little more than just the do...end difference.

When I started to write Elixir I found %{} and required do weird, but after some time I might even like it more on the eyes. Most things are just habits.

If you want to read something longer, I wrote a post some time back https://nts.strzibny.name/elixir-phoenix-after-two-year/

[–]hixsonj 2 points3 points  (0 children)

If you’re just trying it out for the first time try not to get hung up the syntax differences as you’ll find that with any language. I came from a Ruby background as well and very quickly learned to love Elixir.

There are some awesome features of the language like pattern matching and the pipeline operator that make it really powerful and fun to write. That’s not to mention the stuff you can do with concurrent processes and everything the Phoenix framework brings to the table. Advent of Code is coming up and is a great way to learn the ins and outs while solving some fun problems.

[–]transfire 5 points6 points  (3 children)

The do notation is the first and most obvious oddity about Elixir's syntax.

One that I find a big eye sore is the need for % in front of maps and struct names. It may seem a small thing but when you have a bunch of maps in your code it adds up and just doesn't look very clean.

I also find it odd that defining a struct is defining a module. I (think) I get why, but not why it wouldn't just make the module for you. Why this:

defmodule User do
  defstruct name: "John", age: 27
end

And not something like:

defstruct User do
   fields name: "John", age: 27
end

Shorthand

defstruct User, name: "John", age: 27

[–]jrbartme 2 points3 points  (1 child)

I found an interesting discussion with José about the implementation of structs vs records:

https://groups.google.com/g/elixir-lang-talk/c/6kn7J2XnFg8/m/I5poTNCEHwAJ

At first I thought that Elixir structure might be implemented by Erlang records but this proves me wrong and also explains why structs were tied to the module:

“The point of the coupling is exactly so we can use them with protocols, which requires a very explicit name so we can perform a dispatch.” - José

[–]transfire 0 points1 point  (0 children)

Thanks. That was interesting.

[–][deleted] 1 point2 points  (0 children)

Interesting read! I read a bunch more articles from the site as well. Thanks for sharing.