Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace TB2::Mouse #70

Open
schwernbot opened this issue Mar 16, 2014 · 2 comments
Open

Replace TB2::Mouse #70

schwernbot opened this issue Mar 16, 2014 · 2 comments

Comments

@schwernbot
Copy link

From: @schwern
Date: Wednesday Apr 24, 2013 at 19:43 GMT
Orig: Test-More/test-more#376

TB2::Mouse is a copy of Mouse::Tiny with all the package names s{Mouse}{TB2::Mouse} to avoid interfering with Mouse. It was chosen because...

  • It has no dependencies
  • It's easy to embed
  • It has roles
  • It has rich attributes
  • It's Moose syntax compatible
  • It was available at the time

TB2::Mouse allowed TB2 to be much better designed with far more aggressive use of objects and roles than if it had been done in pure Perl.

There are problems...

  1. Test::More is 5-6x slower to load than 0.98.
  2. TB2 roles can only be consumed by TB2::Mouse users exposing our implementation
  3. The core isn't going to be happy about having a copy of Mouse

1 and 2 are major problems. 3 I'm less concerned about, if 1 and 2 can be solved then we can mitigate 3.

Because each .t file is loading Test::More, the extra load time noticeably impacts test performance.

Because any consumers of our roles must write use TB2::Mouse; with "..."; this exposes what OO system we're using and we will never be able to change it. This is an unacceptable exposure of internals. All existing role implementations suffer from this.

Even though it's unacceptable for final release, TB2::Mouse has been left in because it works for now and there are more pressing problems to fix. We're approaching release, so it's time to work on this.

A replacement MUST

  • Not expose what OO system we're using.
  • Significantly improve load time performance
  • Not degrade runtime performance
  • Support attributes
  • Support roles
  • Support basic attribute introspection (ie. list them)
  • Be bundle-able (pure Perl)
  • Able to change namespace to avoid interfering with installed version
  • Work back to 5.8.4

A replacement SHOULD

  • Support types
  • Work back to 5.8.1
  • Support Moose syntax (that we use)

Nice to haves...

  • Type coercion

The requirements are negotiable.

@schwernbot schwernbot added this to the Remove Mouse dependency milestone Mar 16, 2014
@schwernbot
Copy link
Author

From: @dakkar
Date: Wednesday Apr 24, 2013 at 20:25 GMT
Orig: Test-More/test-more#376 (comment)

I think the "standard" answer nowadays is Moo. It was certainly designed to be compile-time perfomant, "bundle-able" (mostly via fatpacker), and Moose-compatible.

To avoid exposing the internal OO implementation, there's relatively little you can do: how do you add an attribute to a class consuming a TB2 role, without using the same OO system? (IIRC, Moo interoperates with Moose also in that it allows Moose classes/roles to consume Moo roles).

I don't know about changing the namespace, but we may ask.

@schwernbot
Copy link
Author

From: @schwern
Date: Wednesday Apr 24, 2013 at 21:24 GMT
Orig: Test-More/test-more#376 (comment)

I've written down the criterion because a lot of people say "you can use X!" Rather than argue for each X, now people can step up and show that X will fix our needs.

Which is to say, if someone wants to take on converting the whole thing to Moo and demonstrate it passes the criterion (or negotiate criterion as unnecessary), let's see it!

mst has been working on a Moo compiler with Test::Builder as a target and has my criterion, but I don't know where that project lives.

Exposing the OO implementation is not an option. I don't want to be stuck in 2023 with an OO system choice I made in 2013. I have ideas about how to fix the role problem by writing an adapter which knows how to talk between the various role implementations. In addition, a role meta protocol could be established so all the role implementations have similar methods for composition. The question of attributes is tricky but IMO surmountable. This is not a requirement I want to have for Test::Builder1.5 but it is unfortunately necessary to protect its future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant