Live data from Hacker News

Rust for Rubyists

matthias-endler.de

21–30 of 45 posts

Re: Rust for Rubyists

#21

Earlier quoted context omitted.

Exactly [1,2,3,4,5].select{|x| x%2 == 0} If I were interviewing a a Ruby dev, anything other than Array#select indicates lack of experience.

That seems a bit shallow. I’ve been Rubying for 10 years and have always preferred find_all over select. select turns up in other APIs having different meanings (thinking of IO specifically); find_all tells you exactly what it’s going to do. Just my opinion, of course.

For me, it's always been select/reject/detect. Even though I know about find_all, it always seemed like the odd one out.

Re: Rust for Rubyists

#22
> With iter(), you get a "read-only view" into the vector. After the iteration, it will be unchanged.

> With into_iter(), you take ownership over the vector. After the iteration, the vector will be gone. In Rust terminology, it will have moved.

I stopped reading right there. No Rubist or actually nobody, except real time system developers, should care about ownership.

It makes programming so much more complicated without any real benefit, again apart from real time systems.

Re: Rust for Rubyists

#23
post #22

> With iter(), you get a "read-only view" into the vector. After the iteration, it will be unchanged. > With into_iter(), you take ownership over the vector. After the iteration, the vector will be gone. In Rust terminology, it will have moved. I stopped reading right there. No Rubist or actually nobody, except real time system developers, should care about ownership. It makes programming so much more complicated wit…

Lol. If you want to hamstring yourself by not utilizing powerful concepts, then go ahead, but don't thrust that onto others. The concept of moving a value is powerful and useful when designing APIs. You can use it to basically encode a finite state machine into your API, with the property that once a state is used for a transition, it can't be reused.

Re: Rust for Rubyists

#25
post #22

> With iter(), you get a "read-only view" into the vector. After the iteration, it will be unchanged. > With into_iter(), you take ownership over the vector. After the iteration, the vector will be gone. In Rust terminology, it will have moved. I stopped reading right there. No Rubist or actually nobody, except real time system developers, should care about ownership. It makes programming so much more complicated wit…

[deleted]

Re: Rust for Rubyists

#26

Earlier quoted context omitted.

Exactly [1,2,3,4,5].select{|x| x%2 == 0} If I were interviewing a a Ruby dev, anything other than Array#select indicates lack of experience.

That seems a bit shallow. I’ve been Rubying for 10 years and have always preferred find_all over select. select turns up in other APIs having different meanings (thinking of IO specifically); find_all tells you exactly what it’s going to do. Just my opinion, of course.

I always use select and I've been writing Ruby since 2006. I didn't even remember find_all exists. As a name select reflects what I want it to do, find_all much less (this is very subjective). Furthermore it's easier to type. Luckily we have both and everyone is happy.

Re: Rust for Rubyists

#27
post #13
post #3

Earlier quoted context omitted.

Or apparently the even more common functional list operations: “map”, “for_each”, “filter”, “every”, etc.

Well, unless your language is "go" in which case it converges on no good package management and no functional filter/map/reduce functions

Literally the worst thing about that language. Such a common operation, and every time it comes up I end up iterating over ranges like a caveman.

Re: Rust for Rubyists

#28
post #2

It's nice to see languages converging on a standard set of features. String interpolation, random number generation, package management, etc.

Though I don't quite like the part about package managers. The more of them is language specific, the more entrenched in the language development is, the more difficult is to develop multilingual code, and the more projects depend on random stuff from the internets for no good reason, like in the infamous left-pad farce.

Re: Rust for Rubyists

#29
post #11
post #7

Earlier quoted context omitted.

If I'm writing ruby I'd prefer Array#select for this task.

That’s an alias for `find_all`.

That's one beautiful thing about Ruby. There's not just one way to do it, which means that .select and .find_all may be aliases but both are valid and will show up, depending on the author's preference.

Re: Rust for Rubyists

#30
Nice article, I bookmarked it. I am just now learning Rust because I want to use an open source blockchain library/framework written in Rust. Ruby used to be my favorite language until a career in machine learning literally forced me to swap scripting languages. I also really like Haskell (plug: I wrote a Haskell book) and I find that Rust borrowed many good ideas from Haskell.
Post reply on HN