general introduction and outline of the study

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

Upload: others

Post on 12-Sep-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Perl 6 DesignPhilosophy

Allison RandalThe Perl Foundation &

Onyx Neon Consulting

Page 2: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

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: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Simplicity

• Simple is better

• Simple is easier– to teach

– to learn

– to remember

– to use

– to read

– to parse

Page 4: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Simplicity

• Not all problems are simple

• "The Unlanguage"

• Choose your complexity

Page 5: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

The Waterbed Theory

Page 6: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

The Waterbed Theory

Page 7: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

The Waterbed Theory

• Push it down...

Page 8: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

The Waterbed Theory

• Push it down...

Page 9: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

The Waterbed Theory

• Push it down...

• ...it rises on the other side

Page 10: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

The Waterbed Theory

• Conservation of complexity

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

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

• Find the balance

Page 11: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Reuse

• Repeated structures while (true) {

# do something}

if (true) then# do something

end if

• Provides consistency

• Syntactic conventions

Page 12: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Distinction

• Small differences disappear

• If "cats" were "togs"

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

• Distinction vs. Reuse

Page 13: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Freedom

• Programmer freedom

• Customs, not laws

• Perl isn't a training bike

• Some things should be hard

• Freedom demands flexibility

Page 14: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

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: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

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: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

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: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

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: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

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: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Borrowing

• Like "camouflage"

• Features for the taking

• Mutual respect

• Open thought

• Adoption with Adaptation

Page 20: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Perl Should Stay Perl

• What makes it Perl?

• True to designer's purpose

• Familiar

• Translatable

Page 21: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Long-Term Usability

• Not 2 years

• 20+ years

• Not fads or cute tricks

• Strong, dependable tools

• Not perfect, just a step

Page 22: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Summary

• Adaptable

• Freeing

• Simple...

• ...but complex

• Distinct...

• ...but consistent

• Borrow...

• ...but Perl-ishly

Page 23: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Summary

• Relevant now...

• ...and relevant then

• Programmer friendly

• More Perl

Page 24: GENERAL INTRODUCTION AND OUTLINE OF THE STUDY

Questions?