Rust: Haskell, but more imperative

Поделиться
HTML-код
  • Опубликовано: 29 дек 2024

Комментарии •

  • @TrustyBits
    @TrustyBits  Год назад +1

    Script and code: catalin-tech.com/haskell-rust/
    Errata:
    At 11:40 - the macro doesn't have the correct syntax, and the derived trait has to be Debug - Display is not derivable. The following print macro also needs a format string.

  • @MasterGxt
    @MasterGxt Год назад +3

    Loved, the video, concepts are explained fairly clearly, I would love to see more Haskell content.

    • @TrustyBits
      @TrustyBits  Год назад +1

      Noted - Glad it was useful, thank you so much!

  • @Nesdac-k1l
    @Nesdac-k1l Год назад +3

    underrated channel. 🙏🙏🙏

  • @docteurklein
    @docteurklein 3 месяца назад

    I raised my eyebrows at 5:40 when I heard that "unsafe" is the rust way to "know what parts of the code can cause side effects". I was expecting Result::and_then to popup when talking about IO and monads! Also Option::map/and_then ,which share far more similarities than "unsafe" IMHO. (I would have compare rust's unsafe to haskell's "unsafePerformIO").

    • @TrustyBits
      @TrustyBits  2 месяца назад +1

      Hi - I didn't say that, though I get how a viewer could make the connection. Thanks for pointing this out. I was just saying that it's a similar concept o creating a barrier around operations that are more dangerous. I wanted to mostly compare philosophical approaches to language design, rather than comparing Haskell's monad capability with the monad types we have available in Rust.

  • @Lucs-ku5cb
    @Lucs-ku5cb Год назад +1

    Please make a video about haskell templates and Rust macros

  • @0-Kirby-0
    @0-Kirby-0 Год назад

    Content? Fantastic, learned something and had things cleared up in my head.
    Prosody? Needs work. Looking forward to more!

    • @TrustyBits
      @TrustyBits  Год назад +1

      Glad you found it useful! Thanks for the feedback - I'm working on improving the way I talk while recording.

  • @culturedgator
    @culturedgator 11 месяцев назад

    Magnificent video

    • @TrustyBits
      @TrustyBits  11 месяцев назад +1

      You're too kind! Glad you enjoyed it!

  • @Jan-gl7mn
    @Jan-gl7mn 11 месяцев назад +7

    Rust just took some old ideas from Haskell and others and found a way to write code without GC, but the syntax of Rust is ugly and terrible, coming from Haskell, Rust code looks like C++ mix with some hipster language, hard to read. Haskells main issue is bad documentation, tooling(2 gb to install the compiler..) and no backward compatibility, but Haskell's syntax is amazing, although language extensions in Haskell are annoying.

    • @TrustyBits
      @TrustyBits  11 месяцев назад +3

      Would agree - I think it's hard to come up with a way of simplifying Rust syntax while keeping the advantages it currently offers. I'm personally ok with dealing with awkward syntax in some areas in order to have the benefits, but I get why people wouldn't want to deal with it.
      Haskell is indeed elegant and beautiful (though there are certain design choices that I very much dislike), but using it to build something that you actually want to use is not the best experience - though it's getting better. Compared to Rust's tooling, a lot of languages don't look that good, in any case.

    • @steveoc64
      @steveoc64 11 месяцев назад +3

      Well spotted. Just to make the story more interesting - Rust also took old ideas from Simula I, with automatic memory management via the ownership model ... which is effectively a form of automatic garbage collection.
      That was all back in the late 1960s, where CPUs were not as fast, and allocate / free overhead was quite a bit higher. So the general solution to that performance problem was to delay and batch up garbage collection, which then led to the "mark and sweep'" style of GCs that we are familiar with today.
      Ironically, mark and sweep GC is now considered harmful to performance :)
      End of the day ... manual memory management has always been the performance king, and its always going to be the performance king. It's just got a few obvious foot guns.
      I much prefer Zig's approach to addressing those obvious foot guns, rather than attempt to invent a whole new way of restricting programmers that just gets in the way. I don't find using Rust to be enjoyable in the slightest, and that has nothing to do with the syntax. I would rather peel potatoes for a living

    • @angeldude101
      @angeldude101 5 месяцев назад +1

      Honestly, making Rust's syntax more like Haskell is one of the very few things that would make me like the language even more than I already do.

  • @korigamik
    @korigamik Год назад +1

    Re-upload?

    • @TrustyBits
      @TrustyBits  Год назад +6

      Yes, there was a major mistake for the monad explanation in the first version, so I updated, rerendered and re-uploaded.

  • @deanroddey2881
    @deanroddey2881 2 месяца назад

    The whole unsafe side trip is highly misleading to anyone who doesn't know Rust, who might think you have to use unsafe just to do I/O.

  • @meyou118
    @meyou118 Год назад

    id say more like scala really...

  • @cassandrasinclair8722
    @cassandrasinclair8722 Год назад +5

    Perhaps Ocaml is more accurate :)

    • @TrustyBits
      @TrustyBits  Год назад +6

      You could say that OCaml is closer to Rust because it has some imperative features, while Haskell has none. (Though this makes it closer to any imperative language - which I find very uninteresting to discuss). Looking at the way the type system is designed, I find that Rust borrows more from Haskell than Ocaml (see traits / typeclasses vs modules in OCaml.