Live data from Hacker News

Elixir for Ruby developers: the three most important differences

phoenixonrails.com

31–40 of 78 posts

Re: Elixir for Ruby developers: the three most important differences

#31
post #25
post #17

I wrote a similar article for Pythonistas: https://joyyo.app/elixir-for-humans-who-know-python

Nothing personal but I hate blog posts without a date of publication of said post.

Looking at archive.org it could be from today

https://web.archive.org/web/20230000000000*/https://phoenixo...

Re: Elixir for Ruby developers: the three most important differences

#32
IMHO a more fundamental difference is that because of pattern matching and pipelines you'll write code in a very different way and any expectation that Elixir and Ruby are similar will evaporate before the end of the very first day.

However many Class.method names in Ruby's standard library have a match as Module.function in Elixir, by design, to ease the migration of developers. Language developers take note, copy from the language you want to lure developers from.

Re: Elixir for Ruby developers: the three most important differences

#33
post #5

I love Elixir, Phoenix and LiveView. A drawback is the size of the community, and as a function of that, availability of libraries for various things. It is not bad. It is also not great. That said, the community itself deserves high marks for their willingness to help and do so in a friendly manner.

I worked on a Phoenix project for a few years. We had to write our own libraries to access some services from Google and Stripe which have libraries for other languages but it was not difficult. We have to implement only the few HTTP calls we need and we can choose the functions that suit our application instead of learning somebody's else tool.

Re: Elixir for Ruby developers: the three most important differences

#34
post #27

The article section about interpreted vs compiled is incorrect. .exs files are compiled just like .ex files are. The only difference between `elixirc` and `elixir` is that the former creates an artifact on disk, and the latter does not. See https://medium.com/@fxn/how-does-elixir-compile-execute-code... . Also, Ruby is as compiled as Elixir is. Compiled vs interpreted is blurred the moment you compile to bytecode run…

This is a good point because in elixir metaprogramming you can actually have some things happen at compile time. The frameworks use this for performance in a few places.

So if you had different behavior for ex and exs that would cause developer confusion.

Re: Elixir for Ruby developers: the three most important differences

#35
post #31
post #25

Earlier quoted context omitted.

Nothing personal but I hate blog posts without a date of publication of said post.

Looking at archive.org it could be from today https://web.archive.org/web/20230000000000*/https://phoenixo...

There's a date at the bottom of the page.

Re: Elixir for Ruby developers: the three most important differences

#36
post #33
post #5

I love Elixir, Phoenix and LiveView. A drawback is the size of the community, and as a function of that, availability of libraries for various things. It is not bad. It is also not great. That said, the community itself deserves high marks for their willingness to help and do so in a friendly manner.

I worked on a Phoenix project for a few years. We had to write our own libraries to access some services from Google and Stripe which have libraries for other languages but it was not difficult. We have to implement only the few HTTP calls we need and we can choose the functions that suit our application instead of learning somebody's else tool.

GPT-4 is excellent at this - give it code from an existing SDK in Ruby (or whatever) and tell it to rewrite the functions you need in Elixir and it'll get you at least 90% of the way there.

The other day I used this to create an Elixir wrapper around, appropriately enough, the OpenAI API.

Re: Elixir for Ruby developers: the three most important differences

#37
I love Elixir and I have worked with it in past 2 years. (Specially in China)

But I have been free because the company was broken. I really want to keep writing Elixir, are there any remote job opportunities here?

P.S. I also have some experience of React/Nextjs, Ruby and Scala.

Re: Elixir for Ruby developers: the three most important differences

#38
post #26

Earlier quoted context omitted.

> A common elixir answer to "where are all the blog posts" is "read the docs. No, seriously." This is indeed very common the forums, ha. Also common is for people to actually then go read the docs and be like, "Oh crazy, I'm not used to this!" Not to over-sell the quality of the docs, of course they aren't perfect but they really are particularly good.

As a convenient side effect, GPT-4 is actually quite good at coding in Elixir. I tasked it once to find a bug in an Ecto query and it even improved the query‘s structure. I‘d been worried that, as a small-ish language, Elixir would suffer from bad LLM support, but that’s not the case.

My experience has been the total opposite. It can give simple answers but makes up total nonsense for anything non-trivial.

That said, with Ecto I just ask it to give me the SQL query. From there it’s pretty easy to manually write the Ecto equivalent.

Re: Elixir for Ruby developers: the three most important differences

#39
post #34
post #27

The article section about interpreted vs compiled is incorrect. .exs files are compiled just like .ex files are. The only difference between `elixirc` and `elixir` is that the former creates an artifact on disk, and the latter does not. See https://medium.com/@fxn/how-does-elixir-compile-execute-code... . Also, Ruby is as compiled as Elixir is. Compiled vs interpreted is blurred the moment you compile to bytecode run…

This is a good point because in elixir metaprogramming you can actually have some things happen at compile time. The frameworks use this for performance in a few places. So if you had different behavior for ex and exs that would cause developer confusion.

Yeah, if you don't want the code to run when you're compiling it, don't have it do anything until some function is called.

And it would be the same as in another language if you run a program that has no side effects. For instance "python abc.py" will gladly run a abc.py that is empty or has "class ABC: pass" in it.

Re: Elixir for Ruby developers: the three most important differences

#40
post #27

The article section about interpreted vs compiled is incorrect. .exs files are compiled just like .ex files are. The only difference between `elixirc` and `elixir` is that the former creates an artifact on disk, and the latter does not. See https://medium.com/@fxn/how-does-elixir-compile-execute-code... . Also, Ruby is as compiled as Elixir is. Compiled vs interpreted is blurred the moment you compile to bytecode run…

To add to your excellent points: Elixir is compiled ahead of time while Ruby bytecode is generated as the code is loaded, which is probably the source of confusion in this case.

This leads to differences such as Ruby meta-programming happening at runtime, Elixir’s at compile time. The Elixir compiler (the Erlang compiler really) can also afford to do more work at compile-time which then leads to different approaches at the JIT level too.

Post reply on HN