use moose talk in beijing workshop 2008

62
Outline Introduction Seeing is believing Mouse The End Mooooooooooooooooose [email protected] November 08, 2008 [email protected] Mooooooooooooooooose

Upload: guest28275

Post on 27-May-2015

966 views

Category:

Technology


1 download

DESCRIPTION

This is an introduction for Moose in beijing perl workshop 2008 on 08 Nov.

TRANSCRIPT

Page 1: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Mooooooooooooooooose

[email protected]

November 08, 2008

[email protected] Mooooooooooooooooose

Page 2: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

IntroductionWhat’s Moose?

Seeing is believingLet’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

MouseWhat’s Mouse?Why?Mouse is not enough in future?

The End

[email protected] Mooooooooooooooooose

Page 3: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

What Moose is not

I NOT a cow

I NOT contain any melamine

I NOT Perl 6

I NOT just a toy

I NOT a new object system

[email protected] Mooooooooooooooooose

Page 4: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

What Moose is not

I NOT a cow

I NOT contain any melamine

I NOT Perl 6

I NOT just a toy

I NOT a new object system

[email protected] Mooooooooooooooooose

Page 5: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

What Moose is not

I NOT a cow

I NOT contain any melamine

I NOT Perl 6

I NOT just a toy

I NOT a new object system

[email protected] Mooooooooooooooooose

Page 6: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

What Moose is not

I NOT a cow

I NOT contain any melamine

I NOT Perl 6

I NOT just a toy

I NOT a new object system

[email protected] Mooooooooooooooooose

Page 7: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

What Moose is not

I NOT a cow

I NOT contain any melamine

I NOT Perl 6

I NOT just a toy

I NOT a new object system

[email protected] Mooooooooooooooooose

Page 8: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

Google knows something about Moose

[email protected] Mooooooooooooooooose

Page 9: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

Interested in that animal?

Let’s talk about that animallater

[email protected] Mooooooooooooooooose

Page 10: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

What Moose here really is

I an extension of the existing objectsystem of Perl 5

I very much inspired by Perl 6I built on top of Class::MOP(

Welcome to Meta world! )I postmodern( just like Perl ;)I ready to use

[email protected] Mooooooooooooooooose

Page 11: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

What Moose here really is

I an extension of the existing objectsystem of Perl 5

I very much inspired by Perl 6

I built on top of Class::MOP(Welcome to Meta world! )

I postmodern( just like Perl ;)I ready to use

[email protected] Mooooooooooooooooose

Page 12: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

What Moose here really is

I an extension of the existing objectsystem of Perl 5

I very much inspired by Perl 6I built on top of Class::MOP(

Welcome to Meta world! )

I postmodern( just like Perl ;)I ready to use

[email protected] Mooooooooooooooooose

Page 13: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

What Moose here really is

I an extension of the existing objectsystem of Perl 5

I very much inspired by Perl 6I built on top of Class::MOP(

Welcome to Meta world! )I postmodern( just like Perl ;)

I ready to use

[email protected] Mooooooooooooooooose

Page 14: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

What Moose here really is

I an extension of the existing objectsystem of Perl 5

I very much inspired by Perl 6I built on top of Class::MOP(

Welcome to Meta world! )I postmodern( just like Perl ;)I ready to use

[email protected] Mooooooooooooooooose

Page 15: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Moose?

Official Definition

Moose is a postmodern object systemfor Perl 5 that takes the tedium outof writing object-oriented Perl. Itborrows all the best features fromPerl 6, CLOS (LISP), Smalltalk, Java,BETA, OCaml, Ruby and more, whilestill keeping true to its Perl 5 roots.

[email protected] Mooooooooooooooooose

Page 16: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

The Request

[email protected] Mooooooooooooooooose

Page 17: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

What we normally OOP

[email protected] Mooooooooooooooooose

Page 18: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

If we have Moose . . .

[email protected] Mooooooooooooooooose

Page 19: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

You may point out. . .

You skipped use strict; and usewarnings; on purpose to reduce

lines!

[email protected] Mooooooooooooooooose

Page 20: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

So, I’m telling you. . .

Well, I skipped those two linesbecause Moose does that for

me.

[email protected] Mooooooooooooooooose

Page 21: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

Thanks, Moose!

[email protected] Mooooooooooooooooose

Page 22: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

use ’has’ to install attributes

has $name|@$names => %options

[email protected] Mooooooooooooooooose

Page 23: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

%options

I is ( ’ro|rw’ )

I isa ( type constraints )

I does ( $role )

I required ( 1|0 )

I default

I predicate ( method name to check for initialization )

I clearer ( method name to uninitialize )

[email protected] Mooooooooooooooooose

Page 24: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

%options

I is ( ’ro|rw’ )

I isa ( type constraints )

I does ( $role )

I required ( 1|0 )

I default

I predicate ( method name to check for initialization )

I clearer ( method name to uninitialize )

[email protected] Mooooooooooooooooose

Page 25: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

%options

I is ( ’ro|rw’ )

I isa ( type constraints )

I does ( $role )

I required ( 1|0 )

I default

I predicate ( method name to check for initialization )

