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: A Scala Engineer's Perspective

213 pointsby blacksmythealmost 8 years ago

9 comments

saghmalmost 8 years ago
&gt; When handing out references of something bound with let mut, why do i need to do &amp;mut instead of just &amp; ?<p>Sometimes, you still want to immutably borrow a mutable variable. Otherwise, you wouldn&#x27;t be able to have multiple references to a variable declared with `mut`, which would be an unnecessary limitation.<p>EDIT: Here&#x27;s an example of something that wouldn&#x27;t otherwise work if borrows of mutable variables were implicitly mutable:<p><pre><code> struct Point { x: i32, y: i32, } fn add(p1: &amp;Point, p2: &amp;Point) -&gt; Point { let x = p1.x + p2.x; let y = p1.y + p2.y; Point { x: x, y: y } } fn main() { let mut some_point = Point { x: 1, y: 1 }; some_point.x = 2; &#x2F;&#x2F; `some_point` is borrowed twice here, which wouldn&#x27;t be possible if the borrows were mutable. let other_point = add(&amp;some_point, &amp;some_point); println!(&quot;({}, {})&quot;, other_point.x, other_point.y); }</code></pre>
评论 #14465736 未加载
评论 #14462260 未加载
brsonalmost 8 years ago
&gt; As with Swift, I haven’t been able to find conclusive evidence nor credit given to suggest that there was any influence from Scala on Rust …<p>Scala was a significant influence on Rust. Niko did his dissertation in Scala, and several other team members were fans. Let it be known!
评论 #14462740 未加载
评论 #14463661 未加载
kaoDalmost 8 years ago
<p><pre><code> match some_int { &#x2F;&#x2F; Why not Some(&amp; s) =&gt; ... ??? Some(ref s) =&gt; println!(&quot;{}&quot;,s), None =&gt; unreachable!() } </code></pre> To me his proposed syntax looks like the exact contrary use case: pattern-match on something that&#x27;s a reference.<p>EDIT: And that&#x27;s actually the case.<p><a href="https:&#x2F;&#x2F;play.rust-lang.org&#x2F;?gist=017740fbff2c5923dec3cc514bdba2f7&amp;version=stable&amp;backtrace=0" rel="nofollow">https:&#x2F;&#x2F;play.rust-lang.org&#x2F;?gist=017740fbff2c5923dec3cc514bd...</a><p>In that case it works because `w` is copy. For non-copy types, it prevents moving out of the borrow (as expected).<p><a href="https:&#x2F;&#x2F;play.rust-lang.org&#x2F;?gist=241728575a382c54c324b0201c5f7ea5&amp;version=stable&amp;backtrace=0" rel="nofollow">https:&#x2F;&#x2F;play.rust-lang.org&#x2F;?gist=241728575a382c54c324b0201c5...</a>
评论 #14462452 未加载
corn_dogalmost 8 years ago
Having done scala for a few years and only dabbled in rust, I also get the impression that the rust community is trying to have good default answers to questions like how to do json, or which web framework to use. As opposed to scala-land where if you ask three scala devs those questions you&#x27;ll get five answers.
评论 #14463811 未加载
Othersalmost 8 years ago
Concerning cross compiling, one useful tool the author may of missed is [xargo](<a href="https:&#x2F;&#x2F;github.com&#x2F;japaric&#x2F;xargo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;japaric&#x2F;xargo</a>).
qsymmachusalmost 8 years ago
&gt; If you lean more towards the functional programming paradigm side of Scala then you’ll probably love the following about Rust’s type system<p>Some of the more popular functional languages have advanced type systems, but not all functional languages are statically typed. Lisp, the granddaddy of all FP languages, is dynamically typed. So is Elixir.<p>Can we stop conflating FP with static typing?
评论 #14462703 未加载
评论 #14463534 未加载
评论 #14467641 未加载
评论 #14462230 未加载
评论 #14464385 未加载
评论 #14464206 未加载
评论 #14462245 未加载
评论 #14466636 未加载
doug1001almost 8 years ago
thanks for doing this<p>two questions: from the perspective of a Scala dev, does Rust have a solid collections library (including persistent structures such as Scala&#x27;s Vector type) with mutable counterparts (eg, ListBuffer)?<p>second, from a quick glance it seems Rust&#x27;s top-level concurrency model (locks, thread ownership) is the polar opposite of Scala&#x27;s (Actor-based)--is this correct? Scala&#x27;s concurrency model (based on Erlang), along with trait-based multiple inheritance, were Scala&#x27;s initial selling points for me
评论 #14462821 未加载
评论 #14462634 未加载
评论 #14462590 未加载
knavelyalmost 8 years ago
Is there a Rust Console ? As a Scala&#x2F;Haskell programmer, this is my biggest wish right now.
评论 #14463683 未加载
flavio81almost 8 years ago
<p><pre><code> TL;DR: </code></pre> He is happy.<p>Better toolchain (environment manager, package manager, etc)<p>Macros are easier to do with Rust (than in Scala).<p>IDE: happy with MS Visual Studio Code<p>Syntax is not too different.<p>Type system: He likes it.<p>Calls C code with a similar syntax than doing it with Scala<p>Rust allows you more control on how to use your memory allocation. (Or forces you to take control).<p>-------<p>My own take on Rust (haven&#x27;t used the language yet, only looked at specs) is that it appears to be a more &quot;sane&quot;, state-of-the-art version of C++, streamlined, without all the cruft and all the legacy. And with a much better object oriented system based on Traits.
评论 #14463076 未加载
评论 #14462468 未加载
评论 #14465138 未加载
评论 #14462247 未加载