A .NET port of Scientist

github csharp dotnet scientist 11 comments suggest edit

Over on the GitHub Engineering blog my co-worker Jesse Toth published a fascinating post about the Ruby library named Scientist we use at GitHub to help us run experiments comparing new code against the existing production code.

Photo by tortmaster on flickr - CC BY 2.0

It’s an enjoyable read with a really great analogy comparing this approach to building a new bridge. The analogy feels very relevant to those of us here in the Seattle area as we’re in the midst of a major bridge construction project across Lake Washington as they lay a new bridge alongside the existing 520 bridge.

Naturally, a lot of people asked if we were working on a C# version. In truth, I had been toying with it for a while. I had hoped to have something ready to ship on the day that Scientist 1.0 shipped, but life has a way of catching up to you and tossing your plans in the gutter. The release of Scientist 1.0 lit that proverbial fire under my ass to get something out that people can play with and help improve.

Consider this a working sketch of the API. It’s very rough, but it works! I don’t have a CI server set up yet etc. etc. I’ll get around to it.

The plan is to start with this repository and once we have a rock solid battle tested implementation, we can move it to the GitHub Organization on GitHub.com. If you’d like to participate, jump right in. There’s plenty to do!

I tried to stay true to the Ruby implementation with one small difference. Instead of registering a custom experimentation type, you can register a custom measurement publisher. We don’t have the ability to override the new operator like those Rubyists and I liked keeping publishing separate. But I’m not stuck to this idea.

Here’s a sample usage:

public bool MayPush(IUser user)
{
  return Scientist.Science<bool>("may-push", experiment =>
  {
      experiment.Use(() => IsCollaborator(user));
      experiment.Try(() => HasAccess(user));
  });
}

As expected, you can install it via NuGet Install-Package Scientist -Pre

Enjoy!

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.

Comments

avatar

11 responses

  1. Avatar for Jakub Jedryszek
    Jakub Jedryszek February 4th, 2016

    Love the fact that Marie Curie is the face of this project :)

  2. Avatar for Frank Black
    Frank Black February 4th, 2016

    So one will legitimately be able to say: "Let's Science the shit outta this"

  3. Avatar for haacked
    haacked February 4th, 2016
  4. Avatar for Mahmoud Ali
    Mahmoud Ali February 7th, 2016

    Having a port to .NET was my first thought after reading the original article. Thanks for starting this :)

  5. Avatar for dotnetchris
    dotnetchris February 9th, 2016

    Why is it Science<int> was that a typo?

    So when you use this, what do you expect to get back the original answer, the new answer, or some type of response object that contains both?

  6. Avatar for haacked
    haacked February 10th, 2016

    That was a typo! I fixed it. The method always returns the original answer. But it publishes an object that contains both answers and timing information. However, I don't have any publishers written...yet. I'm looking for contributions to do that.

  7. Avatar for Bertrand Le Roy
    Bertrand Le Roy February 16th, 2016

    Here's another port, which may be a little ahead, as far as I can tell: https://github.com/davezych...

    Maybe there's an opportunity to join forces?

  8. Avatar for Dave Zych
    Dave Zych February 19th, 2016

    I'm always open to that!

  9. Avatar for haacked
    haacked February 19th, 2016

    Sweet! The plan is to work on haacked/scientist.net under my GitHub account. But eventually, once it's been battle tested, I'll move it to github/scientist.net and it'll be the official GitHub release of the library.

    Would love to have you jump in and take a look and merge efforts!

  10. Avatar for John Staniforth
    John Staniforth June 13th, 2016

    Hi, this sounds like an ideal tool for some refactoring work which is coming up. (Hope this hasn't been asked already) When do you envisage the move from beta might happen as this makes it a difficult sell in some work places? Would love to help out but not sure what would be the best place to start in terms of work that's required by the project?

  11. Avatar for haacked
    haacked June 13th, 2016

    A couple of people are already using it in production. We still have a few more features before we call it a 1.0. https://github.com/Haacked/...