5
jestdotty
35d

if anyhow is so good and important why isn't it part of the std

I just can't with this

I don't wanna download a bunch of unnecessary libraries just because people were lazy

Comments
  • 1
    I'm on the opposite camp, in my opinion std should focus on interop standards and everything it actually does should be possible to implement (and preferably provided) in a 3rd party library.
  • 2
    Anyhow is very cool and I also only discovered it recently, but beware that it suffers from the same exact issues c++ exceptions do;

    - type erasure is slow
    - throwing allocates
    - allocation may panic
    (in c++ allocation may throw which is even worse)
    - you lose the explicit list of error conditions (but you probably want that if you use anyhow)
  • 2
    I didn't originally understand why the async runtime is injectable, but when you compile to Webassembly it uses the JavaScript event loop which is seamless thanks to this design choice. This would be very difficult otherwise. Given the timeline of async and WASM support, I actually think that being able to use the JS event loop was a primary use case.
  • 1
    @jestdotty I thought some more about this and I wholly agree, it should be in STL. Either way, every language eventually cultivates an ecosystem of quasi-standard libraries and frameworks that solve very common problems in a simple way that kinda conflicts with the language's principles but generates enough value to be used nonetheless.

    At least in Rust you can install these with a single line because it has a good package manager.

    Type erasure is slow at runtime, becuase in order to create an owned trait object you need to box the original data and put it on the heap, and in order to access any Context you need to read from a hashmap. It's actually faster to compile than generics because the compiler has to keep track of fewer different monomorphizations, and in fact a common way to cut down on compile times in both C++ and Rust is to erase non-performance-critical generics (with inheritance and trait objects respectively).
  • 1
    @lorentz i remember the C++ quasi Standard lib was boost.

    Now i'm actually not sure if i use tokio in my current project. Need to check where the par_iter's are from

    Edit: nvm, turns out it was rayon.
  • 1
    @thebiochemic That'll be Rayon, which only offers par_iter.

    C++ has Boost because it didn't have a package manager for a very long time and then suddenly got 3. If setting up a project to work correctly is O(2^depc) then you do your best to keep your dependency count below 5 by choosing packages that do as many things as possible. Boost, Abseil, Qt, Gtk.
  • 0
    @lorentz yeah i remember whenever i worked with c++ i was working in C++11 and only GTK, because i never wanted to add this monster of Qt.

    And yeah it was always wrestling with the few libs until shit compiled and linked correctly, i remember that dread..

    And to be fair C++11 had some nice new Features like better fs access and stuff
Add Comment