Live data from Hacker News

Ruby vs Elixir – Panel discussion at Wroc_love.rb [video]

youtube.com

11–20 of 50 posts

Re: Ruby vs Elixir – Panel discussion at Wroc_love.rb [video]

#11
post #7

I think it comes down to this: with Elixir, you gain a lot over Ruby and lose very little. Any Elixir app will be significantly more performant and reliable than its Ruby counterpart. This is due to several reasons: - Elixir runs on a battle-tested virtual machine, and stuff like supervisor behavior (e.g. auto-restart of crashing processes) is built right in - Elixir is a functional language, which makes the code you…

Playing around with Elixir, it seems like it loses Ruby's Smalltalk like "everything is an object" that allows things like: > 4.even? => true That's not to say that what Elixir provides is (or is not) worth giving up everything-is-an-object because Erlang's design does what it is supposed to do very very well.

Elixir isn't an object-oriented language.

Re: Ruby vs Elixir – Panel discussion at Wroc_love.rb [video]

#12
post #3

I think it comes down to this: with Elixir, you gain a lot over Ruby and lose very little. Any Elixir app will be significantly more performant and reliable than its Ruby counterpart. This is due to several reasons: - Elixir runs on a battle-tested virtual machine, and stuff like supervisor behavior (e.g. auto-restart of crashing processes) is built right in - Elixir is a functional language, which makes the code you…

I love Elixir, and came from Ruby. I do find it hard to describe to people why I like it more it more. There is no one thing that is a killer feature to me. I do not miss inheritance at all.

IMO, Elixir appeals to developers who have experienced the challenges of the established code bases because you immediately realize the long term benefits of the way it's designed. I've noticed a pattern at least that it seems to appeal to people with more experience because it's easier to recognize what the little details bring.

Re: Ruby vs Elixir – Panel discussion at Wroc_love.rb [video]

#13

I think it comes down to this: with Elixir, you gain a lot over Ruby and lose very little. Any Elixir app will be significantly more performant and reliable than its Ruby counterpart. This is due to several reasons: - Elixir runs on a battle-tested virtual machine, and stuff like supervisor behavior (e.g. auto-restart of crashing processes) is built right in - Elixir is a functional language, which makes the code you…

It's different, but I'm not sure that makes it better than Ruby. You listed three advantages for Elixir. Are there none for Ruby? Language design involves tradeoffs. Are there no tradeoffs for being immutable and functional?

You're right that there are always tradeoffs, but it isn't clear that Ruby takes the other side of many of Elixir's. Some examples: Elixir requires a VM installed on the target machine (unlike Go, C, C++, etc.), it doesn't have strong type checking (unlike Java, Scala, Haskell, etc.), it doesn't have a strong data science story (unlike Python and R), it can't be conveniently used as a dual front- and back-end language (unlike javascript, TypeScript, etc.). But Ruby is on the same side of all those tradeoffs.

Someone mentioned that Ruby is more useful for scripts because libraries can be installed and used at the system level; that seems true to me, so that's one example. But I think the main tradeoff that Ruby wins on is maturity. Which is a big deal to be sure.

Re: Ruby vs Elixir – Panel discussion at Wroc_love.rb [video]

#15
post #7

I think it comes down to this: with Elixir, you gain a lot over Ruby and lose very little. Any Elixir app will be significantly more performant and reliable than its Ruby counterpart. This is due to several reasons: - Elixir runs on a battle-tested virtual machine, and stuff like supervisor behavior (e.g. auto-restart of crashing processes) is built right in - Elixir is a functional language, which makes the code you…

Playing around with Elixir, it seems like it loses Ruby's Smalltalk like "everything is an object" that allows things like: > 4.even? => true That's not to say that what Elixir provides is (or is not) worth giving up everything-is-an-object because Erlang's design does what it is supposed to do very very well.

Imagine Ruby, if you had to explicitly namespace every method call with the mix-in that contains the method, so that 1. there could never be collisions between method names, and 2. finding mix-in method definitions at compile time was context-free. It'd maybe look a bit like this:

    > 4.Integer::even?
    => true
Just chew the syntax a bit, and that's Elixir's:

    > 4 |> Integer.even?
    => true
Mind you, that has nothing to do with "everything is an object." An object is—in the original Lisp+Smalltalk sense—effectively:

1. a stateful closure,

2. which you call with args representing a "message" to send to the object,

4. where the object is free to respond to that message however it likes—i.e. you can code the closure-that-is-the-object however you like—and its responses can depend on its state, meaning that the messages it responds to, and even its internal logic, can mutate over time, as this state changes.

Well, we've got plenty of "objects" in Erlang/Elixir land. We call those "processes." And they are cheap enough that—if you wanted—you could code in an "everything is a process" style. Presuming we defined two modules, ObjectFactory and Object, as GenServers with the requisite functions:

    {:ok, obj_f} = ObjectFactory.start_link
    foo = obj_f |> ObjectFactory.make_object!
    foo |> Object.extend(:bar, fn -> 3 end)
    foo |> send(:bar)
    # => 3
All Object.extend/2 needs to do its job is to store something in the GenServer's state, and to rely on Object's GenServer.handle_info/2 callback to do something with that state.

Now, mind you, this won't magick a Bar module into existence to make this API pretty. But there's nothing stopping you from defining one yourself—or even from creating a Mixin module that you could Kernel.use/1 in your mix-in modules, giving them an API Object.extend/1 could understand, and giving you the ability to:

    foo |> Object.extend(Bar)
    foo |> Bar.bar

Re: Ruby vs Elixir – Panel discussion at Wroc_love.rb [video]

#16

Earlier quoted context omitted.

It's different, but I'm not sure that makes it better than Ruby. You listed three advantages for Elixir. Are there none for Ruby? Language design involves tradeoffs. Are there no tradeoffs for being immutable and functional?

You're right that there are always tradeoffs, but it isn't clear that Ruby takes the other side of many of Elixir's. Some examples: Elixir requires a VM installed on the target machine (unlike Go, C, C++, etc.), it doesn't have strong type checking (unlike Java, Scala, Haskell, etc.), it doesn't have a strong data science story (unlike Python and R), it can't be conveniently used as a dual front- and back-end languag…

> Ruby is more useful for scripts because libraries can be installed and used at the system level

There's no reason Elixir can't do this. Or rather, for interactive scripting under iex(1) without a project scope, there's nothing stopping someone from adding a feature that

1. assumes some default project scope (e.g. "~/.mix/default"), and

2. allows you—even from within the REPL!—to add a dependency to "~/.mix/default/mix.exs", re-run the dependency constraint solver, and (if successful) compile + reload the Mix project, or (if failed) back out the mix.exs change.

On the other side, for the use-case of "scripts as standalone redistributable binaries", I prefer Elixir's philosophy of "everything is vendored, always"—the [redistributable form of the] script just has all its deps inside it, much like SPA Javascript apps do.

It's indeed true, though, that you can't achieve a hybrid of these use-cases: have your own personal set of IEx libraries loaded and able to be used to probe and debug within an existing Mix project that contains its own set of libraries, where these libraries' dep specifications—if combined in a single Mixfile—wouldn't constraint-solve. That is an annoying problem that I run into quite often, especially because Elixir doesn't ship with many tools I'd like to use during debugging, like a JSON library, and I end up having to alter the project's own Mixfile to add these deps, rather than just "bringing in" my own.

At root, that problem is a semi-architectural problem with the Erlang VM: modules are indexed by [fully qualified] name, so—unlike in Javascript—you can't have "handles to" two modules with the same name. (But, actually, there's nothing about the design of Erlang or Elixir that requires the Erlang VM to work that way; it could be fixed, if people thought it'd be helpful.)

Re: Ruby vs Elixir – Panel discussion at Wroc_love.rb [video]

#17
post #6

I think it comes down to this: with Elixir, you gain a lot over Ruby and lose very little. Any Elixir app will be significantly more performant and reliable than its Ruby counterpart. This is due to several reasons: - Elixir runs on a battle-tested virtual machine, and stuff like supervisor behavior (e.g. auto-restart of crashing processes) is built right in - Elixir is a functional language, which makes the code you…

Former Ruby, now Elixir, developer here and I agree. The one use case where Ruby still wins for me, though, is a little one-off script. Last time I had occasion to do that, I found you couldn't use any Elixir hex packages without generating a whole mix application. In ruby you could just globally install the gem and require it right into your script. I forget why this came up, but I think it was something like just w…

Mix tasks are what you're looking for. You put them inside your application (we have them in /appa/your_app /lib/mix/tasks), define a run/1 function that takes in args, say "use Mix.Task", then you can make sure that things like Ecto are loaded and interact with your program's major entities, or use Poison or whatever it is that you care to do.

Re: Ruby vs Elixir – Panel discussion at Wroc_love.rb [video]

#18

Earlier quoted context omitted.

There's basically data and functions, so 4 wouldn't really have any methods attached to it and instead you'd just call Number.even?(4). Purely psuedo code example. It's a deep subject but one of the biggest things is that it's virtually impossible to end up with the untenable monolith that many ruby apps eventually grow into. Since you aren't dealing with crazy inheritance trees attached to data separating things out…

Or like this, thanks to the pipe operator 4 |> Integer.is_even Above can be even shortened if you import Integer module: import Integer (...) 4 |> is_even

Collectively at work, we've abandoned the use of import, except when importing DSLs (e.g. Ecto) in favor of explicit function calls or alias. If we do need to use import, we use explicit "import Ecto.Query, only: [from: 2]", so that it's clear where a function is coming from into the namespace. Relatedly, unless otherwise necessary, __using__ macros through our code do not import modules, because it's surprising when something is in scope for no real reason. We often inline the third party __using__ macros to eliminate this.

Re: Ruby vs Elixir – Panel discussion at Wroc_love.rb [video]

#19

I am falling for Elixir. However, my big drawback that made me stay in Ruby is the community don't seem to like NoSQL solutions like MongoDB and you can feel it in the libraries and global architecture.

It's just that they have their own ways of expressing it, using things like ETS, DETS, mnesia, Riak-core, depending on your use cases and consistency requirements.

Re: Ruby vs Elixir – Panel discussion at Wroc_love.rb [video]

#20

I think it comes down to this: with Elixir, you gain a lot over Ruby and lose very little. Any Elixir app will be significantly more performant and reliable than its Ruby counterpart. This is due to several reasons: - Elixir runs on a battle-tested virtual machine, and stuff like supervisor behavior (e.g. auto-restart of crashing processes) is built right in - Elixir is a functional language, which makes the code you…

It seemed like in the panel they just kept looping back to the performance and concurrency, to which the Ruby guys would say "So what, Ruby is fast enough for 99% of apps", completely ignoring all of the other strengths of Elixir.

Because Elixir is better than Ruby in webapp space, in term of speed, you don't need to reach for caching and complex backend solution as early as RoR.

I think this is a big win.

Post reply on HN