I clearer ( method name to uninitialize )

[email protected] Mooooooooooooooooose

Page 26: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

%options

I is ( ’ro|rw’ )

I isa ( type constraints )

I does ( $role )

I required ( 1|0 )

I default

I predicate ( method name to check for initialization )

I clearer ( method name to uninitialize )

[email protected] Mooooooooooooooooose

Page 27: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

%options

I is ( ’ro|rw’ )

I isa ( type constraints )

I does ( $role )

I required ( 1|0 )

I default

I predicate ( method name to check for initialization )

I clearer ( method name to uninitialize )

[email protected] Mooooooooooooooooose

Page 28: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

%options

I is ( ’ro|rw’ )

I isa ( type constraints )

I does ( $role )

I required ( 1|0 )

I default

I predicate ( method name to check for initialization )

I clearer ( method name to uninitialize )

[email protected] Mooooooooooooooooose

Page 29: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

%options

I is ( ’ro|rw’ )

I isa ( type constraints )

I does ( $role )

I required ( 1|0 )

I default

I predicate ( method name to check for initialization )

I clearer ( method name to uninitialize )

[email protected] Mooooooooooooooooose

Page 30: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

is

I ro

I rw

[email protected] Mooooooooooooooooose

Page 31: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

is

I ro

I rw

[email protected] Mooooooooooooooooose

Page 32: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

is

[email protected] Mooooooooooooooooose

Page 33: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

isa - type

[email protected] Mooooooooooooooooose

Page 34: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

isa - type

[email protected] Mooooooooooooooooose

Page 35: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

does - Role

Let’s talk about Roles later

[email protected] Mooooooooooooooooose

Page 36: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

required

[email protected] Mooooooooooooooooose

Page 37: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

default

[email protected] Mooooooooooooooooose

Page 38: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

predicate and clearer

[email protected] Mooooooooooooooooose

Page 39: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

Code Reuse

From S12: Classes are primarily incharge of object management, andonly secondarily in charge of softwarereuse. In Perl 6, roles take over thejob of managing software reuse.

[email protected] Mooooooooooooooooose

Page 40: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

What’s a Role?

From S12: Depending on how youcare to look at it, a role is like apartial class, or an interface withdefault implementation, or a set ofgeneric methods and their associateddata, or a class closed at compiletime.

[email protected] Mooooooooooooooooose

Page 41: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

use ’with’ to apply Roles

[email protected] Mooooooooooooooooose

Page 42: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

I before

I after

I around

[email protected] Mooooooooooooooooose

Page 43: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

I before

I after

I around

[email protected] Mooooooooooooooooose

Page 44: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

I before

I after

I around

[email protected] Mooooooooooooooooose

Page 45: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

[email protected] Mooooooooooooooooose

Page 46: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

[email protected] Mooooooooooooooooose

Page 47: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

I override/super

I augment/inner

I . . .

[email protected] Mooooooooooooooooose

Page 48: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

I override/super

I augment/inner

I . . .

[email protected] Mooooooooooooooooose

Page 49: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

I override/super

I augment/inner

I . . .

[email protected] Mooooooooooooooooose

Page 50: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Let’s Compare!Attributes - hasRoles - withMethod ModifiersOther Methods

an easy way to speed up Moose

[email protected] Mooooooooooooooooose

Page 51: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Mouse?Why?Mouse is not enough in future?

Mouse is a lightweighted Moose. Itprovides a subset of Moose’sfunctionality.

[email protected] Mooooooooooooooooose

Page 52: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Mouse?Why?Mouse is not enough in future?

the compile time penalty

Though significant progress has beenmade over the years, the compiletime penalty is a non-starter for someapplications.

[email protected] Mooooooooooooooooose

Page 53: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

What’s Mouse?Why?Mouse is not enough in future?

It’s easy to do

s/Mouse/Moose/g;

[email protected] Mooooooooooooooooose

Page 54: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Less is better sometimes

I less code

I less tests

I less bugs

[email protected] Mooooooooooooooooose

Page 55: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Less is better sometimes

I less code

I less tests

I less bugs

[email protected] Mooooooooooooooooose

Page 56: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Less is better sometimes

I less code

I less tests

I less bugs

[email protected] Mooooooooooooooooose

Page 57: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

So. . .

Let’s Moose from now on

[email protected] Mooooooooooooooooose

Page 58: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Until. . .

Perl 6 is finished

[email protected] Mooooooooooooooooose

Page 59: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

More Info

I

http://www.iinteractive.com/moose

I #moose on irc.perl.org

I subscribe to [email protected]

[email protected] Mooooooooooooooooose

Page 60: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

More Info

I

http://www.iinteractive.com/moose

I #moose on irc.perl.org

I subscribe to [email protected]

[email protected] Mooooooooooooooooose

Page 61: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

More Info

I

http://www.iinteractive.com/moose

I #moose on irc.perl.org

I subscribe to [email protected]

[email protected] Mooooooooooooooooose

Page 62: use Moose talk in beijing workshop 2008

OutlineIntroduction

Seeing is believingMouse

The End

Thanks!

Any Questions?

[email protected] Mooooooooooooooooose