TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Rust for Rubyists

144 pointsby omn1over 7 years ago

11 comments

isaacgover 7 years ago
The filter_map explanation is wrong. .ok() converts a result to an Option, not a boolean. Likewise, filter_map expects an option. That&#x27;s how it can both filter and map.<p>Docs: <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;result&#x2F;enum.Result.html#method.ok" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;std&#x2F;result&#x2F;enum.Result.html#method...</a>
评论 #16003994 未加载
werdnapkover 7 years ago
The example for even numbers should be:<p>even_numbers = [1, 2, 3, 4, 5].find_all { |element| element.even? }<p>or<p>even_numbers = [1, 2, 3, 4, 5].find_all(&amp;:even?)<p>instead of:<p>even_numbers = [1, 2, 3, 4, 5].map { |element| element if element.even? }
评论 #16002477 未加载
评论 #16002472 未加载
freedombenover 7 years ago
Good post, although it served to remind me again how much I love Ruby for it&#x27;s emphasis on being elegant and expressive. I may not reach for it first for anymore for standing up a new service, but I still use it for personal projects and scripts unless there&#x27;s a compelling reason not to.
cheezover 7 years ago
It&#x27;s nice to see languages converging on a standard set of features. String interpolation, random number generation, package management, etc.
评论 #16002377 未加载
评论 #16003833 未加载
weihangloover 7 years ago
Great post. If you are plan to write a native Ruby extension, check out Rust Helix <a href="https:&#x2F;&#x2F;usehelix.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;usehelix.com&#x2F;</a>
mark_l_watsonover 7 years ago
Nice article, I bookmarked it. I am just now learning Rust because I want to use an open source blockchain library&#x2F;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.
chrisrhodenover 7 years ago
The section titled &quot;Implicit returns and expressions&quot; purports to contrast the two when as far as I can tell they work identically.<p>In fact, the article specifically calls out that in Rust, even if expressions have a value, which is also true in Ruby, every expression has a value (though it is sometimes nil).
ngcc_hkover 7 years ago
Or every language complicated enough is reinventing lisp partially.
评论 #16003077 未加载
评论 #16003333 未加载
cjbprimeover 7 years ago
Enjoyed this, thanks for writing!
noncomlover 7 years ago
&gt; With iter(), you get a &quot;read-only view&quot; into the vector. After the iteration, it will be unchanged.<p>&gt; With into_iter(), you take ownership over the vector. After the iteration, the vector will be gone. In Rust terminology, it will have moved.<p>I stopped reading right there. No Rubist or actually nobody, except real time system developers, should care about ownership.<p>It makes programming so much more complicated without any real benefit, again apart from real time systems.
评论 #16003289 未加载
评论 #16004008 未加载
评论 #16003355 未加载
cryptonautover 7 years ago
Minor correction:<p>In the section about converting a vector of strings into integers the article says that the Result returned from parse() is converted to a bool via Result::ok(). However, Result::ok() actually converts the Result&lt;T, E&gt; into a Option&lt;T&gt; which is what filter_map() expects.
评论 #16003968 未加载