Coder Social home page Coder Social logo

Benchmark switching to anyhow about gitoxide HOT 7 CLOSED

byron avatar byron commented on May 25, 2024
Benchmark switching to anyhow

from gitoxide.

Comments (7)

joshtriplett avatar joshtriplett commented on May 25, 2024 1

I absolutely agree that library code should not use anyhow. (You might consider thiserror as a more convenient replacement for quick-error with some additional features, but that's more a matter of taste.)

I was purely talking about contexts where you currently use boxed errors.

from gitoxide.

Byron avatar Byron commented on May 25, 2024

For libraries, I would prefer keeping quick-error, but possibly box big enum variants to keep the size small, allowing users of these functions to actually see what went wrong programmatically.

There some spots in the code that use Box<dyn Error + Send + Sync>, but it's portions of code that don't have anyhow available, and I would like to avoid that dependency unless truly, truly required.

gitoxide-core and higher use anyhow as they are considered application level.

Unless there are performance issues, I would avoid switching just because I am so happy with the error handling story in this project so far. And I have tried a lot :D - and feel like I finally arrived.

from gitoxide.

Byron avatar Byron commented on May 25, 2024

thiserror I evaluated, and then I found quick-error in an old project of mine and realized that these 200ish lines of macro is all I need. thiserror pulls in a bunch of dependencies and increases compile times to the point where I can't justify its benefits.

Some of my decisions are driven by my constraints, after all I am working on a tiny machine (MB Air 2020, 8GB of RAM, 4 cores) :D. It's a good thing, and I will hold on to it for that very reason and resist the urge to go all 'ARM' ;).

from gitoxide.

joshtriplett avatar joshtriplett commented on May 25, 2024

@Byron Did you evaluate that before or after the change that made build-time-only dependencies use opt-level 0?

from gitoxide.

Byron avatar Byron commented on May 25, 2024

from gitoxide.

Byron avatar Byron commented on May 25, 2024

I have just added thiserror for use in one particular error type, resolving some limitations of quick-error in that particular instance. It's very nice, too, here my highlights (and for when I will use it):

  • support for generic errors (and I will revise some error types in git-odb which could benefit from that)
  • support for 'transparent' errors - often I find myself adding a quite generic 'quick-error' display message because the detailed message is contained in the source(). There I doubt the generic message adds much value most of the time.

The drawbacks of thiserror clearly is the dependency chain, which one pays once, and probably most projects do pull syn and procmacro2 in one way or another.
So in short, I think it's worth using when needed, for these features alone.

Right now it seems I will keep using quick-error, but switch to thiserror for particular Errors that require its additional feature set.

from gitoxide.

joshtriplett avatar joshtriplett commented on May 25, 2024

Closing this for now, since performance-critical cases already do this. There might be value in switching, but not for performance.

from gitoxide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.