33 comments

  • steveklabnik6 hours ago
    I think this is a fine post. But one comment:<p>&gt; remember that for compilers which emit machine code, like roc and rustc, doing memory-unsafe things is a big part of the job<p>I don&#x27;t <i>really</i> think that this is true, in the way that it&#x27;s written.<p>I think that for the hot binary patching &#x2F; code reloading features, yes, that is going to need unsafe. But for regular old &quot;producing an executable&quot; compilation? Emitting machine code isn&#x27;t the part that requires unsafe. The language&#x27;s runtime is a more likely site to find unsafe.
    • rtfeldman5 hours ago
      &gt; I think that for the hot binary patching &#x2F; code reloading features, yes, that is going to need unsafe. But for regular old &quot;producing an executable&quot; compilation? Emitting machine code isn&#x27;t the part that requires unsafe. The language&#x27;s runtime is a more likely site to find unsafe.<p>Agreed! Emitting machine code is not unsafe, since it&#x27;s just writing bytes down - it&#x27;s only once you execute that machine code that there&#x27;s potentially unsafety. The reason I said &quot;a big part of the job&quot; is that in practice a lot of compilers both emit machine code and execute it - but you&#x27;re totally right that it&#x27;s not a requirement that a compiler do both.<p>In addition to the examples you gave (hot binary patching&#x2F;code reloading, language runtime, etc.), others would be things like evaluating userspace code at compile time (e.g. const fn in Rust, or in Roc any expression that could be hoisted to the top level), running tests and inspecting their output to decide what to display to the user, etc.<p>Those are the types of things I had in mind when I wrote that.
      • steveklabnik5 hours ago
        I am disappointed you&#x27;re downvoted, Richard. This is a fine reply, and I hope you know that a minor quibble with a single line in the post doesn&#x27;t mean that I think it&#x27;s a bad one overall. (EDIT: a few minutes later, the parent comment is no longer grey.)<p>I also think it&#x27;s a good thing that you wrote the post in general, when I saw it pop up I was like &quot;oh, of course, this post should exist!&quot; I&#x27;m surprised I didn&#x27;t think about it earlier.<p>&gt; evaluating userspace code at compile time<p>Usually this would be done via an interpreter, so I&#x27;m not sure that it really requires unsafe either. If you are literally executing machine code, sure, but const fn in Rust and constexpr in C++ and many other languages do not do that, as it causes a number of problems (for example, cross-compilation).
        • rtfeldman5 hours ago
          Also a good point! TIL that Rust and C++ use interpreters for const, although of course that wouldn&#x27;t work for running tests. Then again, in the specific case of Rust I believe rustc only compiles the tests and then something else like Cargo executes them. Of course, as I noted elsewhere, if rustc emits machine code and then cargo immediately executes it, there&#x27;s the same opportunity for end user memory being corrupted (due to miscompilation) as if rustc and cargo shared a code base.<p>By the way, I thought your question was totally reasonable - my first thought reading it was &quot;Oh yeah I wasn&#x27;t trying to say that writing bytes is unsafe, I definitely should have worded that differently.&quot;
          • steveklabnik5 hours ago
            Cool, I&#x27;m not sure that people know that we know each other and have some deeper mutual understanding. :)<p>&gt; although of course that wouldn&#x27;t work for running tests.<p>Why not? Unless you mean in the cross-compilation case, in which yeah, to run the compiled tests you&#x27;d need an emulator.<p>&gt; in the specific case of Rust I believe rustc only compiles the tests and then something else like Cargo executes them.<p>It doesn&#x27;t have to be Cargo, but yes, rustc produces executables for the tests, and you have to then run them.<p>&gt; there&#x27;s the same opportunity for end user memory being corrupted (due to miscompilation)<p>I agree for sure that the safety of the outputted binary is completely distinct from the safety of the compiler itself.<p>I think the reason that this framing specifically (in the post and in this comment) strikes me as odd is that &quot;requires unsafe code&quot; sort of implies that you need to use unsafe to fix the unsafety of the outputted binary. That just isn&#x27;t the case. Of course, this is a serious bug that needs to be fixed, but there&#x27;s just something about &quot;doing memory unsafe things&quot; in this area that like, I think can be a little mis-leading, even if that&#x27;s not intentional. But I am going to sit with this and think about it, regardless, because I am not sure that my gut reaction here is completely accurate.<p>(And, hilariously, looking over some work my agents did on my compiler last night, they fixed some mis-compilations that occurred, entirely in safe code. I bet that&#x27;s also part of why I&#x27;m in this headspace at the moment, it&#x27;s not like those fixes required dropping down into unsafe to fix either!)
          • Liquid_Fire4 hours ago
            &gt; if rustc emits machine code and then cargo immediately executes it, there&#x27;s the same opportunity for end user memory being corrupted (due to miscompilation) as if rustc and cargo shared a code base<p>Your tests run in an entirely separate process from the compiler (and from cargo). This makes it very different from memory corruption in the compiler:<p>- The test process can only corrupt its own memory.<p>- You don&#x27;t need &quot;unsafe&quot; to run tests. Just the ability to start another process.<p>- If you&#x27;re cross-compiling, you wouldn&#x27;t even be able to run the tests on the same machine (without emulation&#x2F;compatibility layers)<p>Does roc run tests in the same process as the compiler?
            • rtfeldman3 hours ago
              &gt; Does roc run tests in the same process as the compiler?<p>We do for tests of pure functions, yes.<p>&gt; Your tests run in an entirely separate process from the compiler (and from cargo).<p>That&#x27;s a great point and a relevant distinction, although Rust tests can run arbitrary I&#x2F;O, so it&#x27;s not like having them be in a separate process means memory corruption is harmless! :)
          • minraws5 hours ago
            I would like to understand this more,<p>&gt; rustc emits machine code and then cargo immediately executes it, there&#x27;s the same opportunity for end user memory being corrupted (due to miscompilation) as if rustc and cargo shared a code base.<p>Cause this hasn&#x27;t been true for me or for anyone maybe your definition of memory being corrupted is the not same as mine.<p>I am not even sure what you are trying to prove with this.<p>I appreciate the time and effort in building stuff like Roc I don&#x27;t use it but this comment and the article feel like...<p>Oh some guy said Zig not nice because memory safety so here, a post why memory safety doesn&#x27;t exist because we have to do memory unsafe things sometimes and so everything is memory unsafe already, so maybe it doesn&#x27;t matter.<p>I get the energy that we are going for seeing useless claims and wanting to push back but I think the article deserves a clearer part 2 where you elaborate on your thoughts about stuff maybe even get it peer reviewed a bit before posting or maybe don&#x27;t I guess we could use more raw thoughts in the post AI age.<p>Either way I appreciate someone trying to put forward their own thoughts and explain problems with a different perspective.
        • Joker_vD2 hours ago
          &gt; Usually this would be done via an interpreter, so I&#x27;m not sure that it really requires unsafe either.<p>Well, I personally have written a const-expression evaluator that actually reuses the rest of the compiler: it compiles the expression in the current environment with some specific adjustments to the codegen settings, launches the temporary executable and gathers its output... frankly, it&#x27;s more hassle than it&#x27;s worth compared to writing a separate const-expression interpreter. Plus, of course, it also runs slower since most constant expressions are usually pretty trivial.
    • pjmlp5 hours ago
      Many people try to twist the fact memory safe languages have unsafe code blocks to make the pivot that why bother.<p>It is like someone arguing that since they always bump the head somehow while wearing seatbelts, then they are only a nuisance and should not be used.
      • tadfisher3 hours ago
        Because they view &quot;unsafe&quot; as an escape hatch instead of a feature. It&#x27;s a way to encapsulate dangerous behavior, tightly, with clear postcondiitions. Sometimes it&#x27;s the only way to do things like interact with inherently unsafe FFI code, or hardware.
        • MaulingMonkey1 hour ago
          I adore unsafe, appreciate it as a feature... but it <i>is</i> an escape hatch. One that is sometimes necessary, one that is sometimes not necessary but might still be (ab)used for performance, or initial 1:1 porting of C&#x2F;C++ code. There are a lot of cases where that escape hatch should probably welded shut though. Fortunately, the Rust ecosystem has tools like `cargo geiger`, and straight out of the box I can also write:<p><pre><code> &#x2F;&#x2F; src\lib.rs #![forbid(unsafe_code)]</code></pre>
    • narnarpapadaddy5 hours ago
      I agree that it’s not inherent to emitting machine code but I do think it reflects a different set of priorities.<p>In extremely high performance code you use different data structures and algorithms and change your approach to memory allocation. TigerBeetle famously does all memory allocation once on startup.<p>Roc is attempting to make a similar set of trade-offs in their compiler as Zig, so it makes sense that the author finds many shared patterns.
      • nicoburns4 hours ago
        &gt; In extremely high performance code you use different data structures and algorithms and change your approach to memory allocation.<p>It&#x27;s worth noting that the reason Rust doesn&#x27;t include support for custom memory allocation patterns like Zig does has nothing to do with memory safety. It&#x27;s more of a historical accident that it just wasn&#x27;t something that was prioritised early in the projects history and is now hard to change.
        • steveklabnik3 hours ago
          It&#x27;s also important to note that Rust as a language does not know about the heap at all, it is purely a library concern. This means that &quot;doesn&#x27;t include support for custom memory allocation patterns&quot; is purely talking about standard library data structures, and if you need a ton of performance, you&#x27;re probably going to be writing your own anyway.<p>It will be nice when the Allocator trait stabilizes so that the ecosystem can coordinate on making this stuff pluggable, but that&#x27;s not a direct blocker for getting things done if you need to do things today.
        • narnarpapadaddy3 hours ago
          No disagreement in principle; in practice taking that approach in Zig is safer than in Rust, because in Rust it’s “all or nothing.”
          • kibwen3 hours ago
            The interfaces to custom allocators are more idiomatic, standardized, and normalized in Zig, but there&#x27;s nothing systematically unsafer about the Rust equivalent. You can use custom allocators all you want in Rust, as long as you&#x27;re okay using third-party crates like Bumpalo.<p>On that topic, worth mentioning that Rust&#x27;s long-awaited `Allocator` trait is perilously close to stabilizing; watch for <a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pull&#x2F;157428" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pull&#x2F;157428</a> to be merged, then the stabilization PR to progress here: <a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pull&#x2F;156882" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pull&#x2F;156882</a>
      • steveklabnik5 hours ago
        I do think it reflects different priorities, but one of those differences is that from my perspective, safety and performance are not inherently at odds. Yes, sometimes it is needed, but not as much as some people seem to think. Sometimes, it also means writing code in ways that communicate things to the compiler that you may not think of if you&#x27;re not used to thinking in this manner.<p>A lot of the ways in which the zig compiler works doesn&#x27;t use pointers, it uses indices. This stuff is easier to write as safe code, not less easy.<p>&gt; Roc is attempting to make a similar set of trade-offs in their compiler as Zig, so it makes sense that the author finds many shared patterns.<p>I do think that that makes sense, but it also doesn&#x27;t mean that they <i>have</i> to. I am doing a compiler project that takes a lot of inspiration from Zig (as my language currently inherits some major things from Zig, and I also care a lot about compiler performance) and it&#x27;s written in Rust, and does not use much unsafe code (outside of the usual suspects of FFI in the runtime, etc).
        • torginus2 hours ago
          &gt; A lot of the ways in which the zig compiler works doesn&#x27;t use pointers, it uses indices. This stuff is easier to write as safe code, not less easy.<p>I respectfully disagree. This is only true if you view malloc as qualitatively different from a piece of code that gives you an index for a free object in an object pool.<p>Provided you don&#x27;t ask&#x2F;give back memory from&#x2F;to the OS, what malloc is doing is giving you an index (pointer) into a pool of bytes, while manipulating an internal bookkeeping structure.<p>Use after free is just you using an index after said bookeeping structure has marked that piece of memory as available for something else (and perhaps claimed already).<p>If you have an array of Node structs to represent a graph (like the AST in Zig), and use indices to represent references, you have essentially zero protection in Rust that helps you with finding Node-s that have been used for something else etc.<p>The &#x27;asking memory from the OS&#x27; aspect for malloc doesn&#x27;t really change the safety of your language compared to this where it matters - if you do use-after-free on a page claimed by the OS, you get a segfault, which immediately tells you there&#x27;s a problem, which is much better than silent corruption.<p>At least with malloc, you get debug allocators, or other features that can help you in this case. If you are careless with indices in an object pool, and overwrite stuff, essentially, it&#x27;s up to you to figure out what went wrong and you have no tools to help you.
          • steveklabnik2 hours ago
            I fully agree that there are similarities here. But we disagree about some of the details.<p>&gt; you have essentially zero protection in Rust that helps you with finding Node-s that have been used for something else etc.<p>The most obvious technique is generations. You can of course do that in Zig as well.<p>&gt; if you do use-after-free on a page claimed by the OS,<p>This assumes that you&#x27;re working in the context where there is an OS. That isn&#x27;t always the case. Also, there are other cases than just use-after-free: for example, compilers will optimize around null pointers being UB, which can cause other problems, whereas an index of zero does not get the same treatment.<p>But also, again: Zig does not use malloc for its ASTs, as far as I know. It uses lists and indices. I haven&#x27;t literally read the code lately myself, but I would be surprised if they went back to malloc&#x27;ing individual nodes.
    • EPWN3D6 hours ago
      Yeah that is definitely 1000% wrong. A compiler can do its job with totally abstract data structures. If anything would need to do unsafe stuff in memory, it would probably be a linker.
      • steveklabnik5 hours ago
        &gt; probably be a linker<p>I don&#x27;t think that&#x27;s any different either. The core job of linking isn&#x27;t particularly unsafe.<p>(Unless, similarly, you&#x27;re doing the hot reloading stuff)
        • AlotOfReading5 hours ago
          I&#x27;ve noticed that people equate &quot;low level stuff&quot; with unsafe, regardless of whether it&#x27;s contextually justified.
          • steveklabnik5 hours ago
            I think it&#x27;s an understandable prior. Historically, &quot;low level stuff&quot; was near-exclusively (see my comment below about OCaml...) written in unsafe languages. Even if that wasn&#x27;t always literally required, it sometimes was, and so thinking this is the case was a reasonable thing to think.<p>It is only relatively recently that we have gained more realistic options in these spaces, and so not fully understanding the implications, or preferring the historically normal choices, is understandable.
          • inigyou5 hours ago
            I&#x27;ll play devil&#x27;s advocate. I think emitting machine code intended to run is unsafe because you could emit unsafe machine code, which could run. It&#x27;s the whole system that is either safe or not, not the individual components. If your system gets hacked by a buffer overflow in the end, nobody cares whether it was the linker that overflowed or the code emitted by the linker.
            • nvme0n1p14 hours ago
              That would mean no language can ever be considered safe, because any language can emit bytes to a file that will later be executed.
              • inigyou4 hours ago
                Correct. Safety is a system property, not a language property. Calling a language safe is about as sensible as calling a metal alloy unsinkable.
            • AlotOfReading4 hours ago
              &quot;Safe&quot; has a very specific definition in Rust. It&#x27;s not identical to the broader definition used in technical English. You can easily have safe rust code with behaviors any reasonable layperson would call unsafe, like crashing a plane. The original article, comment, and replies were using the word in the Rust sense from my reading, not the English meaning.
              • inigyou4 hours ago
                Then that&#x27;s equivocation. Why do we want a very specific form of safety instead of wanting safety in general?
                • steveklabnik4 hours ago
                  Memory safety is:<p>1. Foundational for other forms of safety<p>2. Has an objective definition, when some other forms of safety are either subjective or inter-subjective.<p>That said, I don&#x27;t understand why your parent brought this up to you, you are talking about memory safety in your original comment here, so that&#x27;s what Rust&#x27;s safety is about.
                  • inigyou2 hours ago
                    I feel that the buzz phrase &quot;memory safety&quot; has been defined by Rust to mean &quot;the safety Rust gives you&quot;. Obviously memory usage can be more safe or less safe, and Rust is decidedly on the safe end of the spectrum, but it also has the gaping type system holes demonstrated in cve-rs which completely shatter any claim that safe code is safe, and there are other bugs which occur in Rust while the programmer is distracted by trying to prove their code is memory-safe.
                    • steveklabnik2 hours ago
                      &gt; the buzz phrase &quot;memory safety&quot; has been defined by Rust to mean &quot;the safety Rust gives you&quot;.<p>It&#x27;s more that Rust&#x27;s safety guarantee <i>is</i> memory safety. No more, no less. It&#x27;s not about buzz, this term was used long before Rust existed.<p>&gt; it also has the gaping type system holes demonstrated in cve-rs<p>This is not a &quot;gaping hole&quot;. It is a compiler bug, which has never been found in the wild.<p>&gt; there are other bugs which occur in Rust<p>This is true! Every language can have bugs in it, and Rust does not claim to solve all bugs.
                      • inigyou2 hours ago
                        Does cve-rs break any type system rules? If so, why hasn&#x27;t it been fixed yet?
                        • steveklabnik2 hours ago
                          &gt; Does cve-rs break any type system rules?<p>Yes.<p>&gt; If so, why hasn&#x27;t it been fixed yet?<p>Pretty classic software engineering reasons.<p>The part of the system that it involves was in the process of being re-written already. The re-write fixes the bug. Because it is essentially a theoretical issue, and not an actual problem in any real code, it is not a five alarm fire. Waiting for that re-write to land makes the most sense, instead of putting in a ton of work that will be thrown away.<p>Other, more serious miscompilations get fixed faster. In fact, a version of the Rust compiler was released today to fix one, even <a href="https:&#x2F;&#x2F;blog.rust-lang.org&#x2F;2026&#x2F;07&#x2F;16&#x2F;Rust-1.97.1&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.rust-lang.org&#x2F;2026&#x2F;07&#x2F;16&#x2F;Rust-1.97.1&#x2F;</a><p>This one was impacting actual users, and did not require re-writing entire subsystems to fix properly. So the engineering and product tradeoffs are different.
                          • inigyou1 hour ago
                            If cve-rs exists, is safe rust safe? Can one prove that Rust code is safe only by auditing the unsafe blocks?
                • skissane4 hours ago
                  &gt; Why do we want a very specific form of safety instead of wanting safety in general?<p>Because a “very specific form of safety” is a useful tool in achieving “safety in general”<p>Because a “very specific form of safety” is tractable for a compiler and language runtime to achieve, “safety in general” isn’t
                • nvme0n1p14 hours ago
                  &gt; safety in general<p>This is impossible. General words like &quot;safe&quot; and &quot;good&quot; are subjective, and useless in a technical context unless you ground the discussion by giving them specific definitions. Otherwise everyone ends up talking past each other.
                  • inigyou3 hours ago
                    Okay, thanks for debunking all good products, safe houses and clean water. I guess they are just products, houses, and water.
                    • nvme0n1p12 hours ago
                      Good for what? A hammer is good for driving a nail, but not good for driving a screw.<p>Safe for what? My house is safe for humans, but not safe for tropical birds.<p>Clean enough for what? Our water is clean enough to wash my ass, but not clean enough to wash a telescope mirror.<p>Sorry but life is not a Disney movie where some things are unequivocally good&#x2F;safe and other things are unequivocally bad&#x2F;unsafe. There are gradients and conditions, and communication requires a shared language between participating parties to navigate them.
                      • inigyou27 minutes ago
                        What nail? A hammer is good for driving a nail from the hardware store, but not good for driving a finger nail.<p>See? I can play stupid word games too.<p>How tropical are the birds? I&#x27;m afraid life isn&#x27;t a Disney movie where some things are unequivocally tropical&#x2F;not tropical. How shared is the language? Congratulations on using <i>only two</i> adjectives in your comment besides the ones you&#x27;re complaining about, but two is greater than zero.<p>How much your is the house? Do you own it? Without any mortgage or lien?
            • BigTTYGothGF4 hours ago
              The only safe program by this measure is the one that&#x27;s never ran.
            • steveklabnik4 hours ago
              &gt; It&#x27;s the whole system that is either safe or not, not the individual components.<p>This is a core perspective disagreement. While this is true:<p>&gt; If your system gets hacked by a buffer overflow in the end, nobody cares whether it was the linker that overflowed or the code emitted by the linker.<p>That does not mean that increasing the amount of safety in the individual components isn&#x27;t helpful, because it helps minimize the above outcome, even if it will never be zero.
            • gpm2 hours ago
              Safety is a feature of a system - yes. It&#x27;s also a property of what it&#x27;s against. A computer could be safe against being hacked but still be dangerously easy to drop on someones toe and break it.<p>Safety [against something] is also a feature of components - a system made up of only safe components [against a thing] is safe [against the same thing... I&#x27;m going to stop this qualification now for brevity]. A system containing unsafe components may or may not be safe but at least you know what components usage you need to look at carefully.<p>If your linker is safe, linking code will never result in the thing it is safe against. Ever. This is a useful property even if running the linked thing is not safe because it means:<p>1. When things go wrong in strange ways, you have strict bounds guiding you in figuring out what went wrong.<p>2. You can build reliable systems that do part of the job, and only have to sandbox the other half of the job. Compiling in a CI system will (if the compiler was entirely safe) be safe. You can do it with secrets present against malicious code. Running tests will have to be sandboxed (assuming running tests isn&#x27;t safe). This could for instance enable safely sharing significantly more artifacts for incremental builds in CI.<p>Unfortunately very few compilers are really safe against anything (though I do wonder how I could break my toe on one). Rustc for instance has a giant C++ half called llvm that isn&#x27;t really hardened at all. We get away with this by just not trusting the compiler when run against potentially malicious code.
        • surajrmal4 hours ago
          Perhaps the parent meant dynamic linker.
          • yencabulator7 minutes ago
            It wouldn&#x27;t be the linker that has to be unsafe, it&#x27;d be the &quot;and now execute!&quot; jump. And that could be abstracted as memfd+execveat, which are fairly normal operations.<p>OP&#x27;s argument is roughly &quot;doings things with computers has to be unsafe to be useful&quot;, which is.. uninteresting.
    • Aurornis6 hours ago
      That line confused me, too. What parts of their compiler require memory-unsafe operations to produce machine code?
      • skybrian5 hours ago
        They are saying that <i>running</i> the compiled code is memory-unsafe when there is a compiler bug, and that’s what developers do next. The memory corruption happens in a different process.<p>In this respect, effectively all the compiler should be treated sort of like an unsafe region because it requires extra care to avoid memory corruption bugs.
        • Aurornis5 hours ago
          That&#x27;s not what it says at all. The section we&#x27;re talking about is for the compiler and emitting machine code<p>&gt; we ended up with about 1,200 uses of unsafe<p>&gt; remember that for compilers which emit machine code, like roc and rustc, doing memory-unsafe things is a big part of the job<p>Anywhere talking about the `unsafe` keyword is within the Rust code.
          • skybrian5 hours ago
            The article is a bit confusing because they also write:<p>&gt; Regardless of which process had the bug—the compiler or compiled program—in both cases the processor only did the bad thing because the compiler told it to. And in both cases the fix is the same: the compiler&#x27;s code must change, since that code was what caused the memory corruption.<p>But yeah, I wonder what those 1,200 unsafe uses actually did?
    • orlp5 hours ago
      I think if you interpret it charitably it means that any bug in the emitted machine code is already a likely memory-unsafe miscompilation if it is ran.<p>The compiler itself might be perfectly &quot;memory safe&quot; but the generated binary fundamentally is always at risk (besides WebAssembly I suppose).<p>I&#x27;m fully aware of the separation of compiler and binary, and being able to compile untrusted code safely is nice, but a perfectly safe compiler that generates vulnerable binaries isn&#x27;t that much better.
      • demosthanos5 hours ago
        In context that&#x27;s clearly not what he&#x27;s saying, the next sentence is this:<p>&gt; Zig has more features than Rust for making memory-unsafe code work correctly, and that was the area where we wanted the most help.<p>Zig definitely does not have more features for successfully emitting memory-unsafe machine code than Rust does. I can emit memory-unsafe machine code from typescript if I really want to and nothing at all in the language will get in my way. So the sentence quoted above must refer to the idea that the compiler itself needs to be unsafe, which Steve is right is simply untrue.
      • steveklabnik5 hours ago
        I do think that is a good point, it&#x27;s just not what the line actually says. But that&#x27;s why I wasn&#x27;t saying &quot;zomg this is WRONG!!!!&quot; but instead, trying to point out that there are subtleties here. For people who aren&#x27;t as deep in the weeds in this subject, I think the details matter. But again, as I said, I like the post, this is just one thing.<p>I am also probably in a more pedantic mindset because, well, I&#x27;m writing a compiler in Rust, and the words as written do not resonate with me at all.<p>&gt; a perfectly safe compiler that generates vulnerable binaries isn&#x27;t that much better.<p>I do think it&#x27;s much better. Eliminating classes of bugs in one component is a good thing, even if it&#x27;s not every component. This is a core lesson of Rust! unsafe still exists, but going from &quot;I don&#x27;t know what is unsafe&quot; to &quot;only this part is unsafe&quot; is a major improvement.
      • Aurornis5 hours ago
        The section this came from was talking specifically about usages of `unsafe` in the compiler code.<p>It&#x27;s not about the memory safety of the resulting binary.
    • paulddraper6 hours ago
      Agreed, that’s disturbingly incorrect.<p>If anything, compilers are perfect models of trees and well formed programs.
      • benj1113 hours ago
        Maybe in theory. In practise you have thing like super optimisers. You have side effects that the compiler needs to understand etc.<p>That said I&#x27;m struggling to think of something that would need to be unsafe.
  • landr0id6 hours ago
    &gt;ReleaseSafe catches use-after-free errors through runtime checks which panic if the program tries to use freed memory.<p>I don&#x27;t know Zig so maybe they know something I don&#x27;t, but I have seen no evidence that it catches any type of use-after-free including double-free?<p>While writing a blog post (below) I went through the documentation to figure out the possible runtime memory safety checks Zig can insert. The term &quot;use-after-free&quot; or &quot;UaF&quot; never occurs on that documentation page. Searching for &quot;safety-checked&quot; doesn&#x27;t yield any related hits either.<p>Unless maybe they&#x27;re using the DebugAllocator in release builds? Even that does not reliably surface UaF.<p><a href="https:&#x2F;&#x2F;landaire.net&#x2F;memory-safety-by-default-is-non-negotiable&#x2F;" rel="nofollow">https:&#x2F;&#x2F;landaire.net&#x2F;memory-safety-by-default-is-non-negotia...</a>
    • minraws4 hours ago
      I as someone with writing Zig a bunch, can safely say if it does it hasn&#x27;t even worked for me.<p>I am talking from experience from a pre-ai human mitts writing code perspective maybe Zig + LLMs do some magic.<p>The more I read the article the more I feel like this is just bad not sure if I should be giving it as much latitude as I have been in my prior comments.<p>There are other claims as well that are weirdly phrased at least.<p>Reads like an article written to justify some arguments they had rather than a genuine take at this point.<p>But I will give the benefit of doubt I enjoy weird articles, languages and share a dislike for aggressive AI-ness of all things.
    • veber-alex5 hours ago
      I believe you are correct.<p>I think ReleaseSafe just adds bound checking and panics on unreachable code.<p>I don&#x27;t think Zig offers any temporal memory safety.
      • Quot2 hours ago
        I don&#x27;t know enough about Zig to explain it, but there is more to ReleaseSafe than checks and panics. ReleaseSafe also clears memory that no longer has an owner (I might be describing that wrong, that is just how I understand it). I found this out with a rendering issue recently.<p>The bug was around passing a slice to OpenGL which referenced memory outside of its lifetime. Since the memory location had no owner, vertices would still exist in Dev builds and everything would work fine, but in ReleaseSafe the application would run and just have nothing to render.<p>Since OpenGL was trying to read the memory, there was no panic from Zig, but it was a cool look into how the different build modes handle memory.<p>This is the commit where I fixed the issue: <a href="https:&#x2F;&#x2F;github.com&#x2F;quot&#x2F;donut&#x2F;commit&#x2F;8fff107e76278c4bf55007cdc7aad34d8dc549b9" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;quot&#x2F;donut&#x2F;commit&#x2F;8fff107e76278c4bf55007c...</a>
      • flohofwoe5 hours ago
        The DebugAllocator catches use-after-free (at least on page-level), but at the cost of never recycling memory addresses (e.g. it eats through the virtual address space).<p><a href="https:&#x2F;&#x2F;ziglang.org&#x2F;documentation&#x2F;master&#x2F;std&#x2F;#src&#x2F;std&#x2F;heap&#x2F;debug_allocator.zig" rel="nofollow">https:&#x2F;&#x2F;ziglang.org&#x2F;documentation&#x2F;master&#x2F;std&#x2F;#src&#x2F;std&#x2F;heap&#x2F;d...</a><p>For higher level code, &quot;generation-counted index handles&quot; might be the better solution to provide temporal runtime memory safety, not part of Zig the stdlib though.<p>Or even better: never use dynamic memory allocation and make all lifetimes &#x27;static&#x27; :)
        • landr0id5 hours ago
          &gt;The DebugAllocator catches use-after-free (at least on page-level)<p>To clarify, is that to say that you have to use the `std.heap.page_allocator` as its backing allocator?
        • dnautics4 hours ago
          as a reminder its a construct in the zig stdlib to take an arbitrary chunk of memory (could be stack, could be in the programs static space) and wrap it in an allocator interface and give that to any data structure that needs an allocator and use it as if it were just malloc&#x2F;free, with a fixed memory limit and the correct memory errors.
      • azakai36 minutes ago
        Zig does offer some amount of temporal memory safety.<p>Link: <a href="https:&#x2F;&#x2F;zig.guide&#x2F;standard-library&#x2F;allocators&#x2F;" rel="nofollow">https:&#x2F;&#x2F;zig.guide&#x2F;standard-library&#x2F;allocators&#x2F;</a><p>Text:<p>&gt; The Zig standard library also has a general-purpose debug allocator. This is a safe allocator that can prevent double-free, use-after-free and can detect leaks.<p>For more detail, see:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ziglang&#x2F;zig&#x2F;issues&#x2F;3180#issuecomment-528456706" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ziglang&#x2F;zig&#x2F;issues&#x2F;3180#issuecomment-5284...</a>
        • landr0id1 minute ago
          I still don&#x27;t think that does anything regarding use-after-frees, only double-frees.<p>Here&#x27;s the code: <a href="https:&#x2F;&#x2F;codeberg.org&#x2F;ziglang&#x2F;zig&#x2F;src&#x2F;commit&#x2F;e44e927d33d37c4417b9abb9a207b35fd25cd353&#x2F;lib&#x2F;std&#x2F;heap&#x2F;debug_allocator.zig" rel="nofollow">https:&#x2F;&#x2F;codeberg.org&#x2F;ziglang&#x2F;zig&#x2F;src&#x2F;commit&#x2F;e44e927d33d37c44...</a><p>The closest callout in the doc comment is:<p>&gt;&#x2F;&#x2F;! * Never reuses memory addresses, making it easier for Zig to detect branch &gt;&#x2F;&#x2F;! on undefined values in case of dangling pointers. This relies on &gt;&#x2F;&#x2F;! the backing allocator to also not reuse addresses.<p>But it&#x27;s not really clear what this means. &quot;branch on undefined values&quot; would I think indicate that maybe they&#x27;re doing a fill pattern? But I don&#x27;t see it in the `free` path.
  • feelamee25 minutes ago
    &gt; As discussed earlier, having full control over allocations and deallocations is what I want in our compiler&#x27;s implementation. And in tests, I also appreciate the testing allocators detecting leaks—it can even detect leaks in compiled Roc code! Unfortunately, to get that benefit requires a lot of &quot;init this, defer deinit&quot; code in tests that has to be correct or else the test fails on a memory leak. None of that is necessary in Rust. I care more about the compiler&#x27;s implementation being the way I want it than the tests looking nicer, but in a perfect world I could somehow have both.<p>haha, just for fun... do you want a C++ in your perfect world :D?
  • arthurbrown6 hours ago
    Interesting that OCaml was flexible and expressive enough to be used as a prototype testbed but not chosen as the implementation language, especially given the maturity of both. I would be surprised if Zigs incremental builds could be meaningfully faster than dune&#x27;s.<p>Cross compilation is great, but not mentioned in the &quot;why Zig&quot; section. Is memory control that crucial for a compiler?<p>Rust itself was originally written in OCaml, same with WASM. I&#x27;m curious about what milestone gets reached where the maintainers collectively decide to transition away.
    • steveklabnik6 hours ago
      Rust moved away from OCaml when it decided to be re-written in Rust. The post alludes to this as being a usual time for a wholesale re-write, and I&#x27;d agree.
      • arthurbrown5 hours ago
        I appreciate the insight, and on closer reading the post clearly states that realistically only Zig and Rust were ever considered anyway.<p>Since you&#x27;re here, could you comment on the approach Rust took in their rewrite? Was it more of a straight translation like Go did when they self hosted -- similar to the recent Bun transliteration? Or were there architectural changes made along the way like this article describes with Roc?
        • steveklabnik5 hours ago
          The Rust re-write happened before I got involved. If pcwalton is around and sees this comment, maybe he can provide a more first-class account.<p>&gt; Was it more of a straight translation like Go did when they self hosted -- similar to the recent Bun transliteration? Or were there architectural changes made along the way like this article describes with Roc?<p>From what I remember, it was a whole-sale re-write from scratch, not a transliteration. While Rust took a lot of inspiration from OCaml, especially in those days, it was different enough that I&#x27;m not sure that a more direct transliteration would have been particularly possible, though again, see above, I wasn&#x27;t there, so I don&#x27;t know for sure.
    • grayrest6 hours ago
      One of the primary goals for the Roc project is compiler speed. I presume OCaml is out of the running because it&#x27;s not a systems language.
      • satvikpendem6 hours ago
        OCaml compiler is incredibly fast. I wonder how it&#x27;d fare with Jane Street&#x27;s extensions for the borrow checker etc in OxCaml, if it&#x27;s good enough for their HFT I&#x27;m sure it&#x27;s good enough for a new language.
        • djha-skin5 hours ago
          I suspect this &quot;not a systems language&quot; alludes only to OCaml&#x27;s rather steeper learning curve and until-recently difficulty with multiple threads. I am sure it could roll just fine as a single-threaded compiler language written by a small team, which indeed, it was.
        • antonvs5 hours ago
          I wrote a toy Scheme implementation in OCaml by using the Camplp4 preprocessor. In benchmarks, it was faster than Gambit Scheme, which compiles through C.
      • steveklabnik5 hours ago
        OCaml has often historically been considered a language that&#x27;s been appropriate to write systems tooling like compilers, runtimes, and unikernels in, even though GC&#x27;d languages were&#x2F;are not often considered for such projects.
        • pjmlp5 hours ago
          They are considered in many research labs since Xerox, unfortunately there are still too much anti-GC religion among mainstream devs.
          • sph2 hours ago
            I don’t think there’s too many of us on the ‘GC did nothing wrong’ hill.<p>Reading the average HN opinion, it seems everybody is writing high-performance latency-sensitive systems that would implode if a response would take 1 ms longer than normal.
            • jandrewrogers37 minutes ago
              Sampling bias. Most of the people responding are probably those with a strong opinion because of what they work on. Everyone else is likely relatively indifferent to it.<p>It is a misconception that GCs only affect latency-sensitive systems. High-performance throughput-optimized systems are also sensitive at ~1µs granularity for different reasons, so GCs are not used there either.<p>That a GC is adverse to the performance both latency-oriented and throughput-oriented workloads doesn&#x27;t leave many use cases in &quot;high-performance&quot; systems. Maybe systems that are severely I&#x2F;O bound but is barely a thing these days.
              • senderista0 minutes ago
                Could you elaborate on &quot;GCs are not used there [high-performance throughput-optimized systems]&quot;? Are you referring to the cascading effects of tail latency on systems with high fanout?
              • senderista2 minutes ago
                Not to mention that in general GC simply requires more memory.
      • pjmlp5 hours ago
        Depends on the beholder.<p>Unix system programming in OCaml<p><a href="https:&#x2F;&#x2F;ocaml.github.io&#x2F;ocamlunix&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ocaml.github.io&#x2F;ocamlunix&#x2F;</a><p><a href="https:&#x2F;&#x2F;mirage.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mirage.io&#x2F;</a>
  • onlyrealcuzzo7 hours ago
    Zig&#x27;s incremental builds are <i>DEFINITELY</i> a killer feature. In the short term, I could see why you&#x27;d make a switch to get it. But, in the medium term, can we really not expect to see this in Rust in the somewhat near future?<p>I want to go fast, but I don&#x27;t want to go fast just to shoot my foot off.<p>If only somehow we could get Rust&#x27;s safety with all of Zig&#x27;s features and Go&#x27;s runtime without GC...<p>That&#x27;s what I&#x27;m working on building [=
    • insanitybit5 hours ago
      Rust&#x27;s compile times will get faster long before Zig gets safer.
      • onlyrealcuzzo4 hours ago
        I&#x27;m pretty sure Zig has no plans to ever become safe - by any sane sense of the word - so, yes, I would expect...
        • dnautics4 hours ago
          zig does have plans to give access to IRs when stable so adding a borrow checker to zig will be even easier than it is now
          • gpm2 hours ago
            This is cool and will likely enable some cool tooling.<p>I don&#x27;t think a borrow checker is likely to be in that tooling. Borrow checking requires shaping the code, and all the dependencies, into easily analyzable (and at least in rust&#x27;s version annotated) patterns. You can&#x27;t borrow check arbitrary code not designed for it without false positives.
            • slekker2 hours ago
              You can because all allocations are tracked and explicit
              • gpm1 hour ago
                That&#x27;s not sufficient - consider the following pseudocode<p><pre><code> x = malloc(); if (opaque_cond()) free(x); if (other_opaque_cond()) use(x); </code></pre> Conditions can be opaque and non-analyzable due to rices theorem - in any turing complete language. This code is correct (or at least not memory unsound) if opaque_cond and other_opaque_cond are never both true. Otherwise it isn&#x27;t.<p>And functionally compiler analyses of whether conditions hold have to be trivial because using some form of theorem prover to decide of code is correct or not leads to code that is brittle against compiler version changes, and slow compile times. Thus opaque_cond could be as simple as `len == 0` and `other_opaque_cond` could be `len &gt; 0` and it&#x27;s unlikely you&#x27;d want the compiler to realize those are mutually exclusive (at the stage where it accepts programs, obviously during optimization it is very likely to take advantage of this).<p>Rust solves this by simply rejecting the pattern. Very roughly forcing you to write if opaque_cond() { free(x) } else if other_opaque_cond() { use_x } (or something else where the program structure and not just the logic in the conditions guarantees correctness). Zig simply allows it and leaves it up to the programmer not to make a mistake.<p>And as onlyrealcuzzo suggests aliases are where this type of analysis (accepting enough programs to be useful but still imposing enough structure you can prove correctness) is really tricky.
              • onlyrealcuzzo1 hour ago
                Allocations are less of a problem than aliases.<p>Without affine&#x2F;linear ownership - solving the aliasing problem is the Halting Problem.<p>Rust didn&#x27;t invent Affine Ownership just to make Rust hard. It did it because it&#x27;s one of the only ways to have memory safety without a GC.
    • dabinat5 hours ago
      This is being worked on: <a href="https:&#x2F;&#x2F;rust-lang.github.io&#x2F;rust-project-goals&#x2F;2026&#x2F;roadmap-fast-builds.html" rel="nofollow">https:&#x2F;&#x2F;rust-lang.github.io&#x2F;rust-project-goals&#x2F;2026&#x2F;roadmap-...</a><p>Most of the goals on this page are targeted for this year.
    • lioeters6 hours ago
      Instead of waiting for faster compiler in Rust, how about from the other direction, adding some kind of borrow checker to Zig? That sounds more within reach and practically achievable, possibly even in userland.
      • onlyrealcuzzo6 hours ago
        That&#x27;s sort of what I&#x27;m doing...<p>I&#x27;m writing a language with Affine Ownership that transpiles to Zig and has a built-in FSM-based Green Fiber runtime.<p>Affine Ownership gives you memory safety + fearless concurrency + eliminates the need for Go&#x27;s GC.<p>It&#x27;s obviously going to slow down compilation - since you need to do Rust&#x27;s borrow checking, etc. But I can do this incrementally as well...
      • veber-alex5 hours ago
        It&#x27;s impossible to add a borrow checker to any existing language.<p>The reason Rust has a working borrow checker is because every part of the language from structs, enum, traits, generics and all the way to the syntax itself has been designed to support lifetimes and borrow checking.<p>It&#x27;s is not something you can just tack on to an existing language without fundamentally changing it.
        • solatic5 hours ago
          I wouldn&#x27;t say it&#x27;s impossible, rather un-ergonomic. TypeScript can add type information to ordinary JavaScript code via JSDoc comments; the result can both be executed as ordinary JavaScript as-is and type-checked with TypeScript. But it&#x27;s a huge pain to try to write (and maintain) everything that way, it was supported as a hack to help migrate legacy codebases. You could probably take a similar &quot;the lifetimes are embedded in comments&quot; approach with other languages, and the result would be similarly un-ergonomic.
          • afdbcreid5 hours ago
            <i>That</i> is possible (clang has experimental lifetime annotations support), but that is not enough to guarantee memory safety.<p>As a simple example, Zig has no private fields. That makes encapsulating any unsafety impossible.
            • dnautics5 hours ago
              no. You don&#x27;t need private fields. All you have to do is analyze the code, harness the compiler to generate a time-dependent data dependency graph, and map allocation&#x2F;frees&#x2F;uses, if you can &#x27;color&#x27; branches where data are shared you can also track and check to see there isn&#x27;t an aliasing violation too.<p>it is easy to patch the zig compiler to enable this this (export the code graph; about 50 LOC). The analysis is much much harder to get right.
              • afdbcreid1 hour ago
                This analysis is undecidable. There is a reason sound static analyzers (including languages like Rust) require in-code annotations.
              • rcxdude1 hour ago
                It is only feasible to do this if the whole of the codebase idea designed to allow it, and it&#x27;s still going to blow up in odd ways of you don&#x27;t have a way to describe lifetimes in your interfaces. The magic of rust&#x27;s design is that it turns this memory tracking into a local problem, such that you can design an interface and be sure that every use case is safe and verifiably so.
              • AlotOfReading1 hour ago
                It seems like it&#x27;d be pretty reasonable to get something akin to polonius. I can write up an engine in zig if it&#x27;d help?
            • solatic4 hours ago
              &gt; Zig has no private fields<p>You may have missed the point here. You could add a comment to the struct field that marks the field as private, and build a TypeScript&#x2F;JSDoc analogue that analyzes all accesses to the field and fails if it finds accesses from functions that aren&#x27;t part of the struct that owns the field. You don&#x27;t even need a comment on the field - you could copy Go&#x27;s convention, add a comment to the struct definition marking it as &quot;follows Go convention&quot;, and then fail any access from outside the struct to a field that starts with a lower-case character.<p>It doesn&#x27;t prevent you from ignoring that tool and writing Zig code that imports the struct and accesses the field. It is, of course, not part of the Zig language itself. But if you adopted a tool like that, it would be your responsibility to run it across-the-board and pay attention to the results - same as how it is your responsibility to pay attention to the results if you added those JSDoc comments.
              • afdbcreid1 hour ago
                I have picked private fields as an example of feature that is needed because it is very simple. You&#x27;re right that you can build an analyzer (with additional code annotations) to support that, but it&#x27;s only one example.<p>Take another example: unsafe traits. They are fundamental to some safety encapsulations, most famously concurrency (`Send`&#x2F;`Sync`). Here you cannot just build an analyzer to mark something unsafe, because Zig has no traits, its generics are duck-typed.<p>You can, of course, add traits. But at this point you&#x27;re essentially creating your own language that compiles to Zig, with all problems this entails (e.g. bad ecosystem support). It&#x27;s also hard to claim that Zig can be memory safe then.
            • veber-alex5 hours ago
              Exactly.<p>Every part of the language must support memory safety from first principles.
              • dnautics4 hours ago
                empirically untrue. several projects exist that bolt on extra safety to unsafe languages or unsafe parts of language. SeL4 for C, MIRI for rust unsafe. i guess ada&#x2F;spark for ada too, is the OG, spark being added to ada 4 years after its first release
                • afdbcreid59 minutes ago
                  Hardening is definitely possible, we&#x27;ve had sanitizers in C&#x2F;C++ for a long time. It&#x27;s not full memory safety though. Miri is the same.<p>SeL4C is formal verification, and while it can prove memory safety (and much more) it is much more difficult, to the point that you&#x27;re basically programming in a different language.<p>Ada&#x2F;SPARK is your best example, and also the example I know the least of, so I won&#x27;t comment on.
          • AlienRobot30 minutes ago
            A better comparison would be Python.<p>The way Python added types is the most disgusting thing imaginable... but it has type hints now, so I guess that makes some people happy.
        • pjmlp5 hours ago
          Swift, Linear Haskell, Chapel, Ada&#x2F;SPARK are all counter examples from such claim.
          • lioeters4 hours ago
            Also OxCaml, from what I hear.
        • kfuse4 hours ago
          C# was already a very mature language when it had referenes and later &quot;ref safety&quot; added to it.
        • dnautics5 hours ago
          &gt; It&#x27;s impossible to add a borrow checker to any existing language.<p>Why do you say that. Have you tried and failed? It seems to be possible to add a borrow checker to zig, just as you can add MIRI to rust to get extra safety in unsafe blocks.
      • dnautics6 hours ago
        &gt; how about from the other direction, adding some kind of borrow checker to Zig? That sounds more within reach and practically achievable, possibly even in userland.<p>It&#x27;s doable, and as static analysis. see sibling comment.
        • Ar-Curunir6 hours ago
          No, it would fundamentally change how Zig works.
          • dnautics5 hours ago
            no, it would not. If you do not believe me, you should try out the repo.
            • Ar-Curunir2 hours ago
              the architecture doesn&#x27;t make sense. MIRI doesn&#x27;t perform static analysis on MIR. It is, as the name says, an interpreter. The borrow checker is entirely different from miri.<p>Rust&#x27;s borrow checker requires lifetime annotations. Zig code doesn&#x27;t contain any such annotations. How does your design handle this?
    • Hinrik6 hours ago
      Layperson here: what is special about Go&#x27;s runtime, aside from the GC?
      • djha-skin5 hours ago
        Chief design goals were radically easy concurrency and speed of compilation.
        • minraws4 hours ago
          Speed of compilation feels like a distant second in terms of goals given the weird new generic features they keep adding..<p>I was fine with basic generics they complicated it quite a bit much for my liking.
          • ameliaquining3 hours ago
            What weird new generic features? Generic type aliases? Those aren&#x27;t very complicated.
      • vips7L4 hours ago
        Is the Go GC that special? Is it even generational yet?
        • silisili4 hours ago
          I&#x27;m not sure it would ever make sense to be. That makes the assumption tons of allocations get made that don&#x27;t live long, which was(maybe is still?) more common in some languages. Go is more aggressive about not heap allocating, and has tools to help you avoid them.
      • fnord776 hours ago
        Goroutines?
      • onlyrealcuzzo6 hours ago
        It&#x27;s literally the most sophisticated scheduling engine in the world.<p>In practice, Go can typically outperform Rust in throughput (using more memory), despite having a mountain of disadvantages against it in theory.<p>That&#x27;s how good the Go scheduler&#x2F;runtime is.
        • Aurornis6 hours ago
          &gt; n practice, Go can typically outperform Rust in throughput (using more memory), despite having a mountain of disadvantages against it in theory<p>This is a huge claim that disagrees with both my real-world experience and everything I&#x27;ve seen from artificial comparisons.<p>Every high performance Go system I&#x27;ve worked on has quickly reached the point where we&#x27;re optimizing memory management and doing things that would have been explicit in a non-GC language like Rust anyway.<p>The Go runtime is amazingly optimized, but it comes with overhead over doing the same work directly in a lower level language.
        • jcgl6 hours ago
          This is the first I&#x27;ve heard anyone claim higher throughput for Go than Rust. Any articles you&#x27;d point to to learn more?
          • insanitybit5 hours ago
            I think one of the few performance benefits with a GC is that you can defer allocations. You can do that in Rust too though.
        • insanitybit5 hours ago
          I think this is interesting and warrants explanation. There are cases where a GC can be faster (sort of, Arenas get you most of the gains) but &quot;the most sophisticated scheduling engine in the world&quot; should be easy to at least partially support.
        • jandrewrogers6 hours ago
          &gt; It&#x27;s literally the most sophisticated scheduling engine in the world.<p>That seems unlikely regardless of how good it is. This is a domain where state-of-the-art research is not in the public literature. Scheduling is an AI-complete problem.
        • zacmps5 hours ago
          What benchmarks are you referring to?<p>Rust itself doesn&#x27;t have a scheduler of course, I assume this is comparing against tokio or one of the other async executors?
        • pjmlp5 hours ago
          What a joke, ignoring Erlang, and the custom schedulers from JVM and CLR runtimes.
          • dnautics4 hours ago
            Erlang&#x27;s scheduler is not sophisticated, which is what makes it AWESOME.<p>but yeah. i would be surprised if the JVM&#x27;s scheduler is not more sophisticated than go&#x27;s if for no other reason than it has way more knobs you can tune. you know they put that knob in there because someone (probably Google cough cough) asked for it
    • dnautics6 hours ago
      &gt; if only somehow we could get Rust&#x27;s safety with all of Zig&#x27;s features<p>i periodically throw my unused codex tokens at this:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ityonemo&#x2F;clr" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ityonemo&#x2F;clr</a>
  • norir4 hours ago
    This piece would have been a lot more compelling if they had actually done science on selecting a language for compiler development. From what I can tell, they had an untested hypothesis that a low level systems language is necessary for a high performance compiler <a href="https:&#x2F;&#x2F;www.roc-lang.org&#x2F;faq#self-hosted-compiler" rel="nofollow">https:&#x2F;&#x2F;www.roc-lang.org&#x2F;faq#self-hosted-compiler</a> and from that concluded that their only choice besides rust was zig.<p>I know from experience that this initial assumption is wrong. Compiler performance is dominated by algorithms. The fastes managed languages tend to be at worst within a factor of two for wall time on any given algorithm. Algorithmic differences can be unbounded in their performance gaps. Zig itself is a perfect counterexample to the theory that writing a compiler in a low level systems language will lead to a fast compiler. Roc seems to compile at around 15k lines per second. That is not fast. There were evidently compilers written in ml that did 3k likes per second in 1998 <a href="https:&#x2F;&#x2F;flint.cs.yale.edu&#x2F;cs421&#x2F;case-for-ml.html" rel="nofollow">https:&#x2F;&#x2F;flint.cs.yale.edu&#x2F;cs421&#x2F;case-for-ml.html</a><p>The zig rewrite of roc looks like the author&#x27;s second compiler. Compiler and language design is a skill like any other and from my vantage point, they appear to have overcommitted to an initial design at the expense of developing their higher level design skills. In my opinion, the best thing they could do for the future of roc is stop working on their current compiler and use it to write a self hosting compiler for a much smaller subset of roc. They should be able to do that in less than 10k lines of code. They might even find that their self hosting compiler is faster than their zig based bootstrap compiler for the self hosted subset of roc. If the self hosting compiler is inadequate. Now they at least have identified a smaller useful subset of roc and can experiment with different compiler implementations in 10k likes of code rather than 300k lines of code. Then they could actually test the theory of whether or not a low level language is necessary to meet whatever arbitrary compiler performance goals they have.<p>By self hosting, they would also discover what roc features actually matter and they would spend much more time actually writing roc code. The features that are needed to write a self hosted compiler are all features that are generally useful. By improving the self hosted compiler, they also improve downstream programs.
    • munificent4 hours ago
      Your comment is very assertive, but also doesn&#x27;t offer much in the way of science.<p>Being able to compile ML quickly in the 90s tells you little about being able to compile Roc or some other language today because the language design enforces hard constraints on the algorithms necessary to compile it and the hardware today is much more complex. It&#x27;s not hard to write a fast Pascal compiler that targets a 1980s chip with shallow pipelines. But that&#x27;s not the problem being solved here.<p>I don&#x27;t know much about Roc but it looks like it&#x27;s got some amount of overloading and the linked article alludes to sophisticated algorithms to avoid heap allocating closures. Those can enforce algorithmic complexity in the compiler that is essential and can&#x27;t be eliminated.<p>Once you&#x27;re at the limits of algorithmic optimization, all that&#x27;s left is reducing constant factors. I&#x27;ve written code in many languages in different performance regimes over the years and it&#x27;s certainly the case that higher level languages, especially managed memory ones, put a hard floor in terms of how low you can go when optimizing to improve those constant factors.<p>I have seen in real-world code where explicit control over memory layout improved performance by more than an order of magnitude. I have friends in the game industry where much of their <i>career</i> is this kind of work. Those people would <i>love</i> to live in the luxurious world you describe where all they need to do is find a sufficiently clever algorithm and all of their performance problems will disappear.
  • bbkane2 hours ago
    Tangentially relates, but if any Roc devs are around I&#x27;m curious about the use cases for Roc.<p>It&#x27;s supposed to be a scripting language right you embed into your C ABI right?<p>Do you see it competing with WASM for the plugin use case (i.e. a really large Roc platform)? Why would an app author prefer to expose a Roc layer to their app rather than a WASM layer? With a WASM layer, plugin devs can write in any language.<p>Another use case I&#x27;ve heard from it is as a more app-level language (i.e. a really small Roc platform). Do you see it competing with Gleam for server side http code? Do you see it competing with Elm for client side code?
    • SoftTalker1 hour ago
      Same question. I always like learning about languages I had not heard of, especially functional languages, so I was immediately curious what sorts of applications this might have. But after looking over the roc-lang.org website and the FAQ, I still don&#x27;t know.
  • giancarlostoro6 hours ago
    One thing I wish Rust would improve over time is the builds. Its one of the biggest sources of wasted storage space on all my computers, builds a ton of libraries can take tens of gigs, it adds up very quickly. Not sure what the best solution is, one I found is to set the global build folder so dependencies get reused across projects, but imho it should be an OOTB default behavior whatever the real solution should be.
    • epage5 hours ago
      We are trading away disk space for faster builds. We could make them faster in some cases by using even more...<p>On the other hand, it would be good to garbage collect those caches. We are wrapping up work on a new layout for intermediate build artifacts that will make it easier to GC them.
      • giancarlostoro4 hours ago
        Sounds like what I was thinking, that or for third party deps to go into the same temp folder, and anything not accessed in over a week, or so just gets auto wiped by rustc &#x2F; cargo build process?
      • kstrauser4 hours ago
        Can you talk a little more about that? How would that work, and what would the developer experience be like when using it?
        • ameliaquining3 hours ago
          The proposal&#x27;s at <a href="https:&#x2F;&#x2F;hackmd.io&#x2F;@rust-cargo-team&#x2F;SJT-p_rL2" rel="nofollow">https:&#x2F;&#x2F;hackmd.io&#x2F;@rust-cargo-team&#x2F;SJT-p_rL2</a>; progress is tracked at <a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;cargo&#x2F;issues&#x2F;12633" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;cargo&#x2F;issues&#x2F;12633</a>.
    • c-hendricks5 hours ago
      I always got a kick out of that, coming from a JavaScript background where people constantly harp on the size of node modules.<p>My Tauri project, where the backend is much smaller code-wise than the frontend, has 9gb of rust artifacts (node_modules is 550mb for comparison)
      • tredre35 hours ago
        Rust isn&#x27;t great, and it shouldn&#x27;t be a surprised since it&#x27;s designed after npm. However one metric where nodes_modules is still worse for me is the sheer number of small files in it.<p>Having nearly one million files in nodes_modules isn&#x27;t that unusual. The problem is that on most common file systems the minimum allocation is usually at least 4KB. So even if the actual data is less than 500MB, you end up with 4GB disk space used&#x2F;wasted.
        • inigyou5 hours ago
          I wish ext4 had a feature to mark a file as &quot;atomic&quot; where it would allocate all atomic files in a long run, without room for expansion, and I suppose with very inefficient compaction upon deletion, but without any padding bytes.
          • giancarlostoro4 hours ago
            A file “pointer” for byte exact files, pointer gets ditched for files that get updated or the pointer gets adjusted to another common file.
  • overgard2 hours ago
    Compile times are a really underrated thing. My #1 gripe with C++ is waiting 10 minutes on a build, it absolutely kills flow.
    • jolt4217 minutes ago
      My realization first time with Eclipse&#x2F;Java.
    • AlienRobot29 minutes ago
      I currently have a problem with Rust that I use Rust-Analyzer for syntax and autocomplete in VS Code and it has to run the compiler when you save a file to &quot;refresh&quot; things.<p>As you may imagine, this is insanely slow.<p>So slow that when I switch from a .rs file to a .ts file I feel like I switched computers.
  • pjmlp5 hours ago
    Quite interesting the hand waving of security issues with Zig, oh well.<p>If I want to use allocator debuggers I already have the production ready tools that exist for C and C++ for at least 30 years.
    • afdbcreid5 hours ago
      Compilers are not security sensitive, usually. And while UB could theoretically poison the generated code, this isn&#x27;t a bigger risk than logic bugs.
      • demosthanos5 hours ago
        &gt; Compilers are not security sensitive, usually.<p>The compiler is one of the most significant trust boundaries we have. Its decisions can intentionally or unintentionally create vulnerabilities in programs compiled by the compiler, which means that if you can compromise a compiler you can compromise everything downstream.<p>Unsafe memory access in a compiler can be exploited in order to hijack the compiler itself (this is reported regularly in production compilers), allowing the attacker to then insert arbitrary code into compiled binaries. Not everything that a compiler absorbs from its environment is meant to be treated as source to be compiled, and in a memory unsafe compiler any of that input can silently turn into machine code in the compiled binary if an attacker is able to exploit the memory safety bug and hijack the compiler.
        • afdbcreid1 hour ago
          Most compilers do not consider themselves a security boundary, and will not try to limit malicious code from hijacking the compiler. E.g. LLVM is explicitly not designed to handled malicious code (<a href="https:&#x2F;&#x2F;llvm.org&#x2F;docs&#x2F;Security.html#what-is-considered-a-security-issue" rel="nofollow">https:&#x2F;&#x2F;llvm.org&#x2F;docs&#x2F;Security.html#what-is-considered-a-sec...</a>).
        • uecker3 hours ago
          For this to be useful you would need to modify the compiler binary to make the exploit persistent. Otherwise why put an exploit for the compiler in the source to so that the compiler can put some malware in a binary, when you can put the malware in the source directly?
          • demosthanos2 hours ago
            Because:<p>1. There are lots of things that compilers load into their memory that aren&#x27;t actually source code. A memory exploit turns non-source data into executing-in-the-compiler code.<p>2. Depending on the language semantics, a memory exploit can allow substantially higher privilege than just being loaded as library code. Latent malicious code that never gets called into never becomes active, but if you can exploit a weakness in the compiler you can make your code execute at any time you&#x27;d like instead of relying on the main application calling in to your malicious library.
            • uecker2 hours ago
              1. What would this be? 2. Good point, but for most purposes I think exploiting some aspect of the build system or the language that moves the exploit code or causes it to be executed before main would be easier than exploiting a memory issue in the compiler (I agree though in principle).
      • pjmlp5 hours ago
        Of course they are, anything can be a gateway to inject backdoors, if security is not taken into account.<p>And as mentioned, if what Zig offers is already in Purify, there is hardly any added value over C and C++, without the headaches of a niche language.
  • dzonga36 minutes ago
    even though I don&#x27;t use Zig - a few things make me excited.<p>such as new games that are gonna come - written in Zig - since its more ergonomic than C.<p>the other side is on the distributed software side of things - we have already seen it with TigerBeetle.<p>on my own end - probably robotics side.
  • KoleSeise12777 hours ago
    The 35ms incremental rebuild is the part that sold me. I&#x27;d be curious to see the same benchmark on ARM once -fincremental gets there.
    • mlugg50 minutes ago
      Zig team member here---obviously I can&#x27;t say for sure yet, but I&#x27;m pretty confident the number will be basically identical. In the Zig compiler, incremental updates (rebuilds) have a small amount of overhead which is roughly proportional to the total size of the codebase (rather than just the amount of code which was changed). This comes from a) detecting which source files changed, and b) traversing a graph to figure out which declarations are referenced (necessary due to Zig&#x27;s &quot;lazy analysis&quot; feature). But performance analysis reveals that for small updates, this overhead actually dominates the update time, by a <i>lot</i>. Of the 35ms, I would guess that under 5ms are actually spent rebuilding the function(s) that changed. Of that 5ms, code generation---the only thing which would really be different on AArch64---is an even smaller slice of the pie (it often doesn&#x27;t even impact the overall time, since it runs in parallel with other parts of the pipeline, and those other parts are usually the bottleneck there). So even if the AArch64 backend was significantly slower (which, right now, is the opposite of what we expect---instruction selection and encoding for x86_64 is unusually complicated!), I wouldn&#x27;t expect the number to change from 35ms.
  • dev_l1x_be6 hours ago
    Zig is a pre-1.0 language while Rust is post-1.0. This alone is settles which one to pick for may developers. The library support is probably favours Rust too. Rust build times are much slower than Zig, I get that, but I rarely optimize software for build times.
    • drdexebtjl5 hours ago
      Zig is not pre-1.0 because it’s not ready for production (bugs or missing features), it’s pre-1.0 because they want to be able to make breaking language changes.<p>Nowadays when you can just point an agent at release notes and have it update everything, I actually prefer not having to wait through rare major releases to get new language features.
      • Aurornis5 hours ago
        &gt; Zig is not pre-1.0 because it’s not ready for production (bugs or missing features), it’s pre-1.0 because they want to be able to make breaking language changes.<p>This is a solved problem in other projects. Either use the version numbers as intended and bump the major version number on breaking changes, or use Rust-style editions to opt in to the newer versions of the changes.<p>Calling a project production-ready but keeping the version number below 1.0 and saying breaking changes are expected is a tired game. We&#x27;ve seen it backfire across a number of language projects like Elm, where the exact same claim was used to both encourage people to use it and then blame them when it backfired.<p>If it&#x27;s production ready, go to 1.0 and then follow semver for breaking changes. I don&#x27;t care if we get to Zig v73.2.0 as a result. At least we can see from a glance which versions need to be checked for breaking changes.
        • em-bee3 hours ago
          languages ideally should not have breaking changes ever.<p>on the other hand, a language with frequent breaking changes should not be considered production ready.<p>people are of course free to live on the edge, and if someone decided that zig is good enough and they are not bothered by breaking changes then they are free to use it for their production system, but that doesn&#x27;t mean it&#x27;s ready for everyone. so i prefer the zig approach.
          • bsder1 hour ago
            &gt; languages ideally should not have breaking changes ever.<p>I disagree <i>MIGHTILY</i>. This is how you wind up with C++ and Java.<p>Languages <i>need</i> to be able to remove features to stay coherent. Occasionally, you get things wrong, it takes time to figure that out, and that&#x27;s just the way life is.
        • drdexebtjl4 hours ago
          [dead]
      • afdbcreid5 hours ago
        &gt; Nowadays when you can just point an agent at release notes and have it update everything<p>Except that means that not only you lose compiler bugfixes, you also pretty much has no access to the ecosystem. For most production codebases, this is a deal breaker.
      • rwz5 hours ago
        &gt; they want to be able to make breaking language changes<p>That sounds like it&#x27;s not ready for production to me.
        • drdexebtjl5 hours ago
          I invite you to read the release notes and see for yourself the types of breaking changes we’re talking about.<p>To me it is not much different from Lua, which despite being on 5.x for decades, makes breaking changes on minor releases (because it predates SemVer).<p>I also don’t see it being much different from any other language or language runtime that has a major release every year.<p>It’s fine to update at your own pace.
          • uaksom2 hours ago
            &gt; I invite you to read the release notes and see for yourself the types of breaking changes we’re talking about.<p>I did, and I immediately found this in the latest release: <a href="https:&#x2F;&#x2F;ziglang.org&#x2F;download&#x2F;0.16.0&#x2F;release-notes.html#IO-as-an-Interface" rel="nofollow">https:&#x2F;&#x2F;ziglang.org&#x2F;download&#x2F;0.16.0&#x2F;release-notes.html#IO-as...</a><p>That seems like it would require changing a lot of code. Calling it &quot;production ready&quot; is dishonest at best
  • maybebug5 hours ago
    Nitpicking ahead:<p>I am not sure, but there might be a bug in their pattern matching example.<p>What happens if &#x27;verb&#x27; is &quot;GET&quot; and &#x27;path&#x27; is &quot;&#x2F;users&#x2F;1234&#x2F;posts&#x2F;1234&#x2F;extra_path&#x2F;and&#x2F;more&#x2F;&quot;? Will &#x27;post_id&#x27; become &quot;extra_path&#x2F;and&#x2F;more&#x2F;&quot;?<p>I tried running it in the sandbox, and it does indeed seem to buggily result in:<p>&quot;Post ID: 1234&#x2F;extra_path&#x2F;and&#x2F;more&quot;<p>I suspect that the reason it is behaving like it is, is due to how it handles characters in the string literal. The example program exploits that only the slashes present in the string literal pattern are matched, to enable matching on &#x27;page&#x27; having slashes. But then in the nested &#x27;match&#x27;, it forgot to account for any possible extra slashes.<p>Nitpicking end.<p>I have not read the whole post yet, but the pattern matching not requiring any allocations, seems very nice. The string literal patterns also seem interesting, though I am not completely sold on them, also as per the above possible bug. It seems really clean in some ways, but the specific semantics, I am not fully sure about. Maybe it is excellent, and is so clean and concise that it is overall less bug-prone than alternatives in other programming languages. I do not know.
  • g42gregory2 hours ago
    Does this mean every time you find yourself using lots of “unsafe” Rust blocks, it’s not the right tool for the job? I suspect it’s not that simple, but what are people’s experience?
    • steveklabnik2 hours ago
      It really depends. For example, it might mean that you do not know the way to do the same thing, but in a safe manner. It might mean that you could refactor your code to do things more safely.<p>Of course, reasonable people may also believe that it is easier to use an unsafe language directly rather than change the ways that you code.<p>In my experience doing embedded, operating systems work, compiler work, and others, you never need a large amount of unsafe code. 1%&#x2F;4% is really about it.
  • coffeeindex7 hours ago
    Didn’t know Roc was still being worked on. I think it’s an interesting concept for a language that I personally haven’t seen elsewhere
    • sarchertech4 hours ago
      What made you think it was no longer being worked on?
    • denismenace3 hours ago
      What concepts do you find interesting, compared to other FP languages?
  • Fervicus2 hours ago
    Roc seems interesting. But for some reason I find it very grating to have the type definition on a separate line. Very much prefer F# syntax for that.
  • LAC-Tech28 minutes ago
    &gt; I enjoy Rust, I&#x27;ve taught a course on it, and I happily use it daily for my work at Zed. Despite what Internet comments might have us believe, it&#x27;s extremely normal for one language to be the best fit for one project, while a different language turns out to be the best fit for a different project. One size does not actually fit all!<p>Amen. I like both Zig and Rust, and if I praise&#x2F;criticise one of them, people act like I&#x27;m &quot;switching&quot;, as if they were two exclusionary religions (though I think some people may indeed view them that way).<p>The stuff on memory safety written in the article is well worth reading, because in a lot of programmer discourse it&#x27;s talked of as if it&#x27;s some binary, that Rust Is Memory Safe, and Zig Is Not Memory safe. That&#x27;s simply not the case.
  • satyambnsal6 hours ago
    is this uno reverse for bun post of zig to rust port ?
  • dbacar4 hours ago
    why not rewrite in ROC?? Would be much more cooler.<p>I think precious cognitive time should be spent more on the language itself rather than wasting it on rewrites.
    • steveklabnik4 hours ago
      The article links to <a href="https:&#x2F;&#x2F;www.roc-lang.org&#x2F;faq#self-hosted-compiler" rel="nofollow">https:&#x2F;&#x2F;www.roc-lang.org&#x2F;faq#self-hosted-compiler</a> to discuss this.
  • christkv4 hours ago
    Can anybody explain to me why anthropic bought bun in the first place ?
    • 3D3973909146 minutes ago
      Nobody can.<p>&quot;Claude Code uses Bun&quot; is the reason that&#x27;s given. But even though Anthropic tells us that &quot;coding is solved&quot;, instead of rewriting Claude Code in something other than JS, they bought a company that made a JS runtime and then did a mass rewrite of that JS runtime.
    • steveklabnik4 hours ago
      Claude Code uses bun.
      • christkv3 hours ago
        Yeah I get they use it but I don&#x27;t understand why you would buy it. it&#x27;s just the runtime for code that makes up the agent.
        • steveklabnik3 hours ago
          Bun was a startup. Startups can go out of business, and then you are now scrambling to move your code to something else. They could also be bought by someone who has different priorities regarding future development than you, and that&#x27;s also a risk.<p>The simplest solution to these problems, if you have the capital, is to buy them.
          • christkv1 hour ago
            I get that but there is always node.js
            • steveklabnik1 hour ago
              They aren&#x27;t exactly the same thing, moving to node would be possible but bun does more than node, so you need to replace the whole thing.
              • christkv46 minutes ago
                Oh for sure. I guess its just as much a Acqui-hire as well as for the tech.
  • up2isomorphism6 hours ago
    I think there will be soon a wave of rewriting rust to language X coming up.
    • echelon4 hours ago
      The other way around.<p>Rust is also one of the best languages to use with AI.
      • skhameneh23 minutes ago
        I like Rust and I&#x27;m an advocate of Rust, but this really isn&#x27;t true (at least it hasn&#x27;t been and I doubt much has significantly changed).<p>The syntax complexity and the ecosystem haven&#x27;t been ideal for LLM development. And there have been publications on findings of LLM efficacy with different languages. Rust is most often towards the lower end of efficiency&#x2F;correctness when benchmarked.<p><a href="https:&#x2F;&#x2F;arxiv.org&#x2F;html&#x2F;2508.09101v1" rel="nofollow">https:&#x2F;&#x2F;arxiv.org&#x2F;html&#x2F;2508.09101v1</a>
        • steveklabnik14 minutes ago
          This paper uses models that are over a year old at this point. Many people didn&#x27;t believe that LLMs were worth using for programming until 6 months after that, and now again this week we&#x27;ve had another huge leap in abilities.<p>This is beyond the other issues with the methodology of this study. For example, their Rust code was created by asking Deepseek to port their C++ code, not having it try and write Rust itself.
  • dminik5 hours ago
    While I&#x27;m a rust enthusiast, I do agree that certain languages lend themselves well to particular domains. So a rewrite from Rust to something better suited is fine by me. In fact, while I do work on a rust project, I would not have and still would not recommend it as the choice for that particular project.<p>That being said, I had to do some double takes while reading this.<p>&gt; <a href="https:&#x2F;&#x2F;rtfeldman.com&#x2F;rust-to-zig#memory-safety-post-rewrite" rel="nofollow">https:&#x2F;&#x2F;rtfeldman.com&#x2F;rust-to-zig#memory-safety-post-rewrite</a><p>I feel that it&#x27;s a bit weird to compare a rather well tested 7 (?) year old rust implementation with a brand new not yet released less than a year old Zig implementation. Without that context, this looks like a bad comparison for rust, when it is in fact the complete opposite.<p>&gt; <a href="https:&#x2F;&#x2F;rtfeldman.com&#x2F;rust-to-zig#build-times" rel="nofollow">https:&#x2F;&#x2F;rtfeldman.com&#x2F;rust-to-zig#build-times</a><p>The swiftness of the Zig compilere here is insane, and would would very much shift my recommendation of Rust if it got to similar speeds.<p>That being said, I do find it funny that currently, the compilation speed is actually worse on Zig than Rust, despite Zig (anonymous commenters at least tbf) claiming the opposite for years.<p>How did you eventually discover the 35 ms figure for Roc? Did you have to temporarily update the codebase to 0.17?<p>&gt; <a href="https:&#x2F;&#x2F;rtfeldman.com&#x2F;rust-to-zig#memory-control-zero-parse-deserialization" rel="nofollow">https:&#x2F;&#x2F;rtfeldman.com&#x2F;rust-to-zig#memory-control-zero-parse-...</a><p>Nothing negative here. I did play around with implementing a scripting language in this DOD-ish, index-based paradigm and yeah, it is neat.<p>I was thinking that it might be possible to do resumable computation across the network like this (in the context of frontend frameworks &quot;resuming&quot; UIs), but ultimately I have no use for this so just the experience itself was enough.<p>One note here is that it does tend to break completely if non-pointer-free data is introduced. It seems like it&#x27;s either all or nothing.<p>&gt; <a href="https:&#x2F;&#x2F;rtfeldman.com&#x2F;rust-to-zig#ecosystem-relevance" rel="nofollow">https:&#x2F;&#x2F;rtfeldman.com&#x2F;rust-to-zig#ecosystem-relevance</a><p>This is more of an LLVM thing, which is fair, but I find it funny that &quot;LLVM unstable bad&quot; while &quot;Zig unstable whatever&quot;.<p>Overall though, this was an interesting read. And if the folks contributing to roc like zig then more power to them.<p>Last thing, the link here is broken (points to a TODO):<p>&gt; Zig&#x27;s compiler itself is another
    • andriy_koval4 hours ago
      &gt; In fact, while I do work on a rust project, I would not have and still would not recommend it as the choice for that particular project.<p>wondering what type of project is that? I think besides some very embedded projects with very little memory where you need C&#x2F;assembly, rust is good enough for all kind of projects..
      • dminik4 hours ago
        I work both on a pretty much bog-standard web (GraphQL) backend and the frontend that uses it. We switched over from Apollo on node to async-graphql on Rust.<p>The runtime performance is much better, but the compiler time performance is terrible. To be fair, this is mostly the fault of async-graphql, but that doesn&#x27;t really matter all that much. For example, it&#x27;s not uncommon for a single character SQL query change to trigger over a minute long incremental rebuild.<p>The rust compiler is just choking on the number of generics and codegenned functions.<p>I&#x27;ve personally looked at how to improve this, but short of breaking up the type graph using federation, nothing can help. Not even cranelift makes a noticeable dent.<p>Additionally, the team started off composed by a bunch of TypeScript&#x2F;React&#x2F;Node developers, so mistakes were made along the way.<p>Honestly, I would have recommended to just use C#.<p>That&#x27;s not to say that I don&#x27;t think Rust can work for web development. We have some (GraphQL-less) services where Rust is a great fit. Just maybe shouldn&#x27;t have been the default. That or give up graphql ...
        • steveklabnik4 hours ago
          For whatever it&#x27;s worth, I share some of your async-graphql woes, though I haven&#x27;t investigated things deeply enough to have strong opinions about what to do instead.
  • kyo5uke29 minutes ago
    [dead]
  • nntlol6 hours ago
    [dead]
  • kotberg2 hours ago
    [dead]
  • throwaway6137466 hours ago
    [dead]
  • jdw645 hours ago
    [dead]
  • baerbelblue2 hours ago
    [dead]
  • stymaar5 hours ago
    Irrespective to the technical merits of both language, moving from a stable language to a pre-1.0 one that just lost his most popular open source project is a wild move.
    • estebank5 hours ago
      &gt; that just lost his most popular open source project<p>As they state in the article, they started the migration a year and a half ago, something that happened a few weeks back would never come into the decision making process.
  • royal__5 hours ago
    I don&#x27;t even know what Zig is but I&#x27;ve seen this topic come up so many times on this site that I&#x27;m starting to think the people who are actually doing this are unsure themselves whether it&#x27;s a good idea or not.
    • pjmlp5 hours ago
      Basically the security model of Modula-2 or Object Pascal, with a curly brackets syntax, and compile time execution.<p>Some folks embrace it as some kind of novelty.
    • uaksom2 hours ago
      It does seem like they&#x27;re trying to convince themselves. If you like Zig, that&#x27;s a good enough reason to use it. Why waste time on language tribalism?<p>I have the same issue with &quot;use the right tool&quot; rhetoric. The right tool is the one that does the job and that you know best.