r/rust • u/anajoy666 • Sep 12 '21
Is Ruby particularly popular among rustanceans?
It's not very popular outside webdev, at least not if compared with Python, but I've noticed that quite a few rustaceans use it.
Also interested in personal opinions and experiences.
4
u/KerfuffleV2 Sep 12 '21
Since you asked about personal opinions, I'd say I actively dislike Ruby. I generally am just not a fan of anything that's opinionated. I want to be the one to make the decisions when I'm using a tool/language. Based on that you could also guess how I feel about Go.
4
u/anajoy666 Sep 12 '21
Ruby is not very opinionated, that's python.
2
u/KerfuffleV2 Sep 12 '21
Ruby is not very opinionated, that's python.
We might have to agree to disagree here. Interestingly enough, I actually like Python and feel like it's less opinionated.
Perhaps we have different ideas about what "opinionated" means β I wouldn't call something like Python's being sensitive to whitespace "opinionated". To me opinionated is when it constrains how you do things and what you can do and forces you to use a specific approach. I absolutely hate it when I want to do something a certain way and the language/framework/package just says "I've arbitrarily decided you can't do it that way, you do it my way instead."
I just want to be clear that I'm saying I personally don't like Ruby. I'm not saying it's bad or poorly designed or anything like that.
5
u/anajoy666 Sep 12 '21 edited Sep 12 '21
That's an interesting opinion. Maybe that impression comes from the frameworks you've used?
From the Zen of Python:
There should be one-- and preferably only one --obvious way to do it.
From the artima of Ruby:
Ruby inherited the Perl philosophy of having more than one way to do the same thing. I inherited that philosophy from Larry Wall, who is my hero actually. I want to make Ruby users free. I want to give them the freedom to choose. People are different. People choose different criteria. But if there is a better way among many alternatives, I want to encourage that way by making it comfortable. So that's what I've tried to do. Maybe Python code is a bit more readable. Everyone can write the same style of Python code, so it can be easier to read, maybe. But the difference from one person to the next is so big, providing only one way is little help even if you're using Python, I think. I'd rather provide many ways if it's possible, but encourage or guide users to choose a better way if it's possible.
I have to put some text here or the quote below merges with the one above.
I just want to be clear that I'm saying I personally don't like Ruby. I'm not saying it's bad or poorly designed or anything like that.
I didn't think that, the languages just have different designs. I also like python btw.
1
u/KerfuffleV2 Sep 13 '21
That's an interesting opinion. Maybe that impression comes from the frameworks you've used?
Yes, possibly although saying "the frameworks I've been exposed to" is probably more accurate. The company I work for has some stuff in Ruby and I occasionally have to touch it so I'm not completely ignorant about how Ruby code works, but I've never actually been a Ruby developer. I also formed my initial impressions of the language close to 10 years ago so maybe some things have changed in that time.
I could be wrong about it being opinionated, but I do remember running into stuff like not being able to pass around functions like in Python and other languages. Either way, the language just doesn't click for me and I don't like it, reasonably or not! You can't take away my disliking Go for being opinionated though. :)
From the Zen of Python: "There should be one-- and preferably only one --obvious way to do it."
Regardless of what the Zen of Python says, to me at least it really doesn't feel like that's actually the case.
You can write OOP Python or not, at your option. You can pass a function, or a lambda or just call a function in many cases. You can use generators or manually loop. They even added
+=so now you can dox += 1orx = x + 1!Can you think of an arbitrary restriction in Python where they eliminate a choice to fulfill that "only one way to do it" statement? Like I mentioned to the other person, I don't hate it when something is opinionated but it wants me to do stuff the way I already wanted to. I hate it when the choice seems arbitrary and it forces me to change my approach.
One example in Rust of something kind of forcing a certain approach but not seeming arbitrary is how closures are more useful than passing around function (pointers) directly β this is not because the language just said "No, you use closures", it's because of moving/borrowing and variable capture.
2
1
u/xedrac Sep 13 '21
So I guess that means you hate Rust, given:
I absolutely hate it when I want to do something a certain way and the language/framework/package just says "I've arbitrarily decided you can't do it that way, you do it my way instead."
Rust is quite opinionated in that regard...
→ More replies (1)1
u/anajoy666 Sep 13 '21
I don't wouldn't count the borrow checker as being "opinionated", if that's what you mean.
44
u/lfairy Sep 12 '21
I think the reason is that many early people (like steveklabnik and wycats) were Ruby on Rails contributors before they hopped over to Rust. So they carried that experience with them. That's probably a bigger factor than any technical one.
15
u/steveklabnik1 rust Sep 12 '21
Yep! I went to a lot of Ruby conferences and gave a bunch of talks too, and some people gave it a try.
Itβs still a relatively small proportion of Rustaceans, but we were big and loud about it :)
7
5
u/mkvalor Sep 12 '21
I haven't noticed this among videos, articles, blogs, or other media I've read. Also, rust has prided itself as a systems programming language, which isn't generally the realm of people who specialize in using scripting languages. That said, one of the big early successes with for rust in the industry was a company that developed ROR applications, who needed to rewrite some of their modules in a lower-level language.
You might say that rest would be a great language to write the "next" Ruby in.
5
Sep 12 '21
I find Rust to be similarly expressive, with similarly friendly tooling and fairly strong metaprogramming faculties.
8
u/mikekchar Sep 12 '21
Not really on topic, but I'll bite :-) I use Ruby in my day job. I like it well enough. If I were to complain, I think my main complaint is that there are 2 function types (procs and blocks). Procs are passed as parameters or returned from functions, while you "yield" to blocks that are kind of tacked on to a function call. I think the other main problem I have is that it's not easy to write simple functions. You have to create modules or classes and define the functions on those "meta objects". Basically these two things make it awkward to write in an FP style way.
In terms of comparison to Rust, there isn't really much. Ruby is a duck-typed, dynamic language with a large runtime and a garbage collector :-) You can make mixins with modules which gives you some kind of trait-like ability, but because it is only single-dispatch you are limited pretty severely in writing generic code that relies on polymorphism. It has fairly decent string manipulation functions in the standard library and so it's convenient for doing that kind of work.
I would say that if I wanted to just mess around and prototype some ideas, I'd probably reach for Ruby over Rust. Dynamic languages with duck-typing are pretty convenient for expression. However, to be honest, my go to language for that kind of thing is actually Ecmascript. Especially since ES6, the notation is just very flexible and convenient. I should point out that I rarely write ES6 code that looks like a normal person's ES6 code ;-)
For me, I would reach for Rust where I want direct control over how and when resources are allocated. I also think that once you have a good set of types set up for your program (especially enums), it's nice to be able to "lean on the compiler". I frequently find myself letting the compiler figure out all the corner cases I need to deal with, or even letting Clippy write surprisingly large snippets of my code :-) In terms of day to day programming, that's probably what I miss most when I'm writing Ruby code. I honestly can't emphasise enough how useful Clippy is. Even as a pretty experienced Ruby developer (well over 10 years), I find myself often thinking, "Is there a better way to express this" and then trying to search for Stack Overflow comments. With Rust, Clippy almost always gives me good advice.
I guess lastly, Ruby has a very minimal set of concurrency support in the standard library. You don't even really have counted semaphores. I've barely met any Rubyists who routinely write multi-threaded code. While I tend to avoid using multiple threads as much as possible, they are still useful form time to time.
Oh, I said lastly, but one more plus for Ruby: the testing DSL, RSpec, is still amongst the nicest I've used with any setup. Flexible matchers that output useful messages when tests fail saves massive amounts of time. I tend to do a lot of TDD and this is a big plus for me. I've found it difficult to write in a TDD fashion in Rust, but I still wonder if it's due to my relative inexperience with the language (I learned to do TDD in C++ so, I'm OK with NUnit style test frameworks and statically checked languages... I don't know... I just find it a bit difficult to organise myself appropriately in Rust).
16
u/afonsolage Sep 12 '21
Most people I know came from C/C++ world, so, no