Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a Ruby programmer trying to take a look at Elxir, i still find it hard to read. Maybe functional languages take time to get used to but it doesn't seem as "clear" as procedure or oop style. I know the added benefit of speed and concurrency, but for most apps we build it is not needed for now.

Do any Ruby programmer find Elxir easier to write or read? Im genuinely curious to hear about this because a lot of Ruby devs are writing Elixir.



I'm a proficient Ruby developer (with code in production since 2004).

Ultimately I find it's easier to go back to some Elixir code and understand what it does, compared to Ruby.

The main reason is (to me) the fact that I now see Ruby object instances as "living things" (with always something hidden underneath, that can change), while Elixir types are more like "stable messages".

So yes, I believe doing Elixir maintenance is ultimately going to be easier than with Ruby.

(Note that I work with both Elixir & Ruby now, and also with Node & other platforms, I don't intend to stop using Ruby at all).


I slung Ruby 2008-2015, and started using Elixir heavily in late 2015. Aside from simple scripts that typically involve shelling out to Unix utilities, I find Elixir easier to write in just about all cases at this point. The syntax is even more consistent than Ruby's (to the point that it's homoiconic) and the language docs rule. Once you get a few concepts like pattern-matching and pipelines under your belt, it gets easy.

It was helpful that I wrote a bunch of Scala from 2013-2015, so I was familiar with working in an immutable FP style -- that made it a gentler transition for sure.

What have you found hard to read about it? The community is still settling on what code style "should" look like, so maybe you saw some funky Elixir, or maybe it's something deeper.


> What have you found hard to read about it?

Not the OP, but: keeping state: Agents, GenServers etc. FP/immutable approach does offer some great advantages, but also makes some otherwise trivial stuff (say, something akin to setting an ivar in Ruby) convoluted and tough to read.


Elixir does make you think hard about the global state you keep. It's an "eat your vegetables" decision, and I've acquired the taste. Keeps me out of trouble when designing things. Contrast this to Ruby, where class variables and globals are all over the place and thread safety is a pipe dream. [EDIT: it's not that Ruby-the-language forces this worldview, but Ruby-the-community adopted it and most Gems show the effects of that.]

As far as ivars, you'll have to work hard to emulate that. There are no classes or instances. Probably you want to just use a map or a struct to represent an instance and its state.


When comparing programming languages, it is extremely common for people to mistake familiarity for other things like "clarity" and "simplicity". When looking at code with unfamiliar conventions, they often proclaim tremendously simple, clear code to be "complicated" because it is not what they are accustomed to --even when an equivalent implementation in their fav language would be much more obtuse.

I don't claim to know about your personal situation. Just throwing out a relevant observation.


Ya, in that point, everyone should watch the Simple Made Easy talk by Rich Hickey, creator of Clojure. One of the best talk ever in my opinion.


I've been working full time on a rails app for the last 2+ years.

About 3 weeks ago I dove into Elixir for a big rewrite of a side project as a learning exercise. In the beginning it feels strange, mostly because of the functional way of thinking required and some new types to get used to (structs, keyword lists, etc.). Once you get the hang of it however it feels really, really nice. I dread going back to my rails app now... Others in the thread have stated most of the reasons why so I won't go into that.

I'm looking forward to launching this re-written side project in a few weeks and seeing what the performance is like. (This is currently a stale Django app). Running locally in dev mode the performance (Phoenix) seems like it will be excellent.


I find Erlang itself to be pretty easy to read and write, if a bit repetitive/verbose at times. There are not very many 'magical' things happening; it's all pretty clearly spelled out. Elixir is mostly an improvement on Erlang unless people are getting crazy with the macros.


While learning Elixir and Phoenix, I found Cowboy source code easier to read with no knowledge of Erlang other than what's inferred from learning Elixir than Phoenix's generated app scaffolding.

In Erlang, I look at 'module_name:function_name' I can simply open the module file and look at the function definition.

In Elixir, I had to ask "Was this function aliased?", "Is it imported from a module? Which module?", "Was it imported/aliased through a use statement?" The code was more concise, but harder to read IMO. Of course you can simply reference functions by their full name in Elixir as well, which is what I'm doing with my own code.


Phoenix tends to do .... interesting things with macros. It's not your typical Elixir application.

I find my IDE to be helpful in this situation, since all macros are compile time and thus can be unwrapped by the IDE.


What IDE do you use for Elixir? Thanks.


I use IntelliJ and Atom. I'm actually still deciding which is better.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: