Live data from Hacker News

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

youtube.com

21–30 of 50 posts

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

#21
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.

I'll take "everything is an object if you represent it as a process" over Ruby's everything is an object.

I think the former encompasses the true essence of what Alan Kay have stated when he coined the term OOP. Joe Armstrong and Alan Kay had a talk about how Erlang is more OOP than most languages.

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

#22

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…

Maybe an Elixir vs Crystal discussion for ex-Ruby programmers would be appropriate.

Crystal's advantages over Elixir would be static typing, compile time performance, binaries, and having something like 80 percent of Ruby's syntax. The last one is for people who do like Ruby as a language. Elixir is only superficially similar to Ruby in some syntactic ways.

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

#23
post #15
post #7

Earlier quoted context omitted.

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…

(Replying to myself for the sake of readability:)

All that being said, Ruby (and Smalltalk; and, oddly enough, Javascript) aren't just object-oriented; they go beyond this, into being fully object-based, which is a different thing that Elixir (because of the Erlang VM's architecture) would have a very hard time being.

Ruby—the whole thing—is a graph of objects in a VM, where everything Ruby code does translates to sending a particular message to an object in that graph. The objects themselves start with some responses-to-messages that involve primitives, but if Ruby had a bytecode, it wouldn't contain those primitives, or any way to define them. It'd just be a set of ops to construct values on the stack, and then a send() op. Ruby code effectively boils down to a wire protocol used to speak to a Ruby VM's object graph server. It's all communication, no "client-side" behavior.

So in Ruby, there are no primitives. From the perspective of the VM, 3 might be an unboxed integer primitive; but from the perspective of your Ruby code, it's an object and you have to send messages to it (i.e. to the object-graph server addressed to it.) Ruby code has no way to "operate on" a primitive 3 without asking the object-graph server to do that operating for it.

This is why Ruby "is slow" (and still suboptimal after JIT, due to never being able to drop runtime type checks), but at the same time, it's also why Ruby lets you override Integer#+, and have that effect apply throughout the whole VM. It's why you can re-open a class and define methods on it, when that class is actually a DRb remote object handle. It's why Ruby's Complex and Rational types don't need "first-class" support in order to work with code that never heard of them. Everything is a black box, and so everything is forced to be message-sends to those black boxes. There are no primitives, and so there's no code that expects primitives, which you could break by defying that expectation.

---

As well, Ruby, like Smalltalk, and like Javascript, is image-based: these are languages without an abstract-machine primitive to "load a module." There are no modules. There is only the object graph.

"Library" code in these languages isn't in a "dead" form that gets dumped into VM memory and linked in with symbolic references; instead, it's the source code to a program, a program that gets evaluated when require()d. This program is much like an SQL migration: it can do anything regular code can do, but it usually sends one or more messages to the object-factory-factory member of the graph (i.e. Ruby's Class) asking it to make a new object-factory; and then sends messages to that object-factory, asking it to add mappings from some passed symbol values, to some passed lambda values (i.e. to define some instance methods.)

Smalltalk is a bit different in that Smalltalk has "image-based persistence", meaning the VM can hibernate, and so there's less infrastructure around "loading a bunch of libraries in a tree at VM startup", and more infrastructure around "purging the effects of old libraries and loading new ones." Less like an OS boot process; more like an OS with a package-manager that can install/uninstall packages that start/stop services. But fundamentally, it's the same idea: Smalltalk source code is a migration that executes on the Smalltalk VM to mutate the [persistent] VM object graph.

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

#24

Earlier quoted context omitted.

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…

And I completely agree with this, I have just posted the above example to show that Elixir's syntax can be concise too in case anyone would want that. :)

What Elixir has changed for me, is that I now value the explicitness of my code more than ever. And thanks to this, I aim to write code like this in other languages I use on daily basis (Ruby, Python).

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

#25
post #7

Earlier quoted context omitted.

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.

I'll take "everything is an object if you represent it as a process" over Ruby's everything is an object. I think the former encompasses the true essence of what Alan Kay have stated when he coined the term OOP. Joe Armstrong and Alan Kay had a talk about how Erlang is more OOP than most languages.

All that being said, Ruby is much more like Smalltalk than Elixir or Erlang are. Smalltalk does have inheritance and classes, and does the kind of meta stuff easily that Ruby supports. Objects and classes are as central to Smalltalk's design as message passing is.

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

#26

Earlier quoted context omitted.

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…

And I completely agree with this, I have just posted the above example to show that Elixir's syntax can be concise too in case anyone would want that. :) What Elixir has changed for me, is that I now value the explicitness of my code more than ever. And thanks to this, I aim to write code like this in other languages I use on daily basis (Ruby, Python).

For sure. I just think a lot of new people get caught up in the ability to be concise for self that they forget about the expressiveness for others. Unrelated, we also abandoned 1 pipe pipelines, and instead prefer "function(arg)". Just looks better to us, despite the minor maintenance cost of having to change it if you convert to multiple pipes.

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

#27

Earlier quoted context omitted.

I'll take "everything is an object if you represent it as a process" over Ruby's everything is an object. I think the former encompasses the true essence of what Alan Kay have stated when he coined the term OOP. Joe Armstrong and Alan Kay had a talk about how Erlang is more OOP than most languages.

All that being said, Ruby is much more like Smalltalk than Elixir or Erlang are. Smalltalk does have inheritance and classes, and does the kind of meta stuff easily that Ruby supports. Objects and classes are as central to Smalltalk's design as message passing is.

To touch on what digitalzombie said however, Kay did not originally picture inheritance as being part of OOP.

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

#28

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…

Elixir and Ruby are so different, they shouldn't even be allowed to be compared. If you don't think so, try and write some medium-sized code challenges in both and see how different the implementations come out (try more than 3 because sometimes you can express the same idea in both in a similar way).

"You gain a lot over Ruby and lose very little."

"...better in almost every way."

These are very shortsighted assertions. As engineers we should strive be a little more objective and at least mention pros and cons of both choices.

For example, is ease of deployment important to you and your project? How do these languages compare there? Try not to get blinded by the honeymoon phase with a language.

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

#30
post #7

Earlier quoted context omitted.

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.

alternatively it is the most object oriented language
Post reply on HN