1. Outline
Introduction
Seeing is believing
Mouse
The End
Mooooooooooooooooose
sunnavy@bestpractical.com
November 08, 2008
sunnavy@bestpractical.com Mooooooooooooooooose
2. Outline
Introduction
Seeing is believing
Mouse
The End
Introduction
What’s Moose?
Seeing is believing
Let’s Compare!
Attributes - has
Roles - with
Method Modifiers
Other Methods
Mouse
What’s Mouse?
Why?
Mouse is not enough in future?
The End
sunnavy@bestpractical.com Mooooooooooooooooose
3. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
What Moose is not
NOT a cow
sunnavy@bestpractical.com Mooooooooooooooooose
4. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
What Moose is not
NOT a cow
NOT contain any melamine
sunnavy@bestpractical.com Mooooooooooooooooose
5. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
What Moose is not
NOT a cow
NOT contain any melamine
NOT Perl 6
sunnavy@bestpractical.com Mooooooooooooooooose
6. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
What Moose is not
NOT a cow
NOT contain any melamine
NOT Perl 6
NOT just a toy
sunnavy@bestpractical.com Mooooooooooooooooose
7. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
What Moose is not
NOT a cow
NOT contain any melamine
NOT Perl 6
NOT just a toy
NOT a new object system
sunnavy@bestpractical.com Mooooooooooooooooose
8. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
Google knows something about Moose
sunnavy@bestpractical.com Mooooooooooooooooose
9. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
Interested in that animal?
Let’s talk about that animal
later
sunnavy@bestpractical.com Mooooooooooooooooose
10. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
What Moose here really is
an extension of the existing object
system of Perl 5
sunnavy@bestpractical.com Mooooooooooooooooose
11. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
What Moose here really is
an extension of the existing object
system of Perl 5
very much inspired by Perl 6
sunnavy@bestpractical.com Mooooooooooooooooose
12. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
What Moose here really is
an extension of the existing object
system of Perl 5
very much inspired by Perl 6
built on top of Class::MOP(
Welcome to Meta world! )
sunnavy@bestpractical.com Mooooooooooooooooose
13. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
What Moose here really is
an extension of the existing object
system of Perl 5
very much inspired by Perl 6
built on top of Class::MOP(
Welcome to Meta world! )
postmodern( just like Perl ;)
sunnavy@bestpractical.com Mooooooooooooooooose
14. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
What Moose here really is
an extension of the existing object
system of Perl 5
very much inspired by Perl 6
built on top of Class::MOP(
Welcome to Meta world! )
postmodern( just like Perl ;)
ready to use
sunnavy@bestpractical.com Mooooooooooooooooose
15. Outline
Introduction
Seeing is believing What’s Moose?
Mouse
The End
Official Definition
Moose is a postmodern object system
for Perl 5 that takes the tedium out
of writing object-oriented Perl. It
borrows all the best features from
Perl 6, CLOS (LISP), Smalltalk, Java,
BETA, OCaml, Ruby and more, while
still keeping true to its Perl 5 roots.
sunnavy@bestpractical.com Mooooooooooooooooose
16. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
The Request
sunnavy@bestpractical.com Mooooooooooooooooose
17. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
What we normally OOP
sunnavy@bestpractical.com Mooooooooooooooooose
18. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
If we have Moose . . .
sunnavy@bestpractical.com Mooooooooooooooooose
19. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
You may point out. . .
You skipped use strict; and use
warnings; on purpose to reduce
lines!
sunnavy@bestpractical.com Mooooooooooooooooose
20. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
So, I’m telling you. . .
Well, I skipped those two lines
because Moose does that for
me.
sunnavy@bestpractical.com Mooooooooooooooooose
21. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
Thanks, Moose!
sunnavy@bestpractical.com Mooooooooooooooooose
22. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
use ’has’ to install attributes
has $name|@$names => %options
sunnavy@bestpractical.com Mooooooooooooooooose
23. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
%options
is ( ’ro|rw’ )
sunnavy@bestpractical.com Mooooooooooooooooose
24. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
%options
is ( ’ro|rw’ )
isa ( type constraints )
sunnavy@bestpractical.com Mooooooooooooooooose
25. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
%options
is ( ’ro|rw’ )
isa ( type constraints )
does ( $role )
sunnavy@bestpractical.com Mooooooooooooooooose
26. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
%options
is ( ’ro|rw’ )
isa ( type constraints )
does ( $role )
required ( 1|0 )
sunnavy@bestpractical.com Mooooooooooooooooose
27. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
%options
is ( ’ro|rw’ )
isa ( type constraints )
does ( $role )
required ( 1|0 )
default
sunnavy@bestpractical.com Mooooooooooooooooose
28. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
%options
is ( ’ro|rw’ )
isa ( type constraints )
does ( $role )
required ( 1|0 )
default
predicate ( method name to check for initialization )
sunnavy@bestpractical.com Mooooooooooooooooose
29. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
%options
is ( ’ro|rw’ )
isa ( type constraints )
does ( $role )
required ( 1|0 )
default
predicate ( method name to check for initialization )
clearer ( method name to uninitialize )
sunnavy@bestpractical.com Mooooooooooooooooose
30. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
is
ro
sunnavy@bestpractical.com Mooooooooooooooooose
31. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
is
ro
rw
sunnavy@bestpractical.com Mooooooooooooooooose
32. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
is
sunnavy@bestpractical.com Mooooooooooooooooose
33. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
isa - type
sunnavy@bestpractical.com Mooooooooooooooooose
34. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
isa - type
sunnavy@bestpractical.com Mooooooooooooooooose
35. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
does - Role
Let’s talk about Roles later
sunnavy@bestpractical.com Mooooooooooooooooose
36. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
required
sunnavy@bestpractical.com Mooooooooooooooooose
37. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
default
sunnavy@bestpractical.com Mooooooooooooooooose
38. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
predicate and clearer
sunnavy@bestpractical.com Mooooooooooooooooose
39. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
Code Reuse
From S12: Classes are primarily in
charge of object management, and
only secondarily in charge of software
reuse. In Perl 6, roles take over the
job of managing software reuse.
sunnavy@bestpractical.com Mooooooooooooooooose
40. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
What’s a Role?
From S12: Depending on how you
care to look at it, a role is like a
partial class, or an interface with
default implementation, or a set of
generic methods and their associated
data, or a class closed at compile
time.
sunnavy@bestpractical.com Mooooooooooooooooose
41. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
use ’with’ to apply Roles
sunnavy@bestpractical.com Mooooooooooooooooose
42. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
before
sunnavy@bestpractical.com Mooooooooooooooooose
43. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
before
after
sunnavy@bestpractical.com Mooooooooooooooooose
44. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
before
after
around
sunnavy@bestpractical.com Mooooooooooooooooose
45. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
sunnavy@bestpractical.com Mooooooooooooooooose
46. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
sunnavy@bestpractical.com Mooooooooooooooooose
47. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
override/super
sunnavy@bestpractical.com Mooooooooooooooooose
48. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
override/super
augment/inner
sunnavy@bestpractical.com Mooooooooooooooooose
49. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
override/super
augment/inner
...
sunnavy@bestpractical.com Mooooooooooooooooose
50. Outline Let’s Compare!
Introduction Attributes - has
Seeing is believing Roles - with
Mouse Method Modifiers
The End Other Methods
an easy way to speed up Moose
sunnavy@bestpractical.com Mooooooooooooooooose
51. Outline
Introduction What’s Mouse?
Seeing is believing Why?
Mouse Mouse is not enough in future?
The End
Mouse is a lightweighted Moose. It
provides a subset of Moose’s
functionality.
sunnavy@bestpractical.com Mooooooooooooooooose
52. Outline
Introduction What’s Mouse?
Seeing is believing Why?
Mouse Mouse is not enough in future?
The End
the compile time penalty
Though significant progress has been
made over the years, the compile
time penalty is a non-starter for some
applications.
sunnavy@bestpractical.com Mooooooooooooooooose
53. Outline
Introduction What’s Mouse?
Seeing is believing Why?
Mouse Mouse is not enough in future?
The End
It’s easy to do
s/Mouse/Moose/g;
sunnavy@bestpractical.com Mooooooooooooooooose
54. Outline
Introduction
Seeing is believing
Mouse
The End
Less is better sometimes
less code
sunnavy@bestpractical.com Mooooooooooooooooose
55. Outline
Introduction
Seeing is believing
Mouse
The End
Less is better sometimes
less code
less tests
sunnavy@bestpractical.com Mooooooooooooooooose
56. Outline
Introduction
Seeing is believing
Mouse
The End
Less is better sometimes
less code
less tests
less bugs
sunnavy@bestpractical.com Mooooooooooooooooose
57. Outline
Introduction
Seeing is believing
Mouse
The End
So. . .
Let’s Moose from now on
sunnavy@bestpractical.com Mooooooooooooooooose
58. Outline
Introduction
Seeing is believing
Mouse
The End
Until. . .
Perl 6 is finished
sunnavy@bestpractical.com Mooooooooooooooooose
59. Outline
Introduction
Seeing is believing
Mouse
The End
More Info
http://www.iinteractive.com/moose
sunnavy@bestpractical.com Mooooooooooooooooose
60. Outline
Introduction
Seeing is believing
Mouse
The End
More Info
http://www.iinteractive.com/moose
#moose on irc.perl.org
sunnavy@bestpractical.com Mooooooooooooooooose
61. Outline
Introduction
Seeing is believing
Mouse
The End
More Info
http://www.iinteractive.com/moose
#moose on irc.perl.org
subscribe to moose@perl.org
sunnavy@bestpractical.com Mooooooooooooooooose
62. Outline
Introduction
Seeing is believing
Mouse
The End
Thanks!
Any Questions?
sunnavy@bestpractical.com Mooooooooooooooooose