5 comments

  • joshka3 hours ago
    The weird-looking Rust isn’t really Rust being weird, it’s the type telling the truth.<p><pre><code> Result&lt;Option&lt;Result&lt;Message, WsError&gt;&gt;, Elapsed&gt; </code></pre> That’s three independent “not the happy path” channels: timeout, stream closed, and websocket error.<p>The nicer version is not a cleverer match. It’s choosing a domain error shape and converting into it one layer at a time:<p><pre><code> let timed = tokio::time::timeout(duration, receiver.next()).await; let next = timed.map_err(|_| ReceiveError::Timeout)?; let item = next.ok_or(ReceiveError::Closed)?; let msg = item.map_err(ReceiveError::WebSocket)?; </code></pre> The ugly line is what happens when you have not decided where to normalize the shape yet.
    • loeg3 hours ago
      <p><pre><code> Result&lt;(), ()&gt; </code></pre> Is pretty weird, though, no? Why would you want a unit value &#x2F; error type?
      • MrJohz2 hours ago
        It&#x27;s basically doing the same thing that, say, `return true` might do to indicate a function succeeded, but with more explicit types. However, because it uses `Result`, it can be used with the `try`&#x2F;question mark operator which can be convenient in some situations.<p>That said, a couple of the examples here feel a bit strange - they&#x27;re clever things you can do, but they&#x27;re not necessarily things you often have to do, particularly for a relatively simple task like this. I think the problem with the author&#x27;s approach is that they can&#x27;t distinguish between &quot;weird because Rust is weird&quot; and &quot;weird because the LLM generated bad code&quot;, because they (understandably) don&#x27;t have enough experience in what good Rust code looks like.
      • nasso_dev58 minutes ago
        it is indeed pretty weird. clippy has a lint against this iirc. it&#x27;s recommended to just create a custom error type, even if its just an empty struct or a single-variant enum<p>this lets you implement `std::error::Error`, which you really should to make it less painful when you want to erase the type (`std::error::Error` is `dyn`-compatible)
      • 2ndorderthought1 hour ago
        It&#x27;s not like people regularly decide this is a good return type. Just because Claude isn&#x27;t good at designing code or what have you doesn&#x27;t mean rust is bad&#x2F;weird.<p>Sure this is something someone can do but it&#x27;s suggesting the caller doesn&#x27;t care about why it failed and doesn&#x27;t need anything from it&#x27;s success. It&#x27;s a choice but it&#x27;s not a typical one. Maybe the fact that it looks weird and there is no comment is a clue that this isn&#x27;t high quality code.<p>People really should be more skeptical of LLM coding. Claude is not as amazing as marketing makes it sound. It is amazing in that it can write code and follow specs sometimes, but a lot of quality gets lost along the way without close supervision by someone who knows better
      • tux32 hours ago
        Sometimes you just want a fancy boolean. The advantage is that Result has all the Result APIs and you can compose it with other Results, but otherwise this is just a success bool.
      • stingraycharles2 hours ago
        It’s the equivalent of Haskell’s Either, with Option being the equivalent of Maybe. They’re fairly well-defined idioms.
        • loeg2 hours ago
          I know what Result&lt;&gt; is.
    • simianwords49 minutes ago
      Off topic but using “shape” like this is LLM coded
      • joshka26 minutes ago
        Probably on topic here - I talk like an LLM sometimes, and parse my points through them sometimes. I’d reasonably use that terminology and think nothing of it as it’s precise and correct. That said, this was partially LLM and my thinking here.
        • simianwords1 minute ago
          It’s good, I found your comment relevant and insightful
      • bobnamob46 minutes ago
        I guess I&#x27;m an LLM then. I&#x27;ve been referring to the structure of types as &quot;shape&quot; for more than a decade and so have plenty of others
    • tancop3 hours ago
      [dead]
  • saagarjha2 hours ago
    I feel like having an LLM write code in a language you aren&#x27;t familiar with and then inspecting the results is kind of like hiring someone to speak Spanish for you and then being confused at the weird words they are using. Like, what would make you want to do this?
    • hnlmorg7 minutes ago
      Not the author but this seems a good approach to me because you learn more about a language from implementing a project in it. This is especially true when you already have experience in a language from the same paradigm (like Go and Rust are).<p>So getting an LLM to write an example project then dissecting the code and interrogating those choices, seems like a very good way to learn the idioms of another language.
      • 2ndorderthought1 minute ago
        Go and rust share very few similarities when you consider the syntax.
    • commandersaki4 minutes ago
      Have you tried? Give it a shot and see for yourself.
    • victorbjorklund1 hour ago
      If you already speak French or another Romance language it isn’t a bad idea to just have a conversation in Spanish directly and then ask for clarifications anytime you don’t understand.
      • 2ndorderthought1 hour ago
        Which would be all the time? At which point you might be better served by learning from a source that has any guarantees of being correct and doesn&#x27;t hallucinate. Like text books that have had several editions and are free on the Internet.
        • hnlmorg3 minutes ago
          I would be <i>very</i> surprised if you couldn’t figure out what was happening in one C-derivative language when you’re already competent in another C-derivative language.<p>This isn’t like learning JavaScript and then expecting to be an expert in Prolog.
    • cpursley1 hour ago
      I’ve learned a ton of new things this way, even in a stack that I know really well. Ditto on all sorts of new little command line tricks that I was unaware of before.
      • MrJohz51 minutes ago
        I mean, it&#x27;s not that surprising that you&#x27;ll learn better in a stack you already know well - you know enough there to know what you don&#x27;t know and need to learn. But if you don&#x27;t know anything about a language, it will be very difficult for you to sort fact from fiction.
  • RobotToaster3 hours ago
    Was anyone else expecting OpenClaw over gopher protocol?
    • SyneRyder1 hour ago
      Yep, I did. While I don&#x27;t use OpenClaw, I built a small MCP tool for my AI to use Gopher in a minimal harness, and it&#x27;s been useful. Gopher is almost an ideal protocol for AI, none of the token verbosity of HTML. But I admit in my case, it&#x27;s mostly being used to access weather data on Floodgap&#x27;s Groundhog, because the format published on Gopher is much easier to parse &amp; access than the paywalled government APIs in Australia. Claude occasionally uses Veronica to do a search instead of a web search as well.
    • coqadoodle2 hours ago
      I was looking forward to retro deep-dive back into the 90s. I just couldn&#x27;t figure out where the crab fit in.
  • wiseowise1 hour ago
    Still better than deciphering C++ soup of characters.
    • cenamus55 minutes ago
      std::expected and the utility functions for it (and_then(), or_else()) are pretty much the same, though? Or am I completely misunderstanding something?
      • irishcoffee25 minutes ago
        No, you’re not, the person you replied to is failing to look at their own criticism objectively.
  • nothinkjustai2 hours ago
    Um? Person vibe codes Rust. Output is stupid. The conclusion is either<p>a) Vibe coding produces bad code<p>b) Rust is weird<p>Somehow we’re supposed to accept b as the answer? Give me a break….
    • 2ndorderthought1 hour ago
      People really are forgetting how to think. While reading this blog post I almost immediately flipped into teaching confused freshmen taking the course that wasn&#x27;t their major mode.