eviltoast
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Arbitrary@reddthat.com to Rust@programming.dev · 3 years ago

A Failed Experiment With Static Dispatch

jmmv.dev

external-link
message-square
0
link
fedilink
1
external-link

A Failed Experiment With Static Dispatch

jmmv.dev

Arbitrary@reddthat.com to Rust@programming.dev · 3 years ago
message-square
0
link
fedilink
A failed experiment with Rust static dispatch - Julio Merino (jmmv.dev)
jmmv.dev
external-link
Initial versions of the EndBASIC Service, and therefore initial versions of EndTRACKER, used dynamic dispatch to support abstract definitions of system services such as the database they talk to and the clock they use. This looked like a bunch of Arc objects passed around and was done to support extremely fast unit testing. When I generalized the core logic of these services into the III-IV framework, I decided to experiment with a switch to static dispatch. The rationale was that using static dispatch better aligns with the design of well-regarded crates in the Rust ecosystem, and also because I wanted to avoid unnecessary runtime costs in the foundational pieces of my web services. Let me tell you that this decision was a huge mistake and that the experiment has utterly failed. Using static dispatch has been a constant source of frustration due to the difficulty in passing types around and reasoning about trait bounds. The situation had gotten so bad that I dreaded adding new functionality to my services whenever a change to a statically-typed struct was needed, because that meant adding yet another type parameter and plumbing it through tens of source files. In lieu of the difficulties, which eventually turned into blockers to implementing new features, I made the choice of going back to dynamic dispatch. The goal was to gain ergonomics at the expense of a supposedly-negligible runtime cost. Let me tell you about the problems I faced, the refactoring journey, and some measurements I gathered after the rewrite.
alert-triangle
You must log in or # to comment.

Rust@programming.dev

rust@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !rust@programming.dev

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits
  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 29 users / day
  • 129 users / week
  • 394 users / month
  • 1.32K users / 6 months
  • 8 local subscribers
  • 8.1K subscribers
  • 1.24K Posts
  • 5.42K Comments
  • Modlog
  • mods:
  • snowe@programming.dev
  • Ategon@programming.dev
  • EdTheLegendary@programming.dev
  • torcherist@programming.dev
  • BE: 0.19.17
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org