21 comments

  • Animats2 hours ago
    I could see migrating from C or C++ or Python to Rust, for various reasons, but for web back-end work Go is a good match. I write almost entirely in Rust, but the last time I had to do something web server side in Rust, I now wish I&#x27;d used Go.<p>The OP points out the wordyness of Go&#x27;s error syntax. That&#x27;s a good point. Rust started with the same problem, and added the &quot;?&quot; syntax, which just does a return with an error value on errors. Most Go error handling is exactly that, written out. Rust lacks a uniform error type. Rust has three main error systems (io::Error, thiserror, and anyhow), which is a pain when you have to pass them upward through a chain of calls.<p>(There are a number of things which tend to be left out of new languages and are a pain to retrofit, because there will be nearly identical but incompatible versions. Constant types. Boolean types. Error types. Multidimensional array types. Vector and matrix types of size 2, 3, and 4 with their usual operations. If those are not standardized early, programs will spend much time fussing with multiple representations of the same thing. Except for error handling, these issues do not affect web dev much, but they are a huge pain for numerical work, graphics, and modeling, where standard operations are applied to arrays of numbers.)<p>Go has two main advantages for web services. First, goroutines, as the OP points out. Second, libraries, which the OP doesn&#x27;t mention much. Go has libraries for most of the things a web service might need, and they are the ones Google uses internally. So they&#x27;ve survived in very heavily used environments. Even the obscure cases are heavily used. This is not true of Rust&#x27;s crates, which are less mature and often don&#x27;t have formal QA support.
    • fpoling2 hours ago
      For me the main advantage of Go over Rust is compilation speed. Then compared with Go Rust still rely on many C and C++ libraries making it problematic to cross-compile or generate reproducible builds or static binaries.<p>The minus side of Go is too simplistic GC. When latency spikes hit, there are little options to address them besides painful rewrite.
      • uh_uh2 minutes ago
        What kind of apps are you writing where GC spikes matter?
      • hedgehog1 hour ago
        I&#x27;ve run into GC pauses, I think in many (most?) cases there is some class of bulky data that you can either move into slices of pointer-free structs (so the GC doesn&#x27;t scan them) or off-heap entirely. The workload where GC is slow is also likely prone to fragmentation so whatever the language you&#x27;ll have to deal with it.
        • fpoling40 minutes ago
          Java with its copying GC deals fine with fragmentation albeit at the cost of more upfront memory. And even in Rust one can change the allocator to try to deal with fragmentation. But with Go there is simply no good options besides the rewrite.
      • throwaway89434535 minutes ago
        Isn’t it somewhat easy to remove allocations in Go? I haven’t had to “rewrite” as such, but rather lifting some allocation out of loop. Am I misunderstanding the scenario?
        • fpoling26 minutes ago
          With backend serving many clients with widely varying performance profile of individual requests when latency spikes happen there is no particular hot loop. Just many go routines each doing reasonable thing but with a particular request pattern hitting pathological case of GC.
    • lionkor2 hours ago
      &gt; Rust lacks a uniform error type<p>Rust has practically one error, it&#x27;s the Error trait. The things you&#x27;ve listed are some common ways to use it, but you&#x27;re entirely fine with just Box&lt;dyn Error&gt; (which is basically what anyhow::Error is) and similar.
      • fweimer2 hours ago
        Surely you need an alternative to Box&lt;dyn Error&gt; for reporting memory allocation failures?!
        • dwattttt1 hour ago
          A &amp;(dyn Error + &#x27;static) should be fine for that; you don&#x27;t need any allocated&#x2F;variable sized data in a memory allocation failure.
          • dnautics21 minutes ago
            stacktraces? might also be useful to know whether or not the latest allocand was a jumbo sized allocand that caused the failure?
            • dwattttt13 minutes ago
              Do you really want that data passed back down to the caller of the allocation? From the description of the failure state you&#x27;d want to log that data instead: what&#x27;s the caller of the allocation going to do if you tell it it failed with a crazy size? It already knows the size, it&#x27;s the one who asked for it.
      • BobbyJo2 hours ago
        Having many semantic options for error usage is functionally the same as having many error types, except worse.
        • ViewTrick10022 hours ago
          They all convert seamlessly, and the enums make the branches explicit. Don&#x27;t even need to check the documentation to find which errors supposedly exists like in Go with its errors.Is, errors.As, wrapping and what not.<p>An easy rule before you make a knowledge based choice is Thiserror for libraries, helping you create the standard library error types and Anyhow for applications, easy strings you bubble up.<p>Or just go with anyhow until you find a need for something else.<p><a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;anyhow" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;anyhow</a><p><a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;thiserror" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;thiserror</a>
          • throwaway89434519 minutes ago
            I’ve repeatedly tried using Rust and the error handling has tripped me up every time and has been ~90% of the reason for moving a project back to another language. I’m sure I’m just holding it wrong, but what I run into usually goes something like this (mind you, I have read the Rust book):<p>* Someone tells me to use enums for errors, in a comment like yours<p>* I try writing the enums by hand, implementing the error trait<p>* I realize that in order to use the ? operator I need to implement From on my errors (I’ve read so many comments about how awfully verbose Go errors are, so I assume I’m supposed to use ? in Rust). There are also some other traits IIRC but I’ve forgotten them.<p>* I realize that this is pretty tedious, manual work, so someone points me to thiserr or similar<p>* Now I’m debugging macro expansion errors and spending approximately the same amount of time<p>* I ask around and someone tells me not to bother with thiserr and to just write the boilerplate myself or else to use anyhow or boxed errors everywhere<p>* I try using boxed errors everywhere, which works, but now I have all of these allocations which feels like I’m doing something that will bite me later. Oh well, but now I need to annotate my errors so I can figure out what is actually happening. I guess I should use anyhow for this?<p>* Anyhow mostly works but this is approximately as verbose as the Go error handling that I’m told is Very Bad, and when I ask for code review most Rust people are telling me not to use anyhow because errors should be enums, at least in the API surface<p>I’m sure I’m doing it wrong, but as with many things in Rust, the Right Way is so rarely clear and every other Rust person gives different advice about how to solve my problem and the only thing they seem to agree on is that Rust has an easy solution and that I’m following the wrong advice. (Similarly when I had lifetime problems and half the community told me to just use clone and Rc everywhere until I had performance problems, so instead I just had different static analysis problems).<p>I don’t love Go’s error handling. It feels like there has to be something better than its runtime-typing. But it largely gets out of the way—creating an error is just implementing the Error method, and if you need a concrete type you use Is&#x2F;As&#x2F;AsType. Wrapping is fmt.Errorf. All of this is built into the stdlib and used pretty ubiquitously across the ecosystem—I don’t run into “this dependency uses a different error framework”. Error handling is marginally more verbose than with Rust if you are actually attaching context in both, and neither solves the problem of which call frame attaches the context about specific function parameters (e.g., which level of error context specifies that the function was called with path “&#x2F;foo&#x2F;bar.baz”). It’s terrible, but it works—feels like the least bad thing until the Rust community can arrive at some consensus and document it in The Book. Or maybe I just need to try again in the LLM era?
            • ViewTrick10027 minutes ago
              How come you get macro expansion errors? Or is it because you write incorrect syntax in the enum error definitions?<p>The example on the docs page is quite clear:<p><a href="https:&#x2F;&#x2F;docs.rs&#x2F;thiserror&#x2F;latest&#x2F;thiserror&#x2F;#example" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;thiserror&#x2F;latest&#x2F;thiserror&#x2F;#example</a><p>Including all kinds of errors: Strings, tagged unions and automatically converting from std::io::Error with added context.<p>That one page document is the entire documentation for the thiserror crate.
    • mikeocool2 hours ago
      I was a big fan of go for a while. Though now that I have programmed more swift and rust recently, having a compiler that doesn’t protect against null pointer deferences or provide concurrency safety guarantees feels a little prehistoric.<p>Though go certainly did a much better job than rust on the standard library front.
      • boccko1 hour ago
        Standard library is something you have to maintain for all eternity, with identical API. It had been argued that some concurrency primitives like channels would have been better outside of std (for rust, to be clear). Once dependency management is solved, a small std is beneficial.
        • j1elo6 minutes ago
          &gt; <i>you have to maintain for all eternity, with identical API</i><p>People always tout this as a huge reason for not wanting a too big std in Rust (or &quot;too useful&quot; either), but IMHO that&#x27;s just talking about reaching theoretical optimals, while leaving the community for years without good guidance via providing a opinionated practical and pragmatic way of doing things. Which I find to be a very unhelpful stance for a tool such as a programming language.<p>If a design of some std package didn&#x27;t pass the test of time, and a new iteration would be beneficial, the language can leave its original API version right there, and evolve with a v2, with an improved and better thought out API after learning from the mistakes of v1.<p>Prime example: &quot;hey we found that math&#x2F;rand had some flaws, so here is math&#x2F;rand&#x2F;v2&quot;. A practical solution, and zero dramas as a result of having rand be part of std.
        • ok_dad5 minutes ago
          I use go because of the large and useful stdlib. I rarely have to reach for an external library, and even then I only consider libraries that are very popular. If a library isn’t available, I’ll just write my own, using the stdlib. I recently used the awesome crypto library to implement an envelope encryption system, I didn’t need anything outside of the stdlib or Google’s x library (x is effectively the experimental stdlib).<p>Having too much external code, like npm or rust crates, seems like a nightmare for me.
    • the__alchemist2 hours ago
      I agree! The line early on about this being for backend services caught my attention. I love the Rust language and use it for embedded firmware and PC applications, but still use Python for web backends, because Rust doesn&#x27;t have any tool sets on the tier of Django (Or Rails). It has Flask analogs, without the robust Flask ecosystem. I have less experience with Go, but would choose it over Rust for web backends, for the same reason you highlight: The library (including framework) ecosystem. I am also not the biggest Async Rust fan for the standard reasons (The rust web ecosystem is almost fully Async-required).
    • atombender55 minutes ago
      For backend web dev, there are advantages. I really like Axum&#x27;s use of typing:<p><pre><code> pub async fn dataset_stats_handler( Path(dataset_id): Path&lt;String&gt;, Query(verbose): Query&lt;bool&gt;, ) -&gt; impl IntoResponse { ... } </code></pre> With a route like:<p><pre><code> .route(&quot;&#x2F;datasets&#x2F;{dataset_id}&#x2F;stats&quot;, get(dataset_stats_handler)) </code></pre> …the &quot;dataset_id&quot; path variable is parsed straight into the dataset_id arg, and a query string &quot;verbose&quot; is parsed into a boolean. Super convenient compared to Go, and you type validation along with it.<p>Many other things to like: The absence of context.Context, the fact that handlers can just return the response data, etc.<p>What I don&#x27;t like: Async.
      • ricardobeat1 minute ago
        go is slightly more verbose (surprise) but you can achieve the same thing using struct binding in gin:<p><pre><code> type DatasetStatsQuery struct { Verbose bool `form:&quot;verbose&quot;` } func DatasetStatsHandler(c *gin.Context) { datasetID := c.Param(&quot;dataset_id&quot;) var query DatasetStatsQuery if err := c.ShouldBindQuery(&amp;query); err != nil { c.JSON(http.StatusBadRequest, gin.H{&quot;error&quot;: err.Error()}) return } &#x2F;&#x2F; query.Verbose == boolean }}</code></pre>
    • iknowstuff2 hours ago
      Rust does not have three error systems. It has one: the Error trait. io::Error is one of many that implement it (nothing special about it). Errors defined via thiserror also implement it.<p>“Anyhow” just allows you to conveniently say “some Error” if you don’t care to write out an API contract specifying types of errors your function might spit out.
      • tptacek1 hour ago
        He&#x27;s not making that up; in practice, you&#x27;re going to run into and need to make mental space for the idiosyncrasies of multiple error frameworks.
        • dwattttt1 hour ago
          I guess you might have to if you need to use a library someone&#x27;s written that doesn&#x27;t implement the standard.<p>Writing primarily applications, I couldn&#x27;t tell you what error handling frameworks my dependencies are using: I literally don&#x27;t know, and haven&#x27;t needed to know in order to display, fail, or succeed.<p>EDIT to add: I use anyhow for this, so I should also add &quot;add context to an error when I fall&quot; to the list of things I do.
          • the__alchemist28 minutes ago
            What&#x27;s the standard? I&#x27;m not being snarky; I&#x27;m going down the thought process of how this would work in practice.<p>I am on team Io Error [on std rust]&quot;, somewhat arbitrarily. If I call a lib that is on Team Anyhow, or Team Custom Error Enum, I will have to do some (Straightfoward, but a little clumsy) conversions if I want ? to work. This is complicated by being able to impl From&lt;ErrorType1&gt; for ErrorType2 only in one direction if you don&#x27;t control the other crate. (due to the orphan rule)
            • dwattttt9 minutes ago
              By standard I meant an error type that implements std::error::Error.<p>EDIT: Which I assume all my dependencies have done, given that anyhow is able to consume all of them.<p>I specifically called out writing applications as my use case: my only objection to tptacek&#x27;s note is the somewhat universal &quot;in practice&quot;. The burden for designing errors for a library that others will use is higher, but that&#x27;s far from the default&#x2F;universal experience.<p>Many more people are going to consume libraries &amp; not produce any of their own, and I think my experience is representative there.
    • LoganDark55 minutes ago
      thiserror and anyhow are just std::error with extra steps. Note that io::error is just a specific std::error.<p>The entire point in Rust is that you wrap Error impls with other Error impls, or translate one impl into another using a match. I&#x27;ve found this is far more flexible and verifiable than most other languages, because if you craft your error types with enough rigor, you can basically have a complete semantic backtrace without the overhead of a real backtrace.<p>I use thiserror a lot to help with my impls. Notably, all it does is impl Display and Error. It&#x27;s not a specific other paradigm because it basically compiles out, it&#x27;s just a macro.<p>Anyhow is perhaps the closest one to another paradigm because it allows you to discard typed information in favor of just the string messages, but it still integrates well with Errors (and is one).
    • innocentoldguy1 hour ago
      I find Elixir&#x27;s memory and threading models much more compelling than Go&#x27;s for web services. There are many great libraries for Elixir as well, but if you need something else, Elixir makes rolling your own libraries very easy. I&#x27;d recommend giving Elixir a try, if you haven&#x27;t already.
    • LtWorf2 hours ago
      Praising go for how it handles errors, when it&#x27;s even worse than C where the compiler at least warns you if you&#x27;re ignoring return values of calls. That&#x27;s a new one.
      • awesome_dude2 hours ago
        Linters are available to catch you before you compile - with Go<p>Generally speaking there has to be a mechanism for optional handling of return values, in Go you can ignore everything (ew), you can use placeholders `_`, or you can explicitly handle things - my preference.<p>If you say &quot;Well in C you have to handle the returns - I am not across C enough to comment, but I will ask you - Does C actually force you, or does it allow you to say &quot;ok I will put some variables in to catch the returns, but I will never actually use those variables&quot; - because that&#x27;s very much the same as Go with the placeholder approach<p>edit: I am told the following is possible in C<p>trySomething(); &#x2F;&#x2F; Assumes that the author of trySomething has not annotated the function as a `nodiscard`<p>(void)trySomething(); &#x2F;&#x2F; Casts the return(s) to void, telling the compiler to ignore the non-handling<p>int dummy = trySomething(); &#x2F;&#x2F; assign to a variable that&#x27;s never used again<p>I welcome correction
  • amusingimpala753 hours ago
    This is probably going to sound generic &#x2F; repetitive, but my biggest complaint about Rust is the package management situation, which is entirely the result of the developer mindset. I love the ergonomics on the rust side (the functional approach to data types is beautiful), but I’m working on two projects side by side, one in rust and one in go at the moment. The dependency trees are entirely different beasts, with most of the stuff on the go project covered by the stdlib whereas I think the rust project is over 400 despite asking for <i>just</i> rusqlite (sqlite), clap (cli), ratatui (tui), and tauri (gui), the last of which is by far the worst offender but even without it, it’s still close on 100 which is crazy. If there were (and maybe there are, I just haven’t found them) decently maintained alternatives to the rust crates that <i>actually have a sane dependency approach</i>, I’d feel much better. I’m just trying to not shai hulud my system, and the rust-web people seem to want to turn cargo into npm in that regard.
    • praseodym2 hours ago
      Note that many Rust libraries consist of multiple crates, which all end up in the dependency graph. This makes the number of dependencies seem higher than it actually is: the separate crates have the same maintainers and are often part of the same upstream git repo.<p>I agree with the general sentiment though. Rust also has a lot of crates that are stuck semi-unmaintained at some 0.x version, often with no better alternative.
      • vlovich1232 hours ago
        Unfortunately the 0.x version has pervaded because of community cargo culting claiming that versioning is easier with 0.x than with major version numbers &gt; 0. Personally I find that hard to believe, especially given packages like Tokio and anyhow (still at v1) make it work and there’s others that are &gt;v1.<p>That is to say 0.x doesn’t necessarily mean unmaintained, it can also mean “I don’t want to have to think about how to version APIs &#x2F; make guarantees about APIs). Eg reqwest is very widely used and actively maintained yet is still at v0.13.
        • nicoburns34 minutes ago
          &gt; claiming that versioning is easier with 0.x than with major version numbers &gt; 0<p>I think it&#x27;s less that versioning is claimed to be easier with 0.x versions, and more that some people have got into their heads that 1.0 signals either &quot;permanently stable&quot; or &quot;no new versions for several years&quot; and they don&#x27;t want to commit to that yet.<p>I do wish more crates would 1.0 (and then 2.0, etc).
      • J_Shelby_J2 hours ago
        There is good reasons to break out projects into multiple crates. It makes reusing functionality elsewhere easier. It makes it easier to reason about behavior. It makes it easier for LLMs to understand (either working within the crate or consuming as an api surface.) So you end up with projects that have multiple crates inside the same workspace and it really blows up dependency count.
        • nicoburns33 minutes ago
          The other very important reason for splitting into crates is compile times. Crates are the &quot;compilation unit&quot; and you often get more build paralellism with more crates.
    • ViewTrick10022 hours ago
      &gt; rusqlite (sqlite), clap (cli), ratatui (tui), and tauri (gui)<p>Does any language, except like Java, exist with a standard library comprising matching that?<p>Also, keep in mind that Tauri itself is 14 crates, where each one shows up in your build tree.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;tauri-apps&#x2F;tauri&#x2F;blob&#x2F;dev&#x2F;Cargo.toml" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tauri-apps&#x2F;tauri&#x2F;blob&#x2F;dev&#x2F;Cargo.toml</a><p>And Ratatui is 6:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ratatui&#x2F;ratatui&#x2F;blob&#x2F;main&#x2F;Cargo.toml" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ratatui&#x2F;ratatui&#x2F;blob&#x2F;main&#x2F;Cargo.toml</a>
      • PyWoody1 hour ago
        Python has sqlite3[0], curses (tui) [1], and tkinter[2] in the stdlib.<p>[0] <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;sqlite3.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;sqlite3.html</a><p>[1] <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;curses.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;curses.html</a><p>[2] <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;tkinter.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;tkinter.html</a>
        • ViewTrick10021 hour ago
          Right. The famous stdlib where once good libraries go to die so you instead depend on the latest community replacement choice.<p>Also argparse for Clap:<p><a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;argparse.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;argparse.html</a>
    • OtomotO2 hours ago
      The stdlib is the place where good ideas go to die.<p>And then you have httplib3 followed by httplib4.<p>In other words: I highly prefer the Rust approach.<p>It doesn&#x27;t matter a lot whether I rely on the stdlib or another dependency to me.<p>It&#x27;s a dependency after all.<p>People think just because it&#x27;s the stdlib it&#x27;s somehow better quality or better maintained, but these are orthogonal concepts.<p>In the end it depends solely on resources.<p>Sure, the stdlib may get more of these, but it may also grow fat and unmaintainable...
    • awesome_dude2 hours ago
      Package management is the bane of nearly every language&#x2F;technology<p>Nobody has &quot;solved&quot; it, and I don&#x27;t think that there will ever be one (never say never, though, right?)<p>For Go we rely on developers of libraries to adhere to the semver versioning scheme accurately, and we cannot &quot;pin&quot; versions (a personal bugbear of mine)<p>There is a couple of workarounds - using SHAs not unlike the git commit hash to provide a pseudo version, and, vendoring (which is a cache of known dependencies - which brings with it cache management problems)<p>I had the misfortune of having to use Python with a virtual env on the weekend - it did not end well, and reminded me why I migrated away from Python.<p>Look at Perl (cpan) Java (maven, gradle) Ruby (gems) Go (dep, glide, vgo, modules) Rust (cargo) Node (npm, yarn, etc)<p>OSes too Redhat (yum, rpm, etc) Debian (apt) Ubuntu (snap - god why????)<p>And so on
      • corndoge2 hours ago
        Nix solved it. Languages could choose to adopt Nix as their packaging system.
        • tadfisher1 hour ago
          It did and didn&#x27;t. Nix tools for building language-specific packages almost always wrap the language build tool&#x2F;package manager. This can be easy or hard, depending on how onerous the build tool is for vendoring libraries.<p>What Nix and build tools need to agree on is a specification or protocol for &quot;building a software dependency tree&quot;. Like, I should be able to say &#x27;builder = cargo&#x27; in a Nix derivation and Cargo should be able to pick up everything it needs from the build environment. Alas, there is simply far too much tied up in nixpkg&#x27;s stdenv for this to be viable, so we have magic stdenv builder behavior via hooks when a build tool is included in nativeBuildInputs.
          • awesome_dude1 hour ago
            I think one of the key problems too is that a system level dependency is managed by people dedicated to ensuring the chaotic nature of the package they are responsible for conforms to the way the OS they are maintaining for has proscribed.<p>There&#x27;s no real way to do that at a language level - we cannot have &quot;Go has determined the package you are trying to fix has not met the versioning requirements proscribed so you cannot submit the patch to fix it&quot;<p>What language dependencies do is what OSes would think of as &quot;unofficial versioning&quot; that is, an OS will let you install and run an unofficial version of some lib (we&#x27;ve all been there, right, multiple versions of some core library because one doesn&#x27;t work with whatever you are trying to install), but they will not manage it at all.
    • repelsteeltje2 hours ago
      Interesting. I&#x27;m not very familiar with Go. What is the equivalent for Tauri in Go&#x27;s stdlib?<p>Would it make sense to continue using Go for the frontend and doing only the backend in Rust for your user case?
      • fatty_patty892 hours ago
        wails, there&#x27;s wails3-alpha which some people said is even better than tauri
        • repelsteeltje2 hours ago
          Thanks. Is wails a Go stdlib component, as GP implied or is it third party?
          • fatty_patty892 hours ago
            tauri isn&#x27;t stdlib and neither is wails
    • JuniperMesos2 hours ago
      Why is it worse to import a number of other packages that provide exactly the functionality you need, than to have a large standard library that provides some but not all of the functionality you need, requiring you to still use some large dependencies?
      • pier251 hour ago
        For example, security. See all the supply chain attacks from the past couple of years.
  • tptacek1 hour ago
    This is a weird document that is simultaneously trying to serve as a migration guide and an advocacy document for Rust.<p>Ultimately, <i>if you have to ask</i>, the Rust vs. Go consideration boils down almost completely to &quot;do you want a managed runtime or not&quot;. A generation of Rust programmers has convinced itself that &quot;managed runtime&quot; is bad, that not having one is an important feature. But that&#x27;s obviously false: there are more programming domains where you want a managed runtime than ones where you don&#x27;t.<p>That&#x27;s not an argument for defaulting to Go in all those cases! There are plenty of subjective reasons to prefer Rust. I miss `match` when I write Go (I do not miss tokio and async Rust, though). They&#x27;re both perfectly legitimate choices in virtually any case where you don&#x27;t have to distort the problem space to fit them in (ie: trying to write a Go LKM would be a weird move).<p>The Rust vs. Go slapfight is a weird and cringe backwater of our field. Huge portions of the industry are happily building entire systems in Python or Node, and smirking at the weirdos arguing over which statically typed compiled language to use. Python vs. (Rust|Go) is a real question. Rust vs. Go isn&#x27;t.
    • tempest_57 minutes ago
      The use of LLMs has caused Rust usage to explode.<p>If youre not writing the code yourself and vibing away which I think most people generally are despite the disdain around here then why would you not choose the &quot;more performant language&quot; (I know that isnt necessarily reality but it is a common perception).<p>Go&#x27;s managed runtime is less valuable when the LLM is perfectly happy to slap a bunch of stuff together for you to and approximate it and doesn&#x27;t complain at all when writing async rust despite some of the rough edges.
      • tptacek26 minutes ago
        I agree that agents make Rust a lot more tenable for less &quot;kernel-and-browser&quot;-demanding tasks than it was 4 years ago, but I do not agree that they eliminate the &quot;managed vs. unmanaged runtime&quot; question, and to the extent they influence any of this decisionmaking at all, you have to accept the notion of <i>not reading</i> the code. If you&#x27;re reading it, it matters that Rust makes you do bookkeeping that managed runtimes avoid.
    • galangalalgol1 hour ago
      I think I&#x27;d be ok with node via purescript? But in general I think rust and go people should join forces against the evils of dynamic typing. Isn&#x27;t type hinting finally considered best practice now? I think that is effectively an admission that it was a defect. And even with good ginting it is still worse than inference. Inference can let plenty of code go untouched on type changes, while still protecting against unindended type changes.
    • com2kid1 hour ago
      Us Node folks adapted typescript because we wanted static compiled types.<p>I wish TS had more of a runtime. The only thing I&#x27;m jealous of with regards to python is how seamlessly you can do JSON schema enforcement on HTTP endpoints. The Zod hoops are a constant source of irritation that only exists because the TS team is dogmatic.
      • tptacek1 hour ago
        I think Typescript is a perfectly cromulent language. I don&#x27;t know it well but would seriously consider it for any problem that had a shape that admitted a dynamic language. There&#x27;s a lot to be said for using dynamic languages, too!
        • com2kid56 minutes ago
          Every non-runtime language is dynamic after being compiled to x64 machine code!<p>It is illusions and lies all the way down the instant the compiler finishes its job.
  • nemo16182 hours ago
    LLM writing tells are getting more subtle, but they still jump off the page for me, in particular the word &quot;genuine:&quot;<p><pre><code> &quot;This is the area where Go genuinely shines, and it’s worth being precise about why&quot; &quot;the lack of GC pauses is a genuine selling point&quot; &quot;Humans are genuinely bad at reasoning about memory&quot; &quot;There are cases where the borrow checker is genuinely too strict&quot; </code></pre> tbc I don&#x27;t think the article was fully AI-generated, just AI-assisted. If so, the author did a <i>genuinely</i> good job of it! No one else is commenting on it, so clearly it didn&#x27;t detract much from the substance. It&#x27;s just weird that this is becoming increasingly common, and increasingly hard to detect.
    • pton_xd2 hours ago
      This is completely off topic now but, &quot;it&#x27;s worth being precise about ...&quot; is a much stronger AI-ism than the usage of the word genuine.
    • dillon1 hour ago
      I have to agree here, but I&#x27;m not sure why. I don&#x27;t have any clue what makes something sound AI generated or not. I got to about here &quot;Go is clearly working for a lot of people,&quot; -- before I became suspicious that it was AI-assisted (but also maybe I&#x27;m wrong and it&#x27;s not AI-assisted, I am very bad at telling). It&#x27;s more about vibes (ironically) than anything else in particular. If something &quot;sounds&quot; AI-assisted then I instantly lose interest even if the article itself is otherwise fine. I wish people were more ok with writing their own thoughts with how it comes to them.
    • tkiolp41 hour ago
      I think the whole post is AI generated. The author could have given a draft as input and perhaps edited the output in a few places.<p>Take this paragraph as example:<p>&gt; Go got generics in 1.18, and they’re useful, but the implementation has constraints (no methods with type parameters, GC shape stenciling, occasional surprising performance characteristics). Rust generics monomorphize, each instantiation produces specialized code with zero runtime cost. Combined with traits, this gives you real zero-cost abstractions.<p>Every sentence says something. Every sentence is important and holds its weight. I would expect that kind of writing from very specialized books or papers, not from a blog post. Also, it makes the post harder (and more boring) to read.
    • bbg24012 hours ago
      I&#x27;ve noticed LLM writing over the past year has had an unusually high tendency to talk about surfaces and, in particular, substrates. I don&#x27;t expect LLM generated text to be anything other than rich with clichés. I simply wish we would all demonstrate a better editorial hand so we weren&#x27;t reading the same voice, over and over.
  • h4kunamata10 minutes ago
    Read migrating from one hype to another, developers never learn or change, do they??<p>It feels like yesterday when every single project was moving to Go just because it was the new hype, that was until Rust was born.<p>We are already seeing projects dumping migration to Rust because the grass is not always greener on the other side.<p>We will be seeing this again, &quot;Migrating from Rust to XYZ&quot;
  • kayo_202110302 hours ago
    If you have a green field, by all means write it in rust. If you have a brown field, and a functional profitable system, rewrite the parts that need rewriting in the <i>original</i> language, whatever that is, and carry on. Make your systems better in small measurable ways, with the language you know and a team you trust to implement it all. Anything else is a wasteful religious argument.
    • Thaxll2 hours ago
      I don&#x27;t see any reasons to use Rust when your team successfully shipped and is confortable with C#&#x2F;Java&#x2F;Go ect ...
      • treavorpasan2 hours ago
        If anyone one comes and tells me we need to rewrite in a new language from any of those modern languages, other than you are dealing with something cannot wait for GC.<p>That is a signal that person is lacking purpose in their job or life.
  • cbondurant1 hour ago
    I already use Rust and don&#x27;t have experience with Go, so this article maybe isn&#x27;t super for me.<p>I do have one nitpick though: Stating that data races are &quot;caught at compile time&quot; in Rust feels like it is overstating the case, at least a little. It sounds a bit like its implying Rust can also handle things like mutual lock starvation, or other concurrency issues. When that&#x27;s simply not the case. I know &quot;data race&quot; is technically a formal term, with a decently narrow scope, yet I still think it could be a bit clearer about it.
  • geenat2 hours ago
    If verbosity is a main stickler, this is coming to golang 1.28 which will cut it down drastically:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;issues&#x2F;12854#issue-110104883" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;issues&#x2F;12854#issue-110104883</a>
    • p2detar2 hours ago
      That actually looks great. Thanks a lot for the link.
  • Thaxll2 hours ago
    &quot;services that your organization relies on, that have high uptime requirements, that are critical to your business&quot;<p>Kind of funny when your Rust service runs on Kubernetes.
  • hasyimibhar1 hour ago
    It is also easier to make your code deterministic with Rust vs with Go, which is incredibly useful if you need to perform deterministic simulation testing + property-based testing. I recently wrote a Postgres-to-Iceberg data mirroring tool [1] in Go, but I ported it to Rust because I wanted the ability perform DST without fighting Go&#x27;s runtime [2]. But if the domain is not critical that warrants DST, I would still pick Go over Rust any day.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;polynya-dev&#x2F;pg2iceberg" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;polynya-dev&#x2F;pg2iceberg</a><p>[2] <a href="https:&#x2F;&#x2F;www.polarsignals.com&#x2F;blog&#x2F;posts&#x2F;2024&#x2F;05&#x2F;28&#x2F;mostly-dst-in-go" rel="nofollow">https:&#x2F;&#x2F;www.polarsignals.com&#x2F;blog&#x2F;posts&#x2F;2024&#x2F;05&#x2F;28&#x2F;mostly-ds...</a>
  • gertlabs2 hours ago
    I liked Rust before running a benchmark, but the gap between how effectively most LLMs write in Rust vs Go was still surprisingly large to me (especially in agentic harnesses where they can fix the initial environment issues). I&#x27;ve become a pretty big Rust evangelist after seeing that. We&#x27;ve had a lot of success writing batch processing tools in Rust to be called by our existing codebase, but haven&#x27;t attempted a full production migration... yet.<p>I will say that many of the issues with Go in the article, especially re: nil handling are increasingly solved by thorough coding reviews with Codex. Better to not have the issue in the first place, sure, but these kinds of security bugs are becoming optional to developers who put in at least as much effort to review and understand code as they put into the initial design and execution.<p>Language data at <a href="https:&#x2F;&#x2F;gertlabs.com&#x2F;rankings?mode=agentic_coding" rel="nofollow">https:&#x2F;&#x2F;gertlabs.com&#x2F;rankings?mode=agentic_coding</a>
    • J_Shelby_J2 hours ago
      The detailed compiler errors and strong type system makes the change -&gt; compile -&gt; change loop simple for agents to handle. Rust provides very strong rails it forces users on to. Codex always manages to get something to compile.<p>The downside is that maybe it should fail sometimes when an idiomatic approach isn’t viable… instead it will implement something stupid that compiles and meets the request.
    • logicchains2 hours ago
      The weakness of Rust WRT LLMs is compilation times. LLMs code faster and hence spend relatively more time waiting for compilation than humans do, so on reasonably sized projects (e.g. 100k+ lines) Rust&#x27;s ~10x slower compilation starts showing up as a bottleneck. If you&#x27;re writing some critical infrastructure it makes sense to pay that cost, but if you&#x27;re writing some internal service that&#x27;s not publicly exposed to the internet then development velocity may be a bigger concern. (I&#x27;d argue that slow compilation also influences human development velocity, but for some reason developers very rarely try to quantify this.)
      • J_Shelby_J2 hours ago
        10x slower is like an extra second, if that, for compilation times for the sizes of changes an agent like codex makes.
  • arccy2 hours ago
    perhaps the oncall is better if you write your own services, but as an SRE &#x2F; ops person who has to run other people&#x27;s services, rust ones just generally seem to be worse: logs that are so verbose but seem to tell you nothing, statsd seems to be the only choice for metrics, contextless errors everywhere, memory &quot;leaks&quot; (more like runaway memory use) that the developers swear are impossible because it&#x27;s rust, overall just less mature across services written by both in house and oss teams
  • wpollock1 hour ago
    Very nice write up! I am a fan of Rust and have little exposure to Go. That said, a couple of very minor points:<p>cargo audit is not built-in, it is 3rd party. (The comparison table near the top isn&#x27;t clear about that, and the following text stating more is built-in for Rust than for Go might be confusing. I would suggest adding an asterisk to mark built-ins in that table.)<p>cargo watch has been in &quot;maintenance mode&quot; for some time. The author of that suggests cargo bacon instead.
  • arjie2 hours ago
    I do like using Rust quite a bit, but the presence of arbitrary build-time code in build.rs is very risky until we get better at implementing dev-time sandboxing.
  • amazingamazing2 hours ago
    Rust is great. However in an agentic world go will win. Look no further than incremental build times. This, combined with high token costs mean that for a given application it simply will cost more to to write it in Rust than Go.<p>This can easily be justified for many usecases, but for your vanilla crud app, do you really need Rust?<p>Per the article, you are getting 20-50% better more performance with Rust. Not worth it unless your team was already fluent in Rust. Now consider a scenario where your team uses AI exclusively to code, now you are spending more time and tokens waiting around to consume large rust builds. As far as I know this is an inherent property of Rust to have its safety guarantees.<p>I think Rust makes sense for a lot of cases, but for a small web service, overkill and unnecessary imho. If someone ported their crud app from Go to Rust I would question their priorities.<p>Again I am speaking more in terms of software engineering <i>economics</i> than anything else. Yes, I know in a perfect world Rust binaries are smaller, performance is better and code more “correct”, but the world is hardly perfect. People have to push code quickly, iterate quickly. Teams have churn, Rust, frankly is alien for many, etc.
    • natsucks2 hours ago
      Because the agentic world involves the generation of so much code that gets harder to review, I would think the compile-time guarantees of Rust would make it a better option.
      • amazingamazing2 hours ago
        This is true if the token budget and time are not taken into account. In practice though, waiting minutes instead of seconds per build multiplied by prompt and again by change adds up very fast.
        • nicoburns2 hours ago
          Incremental Rust builds are almost never minutes (on recentish hardware)<p>A quick measurement on my web browser project with almost 600 dependencies:<p>- A <i>clean</i> &quot;cargo check&quot; was 31s<p>- An incremental &quot;cargo check&quot; with a meaningful change was 1.5s<p>Building is a little slower:<p>- A clean &quot;cargo build&quot; was 56.01s<p>- An incremental &quot;cargo build&quot; was 4s<p>But I find that LLMs are mostly calling &quot;check&quot; on Rust code.<p>---<p>That&#x27;s on an Apple M1 Pro. The latest M4&#x2F;M5 machines as ~twice as fast.
          • amazingamazing2 hours ago
            I mean i wouldnt call a 100% a little slower wrt check vs build. In any case, the more you change the longer the incremental check or build will take.
            • nicoburns2 hours ago
              Sure, but when we&#x27;re talking single-digit seconds it feels not that significant regardless?
              • amazingamazing1 hour ago
                My point is that it isn&#x27;t necessarily that fast. It is relative to the amount of changes and where they were made. For a fair comparison you would also have to present the worst case incremental build time which approaches the full build time (this goes for Go too), which per your own example is nearly a minute for rust.
            • J_Shelby_J2 hours ago
              1.5s for a massive project, on a laptop,like the OP said is still barely anything in the context of agentic coding. It’s less than a single percentage point of the total time in the loop, even if the agent has to compile multiple times.<p>This is cope.<p>I do give you that rust is more verbose and thus more token heavy. However that verbosity is meaningful and the LLM would have to spend tokens thinking about the code to understand less verbose languages. So I’d consider that a wash - in some cases it hurts and in some it helps.
              • amazingamazing1 hour ago
                We don’t know how massive the project is, but in any case building and immediately building again of course will be fast. How fast is it if all files have a single line changed, for example refactoring a log message?<p>Not to mention we haven&#x27;t even gotten to discussing tests.
                • nicoburns38 minutes ago
                  &gt; in any case building and immediately building again of course will be fast<p>FWIW, the compile time test above was done comparing consecutive commits. Which in this case happened to have ~3-4 lines changed.
        • natsucks2 hours ago
          When everyone is armed with Mythos-like hacking ability, it&#x27;s hard for me to imagine people wouldn&#x27;t make the tradeoff of security over price.
    • nicoburns2 hours ago
      &gt; As far as I know this is an inherent property of Rust to have its safety guarantees.<p>From what I&#x27;ve seen, Rust&#x27;s strictness is actually a huge win for LLMs, as they get much better feedback on what&#x27;s wrong with the code. Things like null checking that would be a runtime error in Go are implied by the types &#x2F; evident in the syntax in Rust.
    • crabmusket2 hours ago
      &gt; spending more time and tokens waiting around<p>Can you clarify how you&#x27;re spending tokens on waiting? My understanding is that the LLM isn&#x27;t actually necessarily doing anything while a build runs. The whole process end to end may take longer for sure (ignoring things like the compiler catching more errors, that&#x27;s really hard to factor in) but how does that correlate to more tokens?
      • amazingamazing2 hours ago
        &gt; The whole process end to end may take longer for sure (ignoring things like the compiler catching more errors, that&#x27;s really hard to factor in) but how does that correlate to more tokens?<p>This. rust emits more information both in its output and the syntax itself more complicated requires more tokens.
        • kajman2 hours ago
          The cost of verbose compiler output surely cannot compare to the cost of shipping bugs that would&#x27;ve been caught at build time.
          • amazingamazing2 hours ago
            Indeed, but is it the case that all bugs you have are those in which would be caught by the compiler? It’s not like rust code inherently is bug free.
            • kajman1 hour ago
              Of course, there&#x27;s plenty of bugs in Rust code still. The fact that safe Rust should be able to statically guarantee entire classes of bugs like <i>data</i> races are impossible is a huge deal, though. We&#x27;re totally free to have different values when it comes to what matters, but compile time and a verbose toolchain are not high costs for that, to me. I personally would first consider other things like the cognitive overhead of learning to work with the borrow checker.
    • johnfn2 hours ago
      Can you explain a bit about why token costs would favor Go and not Rust?
      • amazingamazing2 hours ago
        Go is more verbose, but Rust have more complex syntax which in practice require more tokens.<p>The big thing though is because builds are slower, you will end up waiting longer as tests are modified, rebuilt and run. This difference piles up fast.
    • the__alchemist2 hours ago
      &gt; However in an agentic world go will win<p>This is Silicon Valley fantasy.
    • OtomotO2 hours ago
      It&#x27;s a good thing then, that the AI hype is dying outside of ycombinator, the silicon valley and the US
      • amarant2 hours ago
        As someone with a background of consulting in the Stockholm based gaming industry for the last decade+, I have to respectfully disagree. Nearly everyone I know is very much on the hype train. And for good reason too! The capabilities are undeniable!
        • OtomotO2 hours ago
          As is the hype.<p>You know, shovels are useful, they are just more useful to the shovel manufacturer than the gold diggers.<p>But in the end it&#x27;s a cool tool that made it way easier to dig holes and tend to your garden!
          • amarant1 hour ago
            Oh yeah, definitely. There has indeed been a lot of hype overestimating the capabilities. People thinking you can one-shot big complex applications with a few paragraphs of descriptions for example. There has also been a lot of anti-hype, or whatever you call it when people seem to believe LLMs don&#x27;t provide any value for software Dev, basically writing all capabilities off as pure hype.<p>The truth of course is somewhere in the middle.<p>It&#x27;s difficult to tell what people mean when they say hype sometimes.
      • jdw641 hour ago
        [dead]
  • dilyevsky37 minutes ago
    &gt; Under heavy allocation, P99 latency tails are noticeably worse than a Rust equivalent that simply doesn’t allocate on the hot path.<p>Lmao so not an equivalent then? Standard glibc malloc, which is default in rust, will also similarly degrade albeit for different reasons.
  • 0xfurai2 hours ago
    The &quot;when to enforce it&quot; framing is what sticks with me. Go and Rust agree on safety, concurrency, simple deployment, but Go says &quot;catch it in review&quot; and Rust says &quot;catch it before it compiles.&quot; The right answer depends entirely on how expensive a production incident is for you vs. how expensive slower iteration is.
    • LtWorf2 hours ago
      &gt; but Go says &quot;catch it in review&quot;<p>So, in production?
      • airstrike2 hours ago
        It&#x27;s AI slop, it makes no sense
  • LoganDark48 minutes ago
    I still think rustfmt made a mistake by going with four spaces. It&#x27;s basically inferior for everything except forcing everyone to use the same indentation width, which is actually a downside, since I constantly encounter two-space indent codebases that I can&#x27;t read and also can&#x27;t change to four spaces because it&#x27;s not tabs. Also translating spaces to tabs visually is undecidable thanks to alignment, while the inverse is not true. Ugh.
    • cyann22 minutes ago
      I&#x27;ve got a `.rustfmt.toml` file in all my repos with<p><pre><code> hard_tabs = true</code></pre>
      • LoganDark19 minutes ago
        Yep, but because it&#x27;s not the default, plenty of ecosystem tooling just does not properly track the two separate types of leading whitespace (indentation vs alignment) and will happily conflate every tab_width characters of alignment with an indentation level (which is grossly incorrect). I don&#x27;t have an example off the top of my head because I run very far each time it happens.
  • amelius1 hour ago
    Go has shorter and more predictable GC pauses. If a reference count drops to zero in Rust, it may take an unbounded time to free all the things it refers to (recursively if necessary).
  • treavorpasan2 hours ago
    [dead]