24
Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting

Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Perl 6 DesignPhilosophy

Allison RandalThe Perl Foundation &

Onyx Neon Consulting

Page 2: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Design Philosophy

• Every language is unique

• Design philosophy drives the shape ofthe language

• Better understand Perl 6

• Better understand all languages

• "Code smells"

• "Language smells"

Page 3: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Simplicity

• Simple is better

• Simple is easier– to teach

– to learn

– to remember

– to use

– to read

– to parse

Page 4: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Simplicity

• Not all problems are simple

• "The Unlanguage"

• Choose your complexity

Page 5: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

The Waterbed Theory

Page 6: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

The Waterbed Theory

Page 7: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

The Waterbed Theory

• Push it down...

Page 8: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

The Waterbed Theory

• Push it down...

Page 9: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

The Waterbed Theory

• Push it down...

• ...it rises on the other side

Page 10: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

The Waterbed Theory

• Conservation of complexity

• Many operators:^%+ !@== ?/ **~* -_-$

• Few operators:assign(a, add(multiply(3,4), 5))

• Find the balance

Page 11: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Reuse

• Repeated structures while (true) {

# do something}

if (true) then# do something

end if

• Provides consistency

• Syntactic conventions

Page 12: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Distinction

• Small differences disappear

• If "cats" were "togs"

• Visual clues– eval and try– for and loop– sub and method

• Distinction vs. Reuse

Page 13: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Freedom

• Programmer freedom

• Customs, not laws

• Perl isn't a training bike

• Some things should be hard

• Freedom demands flexibility

Page 14: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Adaptability

• Change is natural

• Adjust to need

• Stay relevant

• Dead languages don't change

• Plan for change

• Features like:– modifiable parsing

– core vs. user-defined

– user-defined operators

Page 15: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Prominence

• All syntax is not created equal• Some things stick out• Use to your advantage• BEGIN blocks (NAMED blocks)• Modifier forms of if, unless, etc.

if ($blue) {print "True Blue.";

}

print "True Blue." if $blue;

Page 16: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

End Weight

• Lengthy bits at the end "I gave Mary the book" "I gave the book to Mary" "I gave the book about the history of the

development of peanut-based products inIndonesia to Mary."

• Easier to read, easier to parse$line =~ m/^phone\s*

(\d{3})-?(\d{3})-?(\d{4})$/ix;

Page 17: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

End Weight

• Lengthy bits at the end "I gave Mary the book" "I gave the book to Mary" "I gave the book about the history of the

development of peanut-based products inIndonesia to Mary."

• Easier to read, easier to parse$line ~~ m:i/^phone\s*

(\d<3>)-?(\d<3>)-?(\d<4>)$/;

Page 18: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

DWIM

• Do What I Mean

• DWIM not always DWYM

• Use the DWIM, Luke

• Targets– Perl programmers

– English speakers

1st, 2nd, 3rd also 1th, 2th, 3th

Page 19: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Borrowing

• Like "camouflage"

• Features for the taking

• Mutual respect

• Open thought

• Adoption with Adaptation

Page 20: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Perl Should Stay Perl

• What makes it Perl?

• True to designer's purpose

• Familiar

• Translatable

Page 21: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Long-Term Usability

• Not 2 years

• 20+ years

• Not fads or cute tricks

• Strong, dependable tools

• Not perfect, just a step

Page 22: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Summary

• Adaptable

• Freeing

• Simple...

• ...but complex

• Distinct...

• ...but consistent

• Borrow...

• ...but Perl-ishly

Page 23: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Summary

• Relevant now...

• ...and relevant then

• Programmer friendly

• More Perl

Page 24: Perl 6 Design Philosophy - lohutok.net · Perl 6 Design Philosophy Allison Randal The Perl Foundation & Onyx Neon Consulting. Design Philosophy •Every language is unique •Design

Questions?