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 is not a “safe language”

21 pointsby longrodalmost 3 years ago

8 comments

eltetoalmost 3 years ago
This title is pure clickbait. It&#x27;s a cherrypicked line taken out of context.<p>For reference, this is the tweet in it&#x27;s entirety:<p>&quot;I agree with this person, along with many Rust community members. Rust is not a &quot;safe language&quot;. It&#x27;s a language that strongly encourages safety. Safety is a spectrum.<p>The people saying that safety is all or nothing are toxic and Rust community needs to stop turning a blind eye.&quot;
Communitivityalmost 3 years ago
While correct, the headline is a bit disingenuous and the content is kind of obvious. No systems language will ever be 100% safe, and Rust is not the exception, as Safe is a spectrum, as Andrew Kelley points out [1].<p>However, Kelly also points out that Rust tends toward safety. Different languages tend toward safety at different rates, and Rust tends toward safety at a high rate for many reasons. In my experience Rust is the safest language that still allows me to accomplish the professional development tasks I do.<p>[1] <a href="https:&#x2F;&#x2F;twitter.com&#x2F;andy_kelley&#x2F;status&#x2F;1554933549999894528" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;andy_kelley&#x2F;status&#x2F;1554933549999894528</a>
评论 #32362994 未加载
评论 #32344801 未加载
pornelalmost 3 years ago
The reddit quote (image, sigh) is right: in Rust `unsafe` has its place. The language has been designed with the escape hatch from the start, so the &quot;safe&quot; subset of Rust is not a complete language. Rust wouldn&#x27;t get far as a systems programming language if it <i>always</i> had to face limits of the borrow checking model and require the mythical Sufficiently Smart Compiler to magically fix every performance overhead.<p>Rust still helps ensuring that the &quot;hold my beer&quot; blocks are correct by reducing their scope to a few clearly marked places. This helps focus code reviews and fuzzing. Rust also encourages wrapping of high-risk code in foolproof abstractions, and has universal rules for how tight and robust such abstraction has to be. In a way, Python or Java are also safe abstractions on top of &quot;unsafe&quot; CPython or HotSpot. In Rust this division is just more granular, with the same syntax on both sides.<p>It&#x27;s worth remembering that in Rust &quot;safe&quot; refers to Rust&#x27;s specific guarantees around memory safety and thread safety, but the field of software security is much larger than that. There are lots of possible logic bugs and security issues beyond that, and Rust won&#x27;t stop you from running `remove_dir_all(&quot;&#x2F;&quot;)`.
pjmlpalmost 3 years ago
Of course any systems programming language needs an unsafe escape hatch, if nothing else the ability to link into Assembly code, and then the pandora box is open.<p>The big difference is how much regular application developers are forced to go down that path, outside writing drivers or kernel stuff.<p>Zig should focus its security story in being better than just a Modula-2 (1978) with C inspired syntax.
exabrialalmost 3 years ago
I agree with &quot;Safety is a spectrum&quot;. By all accounts, Java is a &quot;safe language&quot;... until your code uses sun.misc.Unsafe
评论 #32344918 未加载
jmillikinalmost 3 years ago
Is there a word for the type of verbal shell game where a purposefully-ambiguous phrase is used to imply an indefensible position? For example, the old joke about functional vs &quot;non-functional&quot; languages.<p>In one sense, saying &quot;X is not a safe language&quot; could mean that X is not a language that exclusively allows proven-safe constructions. One might say that Rust is not a safe language because it has `unsafe`, or Ada is not a safe language because SPARK isn&#x27;t mandatory.<p>But this isn&#x27;t what a typical reader should be expected to understand from the quoted phrase -- to say that Rust is &quot;not safe&quot; is to say that it is <i>unsafe</i>. It feels unreasonable to claim Rust is &quot;not safe&quot; when the same accusation would never credibly be leveled at Go, Java, C#, or other languages that encourage (without mandating) memory-safe programming.<p>--<p><pre><code> &gt; The people saying that safety is all or nothing are toxic and &gt; Rust community needs to stop turning a blind eye. </code></pre> There is no such thing as a &quot;Rust community&quot;. There cannot be a community for a programming language when (1) there&#x27;s no way to prevent someone from using that language, and (2) the barrier to entry is an HTTP download and 15-minute tutorial.<p>I never hear about people discussing the &quot;C++ community&quot;, or writing on Twitter about how the &quot;Java community&quot; needs to do something or other. It wouldn&#x27;t fly, there&#x27;s too many people known to use those languages to ascribe a common motivation to them. Yet when there&#x27;s a smaller language -- Rust, Haskell, Go, Zig, whatever -- suddenly people start treating them as if they are a group, and criticizing people who use Rust for the behavior of other people who (claim to) use Rust. It&#x27;s madness.<p>At best there can be a &quot;posters on Reddit&#x27;s &#x2F;r&#x2F;rust subforum&quot; community, or &quot;posters on Twitter&#x27;s #rust hashtag community&quot;, but these are even more dubious. The only requirement to be a member of these &quot;communities&quot; is an email address and enough sense to not get banned.<p>Nobody would say &quot;the Twitter #rust hashtag community needs to ...&quot; because it would be obviously silly to expect good behavior from freshly registered user &quot;PmMeToePhotos123456&quot;.
评论 #32346037 未加载
评论 #32344312 未加载
midislackalmost 3 years ago
RIDF roundup: the thread. Hit us with your best Rust activism!
pkruminsalmost 3 years ago
Actually Rust is a syntax error. It passes the duck test for a syntax error - it looks like a syntax error, it acts like a syntax error, and it prints a syntax error, so it is a syntax error.