Rust: Haskell, but more imperative

Поділитися
Вставка
  • Опубліковано 3 січ 2025

КОМЕНТАРІ • 23

  • @CataBits
    @CataBits  Рік тому +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.

    • @CataBits
      @CataBits  Рік тому +1

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

  • @Lucs-ku5cb
    @Lucs-ku5cb Рік тому +1

    Please make a video about haskell templates and Rust macros

  • @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").

    • @CataBits
      @CataBits  3 місяці тому +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.

  • @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!

    • @CataBits
      @CataBits  Рік тому +1

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

  • @Jan-gl7mn
    @Jan-gl7mn Рік тому +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.

    • @CataBits
      @CataBits  Рік тому +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?

    • @CataBits
      @CataBits  Рік тому +6

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

  • @culturedgator
    @culturedgator Рік тому

    Magnificent video

    • @CataBits
      @CataBits  Рік тому +1

      You're too kind! Glad you enjoyed it!

  • @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 :)

    • @CataBits
      @CataBits  Рік тому +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.