SlideShare a Scribd company logo
1 of 84
RUMMAGING IN THE CLOOSET
Curtis “Ovid” Poe
http://allaroundtheworld.fr/
9 juin 2021 Copyright 2020, http://www.allaroundtheworld.fr/
All Around The World
• Curtis “Ovid” Poe
• https://allaroundtheworld.fr/
• https://twitter.com/OvidPerl
• ovid@allroundtheworld.fr
↓
9 juin 2021 Copyright 2020, http://www.allaroundtheworld.fr/
OO Trivia Night
• No grand proposals
• No serious points
• Miscellaneous OO trivia
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Simula 67
Class Rectangle (Width, Height); Real Width, Height;
! Class with two parameters;
Begin
Real Area, Perimeter; ! Attributes;
Procedure Update; ! Methods (Can be Virtual);
Begin
Area := Width * Height;
Perimeter := 2*(Width + Height)
End of Update;
Boolean Procedure IsSquare;
IsSquare := Width=Height;
Update; ! Life of rectangle started at creation;
OutText("Rectangle created: "); OutFix(Width,2,6);
OutFix(Height,2,6); OutImage
End of Rectangle;
! http://staff.um.edu.mt/jskl1/talk.html#Classes
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Simula 67
• Classes
• Polymorphism
• Encapsulation
• Inheritance
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Smalltalk!
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Smalltalk
“Making simple things very simple and complex
things very possible”— Alan Kay
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Via Dr. Stéphane Ducasse
http://scg.unibe.ch/archive/lectures/DucasseLectures/Duca00y1SmalltalkLectures.pdf
Syntax on a Postcard
exampleWithNumber: x
|y|
true & false not & (nil isNil) ifFalse: [self halt].
y := self size + super size.
#($a #a 'a' 1 1.0)
do: [:each | Transcript
show: (each class name);
show: (each printString);
show: ' '].
^ x < y
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Smalltalk-80
• true
• false
• nil
• self
• super
• thisContext
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Side Note: Lisp defined in Lisp
apply[fn;x;a] =
[atom[fn] → [eq[fn;CAR] → caar[x];
eq[fn;CDR] → cdar[x];
eq[fn;CONS] → cons[car[x];cadr[x]];
eq[fn;ATOM] → atom[car[x]];
eq[fn;EQ] → eq[car[x];cadr[x]];
T → apply[eval[fn;a];x;a]];
eq[car[fn];LAMBDA] → eval[caddr[fn]; pairlis[cadr[fn];x;a]];
eq[car[fn];LABEL] →
apply[caddr[fn];x;cons[cons[cadr[fn];caddr[fn]];a]]]
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Lisp 1.5 Programmer's Manual, 1962. From page 13
http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf
No “if” in Smalltalk
result := a > b
ifTrue:[ 'greater' ]
ifFalse:[ 'less or equal' ]
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Remember This Slide!
abstract class Boolean {
method ifTrue ($code) {}
method ifFalse ($code) {}
}
class True isa Boolean {
method ifTrue ($code) {$code->()}
}
class False isa Boolean {
method ifFalse ($code) {$code->()}
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
When I get bored writing slides …
class SuperPosition isa Boolean {
has $observed;
method ifTrue ($code) {
$observed //= 'true';
$code->() if 'true' eq $observed;
}
method ifFalse ($code) {
$observed //= 'false';
$code->() if 'false' eq $observed;
}
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Inheritance!
Enough of the sideshow …
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Inheritance
• class Customer isa Person {…}
• A more specialized version of the parent
• Liskov!
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Barbara Liskov
Liskov Substitution Principle
Subtype Requirement: Let ϕ(x)
be a property provable about
objects x of type T.
Then ϕ(y) should be true for
objects y of type S where S is a
subtype of T.
Photo by Kenneth C. Zirkel
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
🤷🤷
Barbara Liskov
Liskov Substitution Principle
Any place you use a class, you
should be able to use its
subclasses.
Photo by Kenneth C. Zirkel
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
👍🤷
Liskov
# Assuming
class Customer isa Person { … }
# If this works
if ( $person->age('years') >= VOTING_AGE ) { … }
# The following must work
if ( $customer->age('years') >= VOTING_AGE ) { … }
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
INHERITANCE
What's Really Wrong With It?
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Alan Kay
You're Doing It Wrong
• Invented the term “Object-
Oriented”
• Biological systems
• Inheritance was interesting
• Until the problem …
By Marcin Wichary from SF, U.S.A. -
Alan Kay, CC BY 2.0
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Inheritance
class Invoice isa Person {
…
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Inheritance (sucks)
• Software doesn’t understand intent
• We can’t enforce “subclass as specialization”
• Design by Contract (sort of) helps
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Design by Contract
• Formal declaration of a class "contract"
• Preconditions
• Postconditions
• Invariants
• Subclasses can weaken preconditions
• Subclasses can strengthen postconditions and
invariants
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
DbC in Eiffel
put (x: ELEMENT; key: STRING) is
-- Insert x so that it can be retrieved via key.
require
count <= capacity
not key.empty
do
... Some insertion algorithm ...
ensure
has (x)
item (key) = x
count = old count + 1
end
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
DbC In Perl (many CPAN modules)
package ClassName
use Class::Contract;
contract {
inherits 'BaseClass';
attr 'data1';
attr 'data2' => HASH;
class attr 'shared' => SCALAR;
ctor 'new';
method 'methodname';
pre { ... }; failmsg 'Error message';
post { ... }; failmsg 'Error message';
impl { ... };
method 'nextmethod';
impl { ... };
class method 'sharedmeth';
impl { ... };
};
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
BETA Programming Language
Employee: (#
name: @ Text;
birthday: @ Date;
dept: ^ Department;
totalHours: @ Integer;
RegisterWork: (#
noOfHours: @ Integer
enter noOfHours
do noOfHours + totalhours → totalHours
#);
ComputeSalary:< (#
salary: @ integer
do inner
exit salary
#);
#)
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
https://beta.cs.au.dk/Papers/BetaOverview/BetaOverview.pdf
BETA Programming Language
Worker: Employee (#
seniority: @ integer;
ComputeSalary::< (#
do noOfHours * 80 + seniority * 4 → salary;
0 → totalHours
#)
#);
Salesperson: Employee (#
noOfSoldUnits: @ integer;
ComputeSalary::< (#
do noOfHours*80 + noOfSoldUnits * 6 → salary;
0 → noOfSoldUnits → totalHours
#)
#)
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Beta Programming Language
Employee:(#
…
ComputeSalary:< (#
salary: @ integer
do inner
exit salary
#);
#)
Salesperson: Employee (#
noOfSoldUnits: @ integer;
ComputeSalary::< (#
do noOfHours * 80 + noOfSoldUnits * 6 → salary;
0 → noOfSoldUnits → totalHours
#)
#)
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Moose
package Employee {
use Moose;
sub ComputeSalary {
my $salary = inner();
croak(…) if $salary < 0;
return $salary;
}
}
package Salesman {
use Moose;
extends 'Employee';
augment ComputeSalary => sub {
my $self = shift;
…
return $salary;
};
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Back to Inheritance
• Multiple inheritance
• Single single inheritance
• Composition and delegation
• Interfaces
• Mixins
• Whatever the BETA designers were smoking …
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Mixins
module Bomb
def explode
puts "Bomb Explode"
end
def fuse
puts "Bomb Fuse"
end
end
module Toddler
def explode
puts "Toddler Explode"
end
def fuse
puts "Toddler Fuse"
end
end
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Mixins
class PracticalJoke
include Toddler
include Bomb
end
joke = PracticalJoke.new()
joke.fuse
joke.explode
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Mixins
class PracticalJoke
include Toddler
include Bomb
end
joke = PracticalJoke.new()
joke.fuse
joke.explode
Bomb fuse
Bomb explode
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Mixins
irb(main):026:0> PracticalJoke.ancestors
=> [PracticalJoke, Bomb, Toddler, Object, Kernel,
BasicObject]
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Mixins
class Car < Vehicle
include Robot
…
end
• What happens if Vehicle and Robot both have a driver method?
• Robot wins (same is true of roles since we can't declare overrides)
• Is Robot really a more specialized version of Vehicle?
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Mixins
• Should not make composition assumptions
• Thus, super should not be called (but it is)
• Should next::method be used in roles?
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Computer Science
• Computer scientists argue
• Computer programmers rant
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
But Ovid …
• “It mostly works”
• “Easy to fix when it doesn’t”
• “Devs should know their code base”
(That last one really ticks me off)
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Alan Kay
Human body has ~ 40 trillion cells
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
A Perfect Object
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Web Browsers and Web Servers
• Browsers send messages
• Browser doesn't crash if server crashes
• Isolation, not encapsulation
• Well-defined, fault-tolerant protocol
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Corinna v Perl v Python
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
InventoryItem (mutable!)
class InventoryItem:
def __init__(self, name, price, quantity):
self.name = name
self.unit_price = price
self.quantity_on_hand = quantity
def total_cost(self):
return self.unit_price * self.quantity_on_hand
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
InventoryItem (immutable)
package InventoryItem;
use strict;
use warnings;
sub new {
my ( $class, $name, $unit_price, $quantity_on_hand ) = @_;
return bless {
name => $name,
unit_price => $unit_price,
quantity_on_hand => $quantity_on_hand,
} => $class;
}
sub name { $_[0]->{name} }
sub unit_price { $_[0]->{unit_price} }
sub quantity_on_hand { $_[0]->{quantity_on_hand} }
sub total_cost {
my $self = shift;
return $self->{unit_price} * $self->{quantity_on_hand};
}
1;
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
InventoryItem (immutable)
class InventoryItem {
has $name :new :reader;
has $unit_price :new :reader;
has $quantity_on_hand :new :reader;
method total_cost() {
return $unit_price * $quantity_on_hand;
}
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
InventoryItem (mutable!)
class InventoryItem:
def __init__(self, name, price, quantity):
self.name = name
self.unit_price = price
self.quantity_on_hand = quantity
def total_cost(self):
return self.unit_price * self.quantity_on_hand
item = InventoryItem('Foo', 3.5, 3)
print(item.total_cost())
item.price = 'bob'
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
InventoryItem (mutable!)
from dataclasses import dataclass
@dataclass
class InventoryItem:
name: str
unit_price: float
quantity_on_hand: int = 0
def total_cost(self) -> float:
return self.unit_price * self.quantity_on_hand
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
InventoryItem (mutable!)
from dataclasses import dataclass
@dataclass
class InventoryItem:
name: str
unit_price: float
quantity_on_hand: int = 0
def total_cost(self) -> float:
return self.unit_price * self.quantity_on_hand
item = InventoryItem('Widget', 3.5, 3)
print(item.total_cost())
item.unit_price = 'bob'
print(item.total_cost())
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
InventoryItem (mutable!)
from dataclasses import dataclass
@dataclass
class InventoryItem:
name: str
unit_price: float
quantity_on_hand: int = 0
def assert_valid(self):
is_valid = True
for field_name, field_def in self.__dataclass_fields__.items():
actual_type = type(getattr(self, field_name))
if actual_type != field_def.type:
print(f"t{field_name}: '{actual_type}' instead of
'{field_def.type}'")
is_valid = False
if not is_valid:
raise ValueError("Type assertion failed");
def total_cost(self) -> float:
self.assert_valid()
return self.unit_price * self.quantity_on_hand
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
InventoryItem (immutable)
from dataclasses import dataclass
@dataclass(frozen=True)
class InventoryItem:
name: str
unit_price: float
quantity_on_hand: int = 0
def __postinit__(self):
self.assert_valid
def assert_valid(self):
is_valid = True
for field_name, field_def in self.__dataclass_fields__.items():
actual_type = type(getattr(self, field_name))
if actual_type != field_def.type:
print(f"t{field_name}: '{actual_type}' instead of '{field_def.type}'")
is_valid = False
if not is_valid:
raise ValueError("Type assertion failed");
def total_cost(self) -> float:
return self.unit_price * self.quantity_on_hand
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Solving This
• Pydantic—Runtime type validation
• mypy—Static type checker
• Pyright—Static type checker
https://pydantic-docs.helpmanual.io/
http://mypy-lang.org/
https://github.com/microsoft/pyright
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Why Types?
•Correctness
• Performance
• Documentation
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
InventoryItem ☹️
class InventoryItem {
has $name :new :reader :isa(Str);
has $unit_price :new :reader :isa(Num);
has $quantity_on_hand :new :reader :isa(Int);
method total_cost() {
return $unit_price * $quantity_on_hand;
}
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Why Not Types?
• Variable declarations
• Slot declarations
• Signatures
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Why Not Types?
• my Int $foo;
• my $foo :Int;
• my $foo :isa(Int);
• has $foo :isa(Int);
• sub foo (Int $bar) {…}
• sub foo ($bar Int) {…}
• sub foo ($bar :isa(Int)) {…}
• sub foo ($bar :isa(Int)) :isa(Num) {…}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Lessons Learned
• Inheritance is a mess
• We need (but won't get) optional types
• Simple is beautiful
• "Good enough" isn't good enough
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Changes to Corinna
• No :builder
• No CONSTRUCT/BUILDARGS
• ADJUST and DESTRUCT are phasers
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
:builder
class SomeClass {
has $x :builder;
method _build_x () { return rand; }
}
class AnotherClass {
method _build_x () { return "Surprise!" }
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Possible Fixes?
# painful if your builder is complex
class SomeClass {
has $x :builder { return rand };
}
# we don't yet have private methods
class SomeClass {
has $x :builder;
private method _build_x () { return "Surprise" }
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
For now …
class SomeClass {
has $x;
ADJUST {
$x = rand;
}
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
For now …
class SomeClass {
has $x;
ADJUST {
$x = $self->_build_x;
}
method _build_x () { return rand; }
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Phasers
class SomeClass {
my $num_instances = 0;
ADJUST { $num_instances++ }
DESTRUCT { $num_instances-- }
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Phasers?
class SomeClass {
my $num_instances = 0;
has $name :new;
CONSTRUCT ($class, @args) {
if (1 == @args) { unshift @args => 'name' }
return @args;
}
ADJUST { $num_instances++ }
DESTRUCT { $num_instances-- }
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Alternate Constructors
class SomeClass {
my $num_instances = 0;
has $name :new;
method from_name ($this_name) {
return $class->new( name => $this_name );
}
ADJUST { $num_instances++ }
DESTRUCT { $num_instances-- }
}
my $thing = SomeClass->from_name('Ovid');
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Speaking of Constructors …
class Person {
has $name :new;
has $title :new(optional);
has $answer = 42;
method name () {
return defined $title
? "$title $name" : $name;
}
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Ugly!
class Person {
has $name :new;
has $title :new(optional);
has $answer = 42;
method name () {
return defined $title
? "$title $name" : $name;
}
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Simplified by Reusing Syntax
class Person {
has $name :new;
has $title :new = undef;
has $answer = 42;
method name () {
return defined $title
? "$title $name" : $name;
}
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Abstract Methods
abstract method foo ();
• Less useful without types
• Compile-time or runtime?
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
How can we simplify this?
abstract class Shape {
abstract method area ();
abstract method perimeter ();
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Abstract Methods == Abstract Class
class Shape {
abstract method area ();
abstract method perimeter ();
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Forward Declarations!
class Shape {
method area ();
method perimeter ();
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Roles!
role Shape {
method area ();
method perimeter ();
}
# versus
role Shape {
requires qw(area perimeter);
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
The Future?
class Shape {
method area ();
method perimeter ();
}
# later
my $foo = Shape->any_method; # boom
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Remember Me?
abstract class Boolean {
method ifTrue ($code) {}
method ifFalse ($code) {}
}
class True isa Boolean {
method ifTrue ($code) {$code->()}
}
class False isa Boolean {
method ifFalse ($code) {$code->()}
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
$self and $class
common method baz () {
$class->quux;
}
method foo () {
$self->bar;
$class->baz;
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Compile-Time Failure!
common method baz () {
$self->quux;
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Redefined Warnings
method foo () {
my $class = ref ($self) || $self;
$self->quux;
}
"my" variable $class masks earlier declaration in
same scope at …
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
And in the future?
common method baz () {
$class->foo;
}
method foo () {
$self->bar;
$class->baz;
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Quick Note On V1 Roles
• Might not have exclusion or aliasing
• Might not have method modifiers
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Role Example
role Role::ToJSON {
use Cpanel::JSON::XS;
private method marshall_data ();
method to_json () {
my $data = $self->marshall_data;
return encode_json $data;
}
}
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
When?
• Curtis Poe—Ovid
• Corinna design
• Will create an RFC
• https://github.com/Perl/RFCs
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
When?
• Paul Evans—LeoNerd
• Object::Pad
• Future::AsyncAwait
• Syntax::Keyword::Try
• Much more
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Summary
• This was trivia, not really informative
• What can we remove?
• What must we add?
• Lack of types is a problem
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
Thank You!

More Related Content

Similar to Rummaging in the clOOset

Bucc Toy Project: Learn programming through Game Development
Bucc  Toy Project: Learn programming through Game DevelopmentBucc  Toy Project: Learn programming through Game Development
Bucc Toy Project: Learn programming through Game DevelopmentSadaf Noor
 
Corinna Status 2022.pptx
Corinna Status 2022.pptxCorinna Status 2022.pptx
Corinna Status 2022.pptxCurtis Poe
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaKonrad Malawski
 
CoreOS + Kubernetes @ All Things Open 2015
CoreOS + Kubernetes @ All Things Open 2015CoreOS + Kubernetes @ All Things Open 2015
CoreOS + Kubernetes @ All Things Open 2015Brandon Philips
 
Boxen: How to Manage an Army of Laptops
Boxen: How to Manage an Army of LaptopsBoxen: How to Manage an Army of Laptops
Boxen: How to Manage an Army of LaptopsPuppet
 
Causal inference-for-profit | Dan McKinley | DN18
Causal inference-for-profit | Dan McKinley | DN18Causal inference-for-profit | Dan McKinley | DN18
Causal inference-for-profit | Dan McKinley | DN18DataconomyGmbH
 
DN18 | A/B Testing: Lessons Learned | Dan McKinley | Mailchimp
DN18 | A/B Testing: Lessons Learned | Dan McKinley | MailchimpDN18 | A/B Testing: Lessons Learned | Dan McKinley | Mailchimp
DN18 | A/B Testing: Lessons Learned | Dan McKinley | MailchimpDataconomy Media
 
EWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 21: Persistent JavaScript ObjectsEWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 21: Persistent JavaScript ObjectsRob Tweed
 
Corinna-2023.pptx
Corinna-2023.pptxCorinna-2023.pptx
Corinna-2023.pptxCurtis Poe
 
Questioning the status quo
Questioning the status quoQuestioning the status quo
Questioning the status quoIvano Pagano
 
Ops for everyone - John Britton
Ops for everyone - John BrittonOps for everyone - John Britton
Ops for everyone - John BrittonDevopsdays
 
John Britton of GitHub on Ops for Everyone at DevCon Summit 2013 #MobileDevNB...
John Britton of GitHub on Ops for Everyone at DevCon Summit 2013 #MobileDevNB...John Britton of GitHub on Ops for Everyone at DevCon Summit 2013 #MobileDevNB...
John Britton of GitHub on Ops for Everyone at DevCon Summit 2013 #MobileDevNB...DEVCON
 
OpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudOpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudIsaac Christoffersen
 
[JSDC 2016] Codex: Conditional Modules Strike Back
[JSDC 2016] Codex: Conditional Modules Strike Back[JSDC 2016] Codex: Conditional Modules Strike Back
[JSDC 2016] Codex: Conditional Modules Strike BackAlex Liu
 
React Native Evening
React Native EveningReact Native Evening
React Native EveningTroy Miles
 
From Android NDK To AOSP
From Android NDK To AOSPFrom Android NDK To AOSP
From Android NDK To AOSPMin-Yih Hsu
 

Similar to Rummaging in the clOOset (20)

Bucc Toy Project: Learn programming through Game Development
Bucc  Toy Project: Learn programming through Game DevelopmentBucc  Toy Project: Learn programming through Game Development
Bucc Toy Project: Learn programming through Game Development
 
Corinna Status 2022.pptx
Corinna Status 2022.pptxCorinna Status 2022.pptx
Corinna Status 2022.pptx
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and Akka
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
 
CoreOS + Kubernetes @ All Things Open 2015
CoreOS + Kubernetes @ All Things Open 2015CoreOS + Kubernetes @ All Things Open 2015
CoreOS + Kubernetes @ All Things Open 2015
 
Boxen: How to Manage an Army of Laptops
Boxen: How to Manage an Army of LaptopsBoxen: How to Manage an Army of Laptops
Boxen: How to Manage an Army of Laptops
 
Causal inference-for-profit | Dan McKinley | DN18
Causal inference-for-profit | Dan McKinley | DN18Causal inference-for-profit | Dan McKinley | DN18
Causal inference-for-profit | Dan McKinley | DN18
 
DN18 | A/B Testing: Lessons Learned | Dan McKinley | Mailchimp
DN18 | A/B Testing: Lessons Learned | Dan McKinley | MailchimpDN18 | A/B Testing: Lessons Learned | Dan McKinley | Mailchimp
DN18 | A/B Testing: Lessons Learned | Dan McKinley | Mailchimp
 
EWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 21: Persistent JavaScript ObjectsEWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 21: Persistent JavaScript Objects
 
How to build the Web
How to build the WebHow to build the Web
How to build the Web
 
Corinna-2023.pptx
Corinna-2023.pptxCorinna-2023.pptx
Corinna-2023.pptx
 
Questioning the status quo
Questioning the status quoQuestioning the status quo
Questioning the status quo
 
groovy & grails - lecture 2
groovy & grails - lecture 2groovy & grails - lecture 2
groovy & grails - lecture 2
 
Ops for everyone - John Britton
Ops for everyone - John BrittonOps for everyone - John Britton
Ops for everyone - John Britton
 
John Britton of GitHub on Ops for Everyone at DevCon Summit 2013 #MobileDevNB...
John Britton of GitHub on Ops for Everyone at DevCon Summit 2013 #MobileDevNB...John Britton of GitHub on Ops for Everyone at DevCon Summit 2013 #MobileDevNB...
John Britton of GitHub on Ops for Everyone at DevCon Summit 2013 #MobileDevNB...
 
Sprockets
SprocketsSprockets
Sprockets
 
OpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudOpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid Cloud
 
[JSDC 2016] Codex: Conditional Modules Strike Back
[JSDC 2016] Codex: Conditional Modules Strike Back[JSDC 2016] Codex: Conditional Modules Strike Back
[JSDC 2016] Codex: Conditional Modules Strike Back
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
From Android NDK To AOSP
From Android NDK To AOSPFrom Android NDK To AOSP
From Android NDK To AOSP
 

More from Curtis Poe

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
life-off-earth.pptx
life-off-earth.pptxlife-off-earth.pptx
life-off-earth.pptxCurtis Poe
 
Rescuing a-legacy-codebase
Rescuing a-legacy-codebaseRescuing a-legacy-codebase
Rescuing a-legacy-codebaseCurtis Poe
 
Perl 6 For Mere Mortals
Perl 6 For Mere MortalsPerl 6 For Mere Mortals
Perl 6 For Mere MortalsCurtis Poe
 
Disappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
Disappearing Managers, YAPC::EU 2014, Bulgaria, KeynoteDisappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
Disappearing Managers, YAPC::EU 2014, Bulgaria, KeynoteCurtis Poe
 
How to Fake a Database Design
How to Fake a Database DesignHow to Fake a Database Design
How to Fake a Database DesignCurtis Poe
 
Are Managers An Endangered Species?
Are Managers An Endangered Species?Are Managers An Endangered Species?
Are Managers An Endangered Species?Curtis Poe
 
The Lies We Tell About Software Testing
The Lies We Tell About Software TestingThe Lies We Tell About Software Testing
The Lies We Tell About Software TestingCurtis Poe
 
A/B Testing - What your mother didn't tell you
A/B Testing - What your mother didn't tell youA/B Testing - What your mother didn't tell you
A/B Testing - What your mother didn't tell youCurtis Poe
 
Test::Class::Moose
Test::Class::MooseTest::Class::Moose
Test::Class::MooseCurtis Poe
 
A Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::ClassA Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::ClassCurtis Poe
 
Agile Companies Go P.O.P.
Agile Companies Go P.O.P.Agile Companies Go P.O.P.
Agile Companies Go P.O.P.Curtis Poe
 
Testing With Test::Class
Testing With Test::ClassTesting With Test::Class
Testing With Test::ClassCurtis Poe
 
Logic Progamming in Perl
Logic Progamming in PerlLogic Progamming in Perl
Logic Progamming in PerlCurtis Poe
 
Inheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionInheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionCurtis Poe
 
Turbo Charged Test Suites
Turbo Charged Test SuitesTurbo Charged Test Suites
Turbo Charged Test SuitesCurtis Poe
 

More from Curtis Poe (17)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
life-off-earth.pptx
life-off-earth.pptxlife-off-earth.pptx
life-off-earth.pptx
 
Rescuing a-legacy-codebase
Rescuing a-legacy-codebaseRescuing a-legacy-codebase
Rescuing a-legacy-codebase
 
Perl 6 For Mere Mortals
Perl 6 For Mere MortalsPerl 6 For Mere Mortals
Perl 6 For Mere Mortals
 
Disappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
Disappearing Managers, YAPC::EU 2014, Bulgaria, KeynoteDisappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
Disappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
 
How to Fake a Database Design
How to Fake a Database DesignHow to Fake a Database Design
How to Fake a Database Design
 
Are Managers An Endangered Species?
Are Managers An Endangered Species?Are Managers An Endangered Species?
Are Managers An Endangered Species?
 
The Lies We Tell About Software Testing
The Lies We Tell About Software TestingThe Lies We Tell About Software Testing
The Lies We Tell About Software Testing
 
A/B Testing - What your mother didn't tell you
A/B Testing - What your mother didn't tell youA/B Testing - What your mother didn't tell you
A/B Testing - What your mother didn't tell you
 
Test::Class::Moose
Test::Class::MooseTest::Class::Moose
Test::Class::Moose
 
A Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::ClassA Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::Class
 
Agile Companies Go P.O.P.
Agile Companies Go P.O.P.Agile Companies Go P.O.P.
Agile Companies Go P.O.P.
 
Econ101
Econ101Econ101
Econ101
 
Testing With Test::Class
Testing With Test::ClassTesting With Test::Class
Testing With Test::Class
 
Logic Progamming in Perl
Logic Progamming in PerlLogic Progamming in Perl
Logic Progamming in Perl
 
Inheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionInheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth Version
 
Turbo Charged Test Suites
Turbo Charged Test SuitesTurbo Charged Test Suites
Turbo Charged Test Suites
 

Recently uploaded

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Recently uploaded (20)

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

Rummaging in the clOOset

  • 1. RUMMAGING IN THE CLOOSET Curtis “Ovid” Poe http://allaroundtheworld.fr/ 9 juin 2021 Copyright 2020, http://www.allaroundtheworld.fr/
  • 2. All Around The World • Curtis “Ovid” Poe • https://allaroundtheworld.fr/ • https://twitter.com/OvidPerl • ovid@allroundtheworld.fr ↓ 9 juin 2021 Copyright 2020, http://www.allaroundtheworld.fr/
  • 3. OO Trivia Night • No grand proposals • No serious points • Miscellaneous OO trivia 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 4. Simula 67 Class Rectangle (Width, Height); Real Width, Height; ! Class with two parameters; Begin Real Area, Perimeter; ! Attributes; Procedure Update; ! Methods (Can be Virtual); Begin Area := Width * Height; Perimeter := 2*(Width + Height) End of Update; Boolean Procedure IsSquare; IsSquare := Width=Height; Update; ! Life of rectangle started at creation; OutText("Rectangle created: "); OutFix(Width,2,6); OutFix(Height,2,6); OutImage End of Rectangle; ! http://staff.um.edu.mt/jskl1/talk.html#Classes 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 5. Simula 67 • Classes • Polymorphism • Encapsulation • Inheritance 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 6. Smalltalk! 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 7. Smalltalk “Making simple things very simple and complex things very possible”— Alan Kay 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/ Via Dr. Stéphane Ducasse http://scg.unibe.ch/archive/lectures/DucasseLectures/Duca00y1SmalltalkLectures.pdf
  • 8. Syntax on a Postcard exampleWithNumber: x |y| true & false not & (nil isNil) ifFalse: [self halt]. y := self size + super size. #($a #a 'a' 1 1.0) do: [:each | Transcript show: (each class name); show: (each printString); show: ' ']. ^ x < y 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 9. Smalltalk-80 • true • false • nil • self • super • thisContext 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 10. Side Note: Lisp defined in Lisp apply[fn;x;a] = [atom[fn] → [eq[fn;CAR] → caar[x]; eq[fn;CDR] → cdar[x]; eq[fn;CONS] → cons[car[x];cadr[x]]; eq[fn;ATOM] → atom[car[x]]; eq[fn;EQ] → eq[car[x];cadr[x]]; T → apply[eval[fn;a];x;a]]; eq[car[fn];LAMBDA] → eval[caddr[fn]; pairlis[cadr[fn];x;a]]; eq[car[fn];LABEL] → apply[caddr[fn];x;cons[cons[cadr[fn];caddr[fn]];a]]] 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/ Lisp 1.5 Programmer's Manual, 1962. From page 13 http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf
  • 11. No “if” in Smalltalk result := a > b ifTrue:[ 'greater' ] ifFalse:[ 'less or equal' ] 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 12. Remember This Slide! abstract class Boolean { method ifTrue ($code) {} method ifFalse ($code) {} } class True isa Boolean { method ifTrue ($code) {$code->()} } class False isa Boolean { method ifFalse ($code) {$code->()} } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 13. When I get bored writing slides … class SuperPosition isa Boolean { has $observed; method ifTrue ($code) { $observed //= 'true'; $code->() if 'true' eq $observed; } method ifFalse ($code) { $observed //= 'false'; $code->() if 'false' eq $observed; } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 14. Inheritance! Enough of the sideshow … 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 15. Inheritance • class Customer isa Person {…} • A more specialized version of the parent • Liskov! 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 16. Barbara Liskov Liskov Substitution Principle Subtype Requirement: Let ϕ(x) be a property provable about objects x of type T. Then ϕ(y) should be true for objects y of type S where S is a subtype of T. Photo by Kenneth C. Zirkel 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/ 🤷🤷
  • 17. Barbara Liskov Liskov Substitution Principle Any place you use a class, you should be able to use its subclasses. Photo by Kenneth C. Zirkel 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/ 👍🤷
  • 18. Liskov # Assuming class Customer isa Person { … } # If this works if ( $person->age('years') >= VOTING_AGE ) { … } # The following must work if ( $customer->age('years') >= VOTING_AGE ) { … } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 19. INHERITANCE What's Really Wrong With It? 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 20. Alan Kay You're Doing It Wrong • Invented the term “Object- Oriented” • Biological systems • Inheritance was interesting • Until the problem … By Marcin Wichary from SF, U.S.A. - Alan Kay, CC BY 2.0 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 21. Inheritance class Invoice isa Person { … } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 22. Inheritance (sucks) • Software doesn’t understand intent • We can’t enforce “subclass as specialization” • Design by Contract (sort of) helps 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 23. Design by Contract • Formal declaration of a class "contract" • Preconditions • Postconditions • Invariants • Subclasses can weaken preconditions • Subclasses can strengthen postconditions and invariants 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 24. DbC in Eiffel put (x: ELEMENT; key: STRING) is -- Insert x so that it can be retrieved via key. require count <= capacity not key.empty do ... Some insertion algorithm ... ensure has (x) item (key) = x count = old count + 1 end 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 25. DbC In Perl (many CPAN modules) package ClassName use Class::Contract; contract { inherits 'BaseClass'; attr 'data1'; attr 'data2' => HASH; class attr 'shared' => SCALAR; ctor 'new'; method 'methodname'; pre { ... }; failmsg 'Error message'; post { ... }; failmsg 'Error message'; impl { ... }; method 'nextmethod'; impl { ... }; class method 'sharedmeth'; impl { ... }; }; 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 26. BETA Programming Language Employee: (# name: @ Text; birthday: @ Date; dept: ^ Department; totalHours: @ Integer; RegisterWork: (# noOfHours: @ Integer enter noOfHours do noOfHours + totalhours → totalHours #); ComputeSalary:< (# salary: @ integer do inner exit salary #); #) 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/ https://beta.cs.au.dk/Papers/BetaOverview/BetaOverview.pdf
  • 27. BETA Programming Language Worker: Employee (# seniority: @ integer; ComputeSalary::< (# do noOfHours * 80 + seniority * 4 → salary; 0 → totalHours #) #); Salesperson: Employee (# noOfSoldUnits: @ integer; ComputeSalary::< (# do noOfHours*80 + noOfSoldUnits * 6 → salary; 0 → noOfSoldUnits → totalHours #) #) 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 28. Beta Programming Language Employee:(# … ComputeSalary:< (# salary: @ integer do inner exit salary #); #) Salesperson: Employee (# noOfSoldUnits: @ integer; ComputeSalary::< (# do noOfHours * 80 + noOfSoldUnits * 6 → salary; 0 → noOfSoldUnits → totalHours #) #) 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 29. Moose package Employee { use Moose; sub ComputeSalary { my $salary = inner(); croak(…) if $salary < 0; return $salary; } } package Salesman { use Moose; extends 'Employee'; augment ComputeSalary => sub { my $self = shift; … return $salary; }; } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 30. Back to Inheritance • Multiple inheritance • Single single inheritance • Composition and delegation • Interfaces • Mixins • Whatever the BETA designers were smoking … 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 31. Mixins module Bomb def explode puts "Bomb Explode" end def fuse puts "Bomb Fuse" end end module Toddler def explode puts "Toddler Explode" end def fuse puts "Toddler Fuse" end end 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 32. Mixins class PracticalJoke include Toddler include Bomb end joke = PracticalJoke.new() joke.fuse joke.explode 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 33. Mixins class PracticalJoke include Toddler include Bomb end joke = PracticalJoke.new() joke.fuse joke.explode Bomb fuse Bomb explode 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 34. Mixins irb(main):026:0> PracticalJoke.ancestors => [PracticalJoke, Bomb, Toddler, Object, Kernel, BasicObject] 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 35. Mixins class Car < Vehicle include Robot … end • What happens if Vehicle and Robot both have a driver method? • Robot wins (same is true of roles since we can't declare overrides) • Is Robot really a more specialized version of Vehicle? 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 36. Mixins • Should not make composition assumptions • Thus, super should not be called (but it is) • Should next::method be used in roles? 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 37. Computer Science • Computer scientists argue • Computer programmers rant 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 38. But Ovid … • “It mostly works” • “Easy to fix when it doesn’t” • “Devs should know their code base” (That last one really ticks me off) 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 39. Alan Kay Human body has ~ 40 trillion cells 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 40. A Perfect Object 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 41. Web Browsers and Web Servers • Browsers send messages • Browser doesn't crash if server crashes • Isolation, not encapsulation • Well-defined, fault-tolerant protocol 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 42. Corinna v Perl v Python 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 43. InventoryItem (mutable!) class InventoryItem: def __init__(self, name, price, quantity): self.name = name self.unit_price = price self.quantity_on_hand = quantity def total_cost(self): return self.unit_price * self.quantity_on_hand 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 44. InventoryItem (immutable) package InventoryItem; use strict; use warnings; sub new { my ( $class, $name, $unit_price, $quantity_on_hand ) = @_; return bless { name => $name, unit_price => $unit_price, quantity_on_hand => $quantity_on_hand, } => $class; } sub name { $_[0]->{name} } sub unit_price { $_[0]->{unit_price} } sub quantity_on_hand { $_[0]->{quantity_on_hand} } sub total_cost { my $self = shift; return $self->{unit_price} * $self->{quantity_on_hand}; } 1; 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 45. InventoryItem (immutable) class InventoryItem { has $name :new :reader; has $unit_price :new :reader; has $quantity_on_hand :new :reader; method total_cost() { return $unit_price * $quantity_on_hand; } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 46. InventoryItem (mutable!) class InventoryItem: def __init__(self, name, price, quantity): self.name = name self.unit_price = price self.quantity_on_hand = quantity def total_cost(self): return self.unit_price * self.quantity_on_hand item = InventoryItem('Foo', 3.5, 3) print(item.total_cost()) item.price = 'bob' 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 47. InventoryItem (mutable!) from dataclasses import dataclass @dataclass class InventoryItem: name: str unit_price: float quantity_on_hand: int = 0 def total_cost(self) -> float: return self.unit_price * self.quantity_on_hand 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 48. InventoryItem (mutable!) from dataclasses import dataclass @dataclass class InventoryItem: name: str unit_price: float quantity_on_hand: int = 0 def total_cost(self) -> float: return self.unit_price * self.quantity_on_hand item = InventoryItem('Widget', 3.5, 3) print(item.total_cost()) item.unit_price = 'bob' print(item.total_cost()) 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 49. InventoryItem (mutable!) from dataclasses import dataclass @dataclass class InventoryItem: name: str unit_price: float quantity_on_hand: int = 0 def assert_valid(self): is_valid = True for field_name, field_def in self.__dataclass_fields__.items(): actual_type = type(getattr(self, field_name)) if actual_type != field_def.type: print(f"t{field_name}: '{actual_type}' instead of '{field_def.type}'") is_valid = False if not is_valid: raise ValueError("Type assertion failed"); def total_cost(self) -> float: self.assert_valid() return self.unit_price * self.quantity_on_hand 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 50. InventoryItem (immutable) from dataclasses import dataclass @dataclass(frozen=True) class InventoryItem: name: str unit_price: float quantity_on_hand: int = 0 def __postinit__(self): self.assert_valid def assert_valid(self): is_valid = True for field_name, field_def in self.__dataclass_fields__.items(): actual_type = type(getattr(self, field_name)) if actual_type != field_def.type: print(f"t{field_name}: '{actual_type}' instead of '{field_def.type}'") is_valid = False if not is_valid: raise ValueError("Type assertion failed"); def total_cost(self) -> float: return self.unit_price * self.quantity_on_hand 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 51. Solving This • Pydantic—Runtime type validation • mypy—Static type checker • Pyright—Static type checker https://pydantic-docs.helpmanual.io/ http://mypy-lang.org/ https://github.com/microsoft/pyright 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 52. Why Types? •Correctness • Performance • Documentation 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 53. InventoryItem ☹️ class InventoryItem { has $name :new :reader :isa(Str); has $unit_price :new :reader :isa(Num); has $quantity_on_hand :new :reader :isa(Int); method total_cost() { return $unit_price * $quantity_on_hand; } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 54. Why Not Types? • Variable declarations • Slot declarations • Signatures 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 55. Why Not Types? • my Int $foo; • my $foo :Int; • my $foo :isa(Int); • has $foo :isa(Int); • sub foo (Int $bar) {…} • sub foo ($bar Int) {…} • sub foo ($bar :isa(Int)) {…} • sub foo ($bar :isa(Int)) :isa(Num) {…} 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 56. Lessons Learned • Inheritance is a mess • We need (but won't get) optional types • Simple is beautiful • "Good enough" isn't good enough 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 57. Changes to Corinna • No :builder • No CONSTRUCT/BUILDARGS • ADJUST and DESTRUCT are phasers 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 58. :builder class SomeClass { has $x :builder; method _build_x () { return rand; } } class AnotherClass { method _build_x () { return "Surprise!" } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 59. Possible Fixes? # painful if your builder is complex class SomeClass { has $x :builder { return rand }; } # we don't yet have private methods class SomeClass { has $x :builder; private method _build_x () { return "Surprise" } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 60. For now … class SomeClass { has $x; ADJUST { $x = rand; } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 61. For now … class SomeClass { has $x; ADJUST { $x = $self->_build_x; } method _build_x () { return rand; } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 62. Phasers class SomeClass { my $num_instances = 0; ADJUST { $num_instances++ } DESTRUCT { $num_instances-- } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 63. Phasers? class SomeClass { my $num_instances = 0; has $name :new; CONSTRUCT ($class, @args) { if (1 == @args) { unshift @args => 'name' } return @args; } ADJUST { $num_instances++ } DESTRUCT { $num_instances-- } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 64. Alternate Constructors class SomeClass { my $num_instances = 0; has $name :new; method from_name ($this_name) { return $class->new( name => $this_name ); } ADJUST { $num_instances++ } DESTRUCT { $num_instances-- } } my $thing = SomeClass->from_name('Ovid'); 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 65. Speaking of Constructors … class Person { has $name :new; has $title :new(optional); has $answer = 42; method name () { return defined $title ? "$title $name" : $name; } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 66. Ugly! class Person { has $name :new; has $title :new(optional); has $answer = 42; method name () { return defined $title ? "$title $name" : $name; } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 67. Simplified by Reusing Syntax class Person { has $name :new; has $title :new = undef; has $answer = 42; method name () { return defined $title ? "$title $name" : $name; } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 68. Abstract Methods abstract method foo (); • Less useful without types • Compile-time or runtime? 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 69. How can we simplify this? abstract class Shape { abstract method area (); abstract method perimeter (); } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 70. Abstract Methods == Abstract Class class Shape { abstract method area (); abstract method perimeter (); } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 71. Forward Declarations! class Shape { method area (); method perimeter (); } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 72. Roles! role Shape { method area (); method perimeter (); } # versus role Shape { requires qw(area perimeter); } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 73. The Future? class Shape { method area (); method perimeter (); } # later my $foo = Shape->any_method; # boom 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 74. Remember Me? abstract class Boolean { method ifTrue ($code) {} method ifFalse ($code) {} } class True isa Boolean { method ifTrue ($code) {$code->()} } class False isa Boolean { method ifFalse ($code) {$code->()} } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 75. $self and $class common method baz () { $class->quux; } method foo () { $self->bar; $class->baz; } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 76. Compile-Time Failure! common method baz () { $self->quux; } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 77. Redefined Warnings method foo () { my $class = ref ($self) || $self; $self->quux; } "my" variable $class masks earlier declaration in same scope at … 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 78. And in the future? common method baz () { $class->foo; } method foo () { $self->bar; $class->baz; } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 79. Quick Note On V1 Roles • Might not have exclusion or aliasing • Might not have method modifiers 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 80. Role Example role Role::ToJSON { use Cpanel::JSON::XS; private method marshall_data (); method to_json () { my $data = $self->marshall_data; return encode_json $data; } } 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 81. When? • Curtis Poe—Ovid • Corinna design • Will create an RFC • https://github.com/Perl/RFCs 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 82. When? • Paul Evans—LeoNerd • Object::Pad • Future::AsyncAwait • Syntax::Keyword::Try • Much more 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 83. Summary • This was trivia, not really informative • What can we remove? • What must we add? • Lack of types is a problem 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/
  • 84. 9 juin 2021 Copyright 2021, http://www.allaroundtheworld.fr/ Thank You!

Editor's Notes

  1. We’re called in when you need to know it’s going to work.
  2. For almost everyone, there will be some surprised here
  3. These are the six reserved keywords. Wait, where's if/else?
  4. Corinna syntax, duh … (singletons!)
  5. Languages from specs are harder to make portable. Languages defined in terms of themselves are easy to make portable.
  6. Corinna syntax, duh …
  7. Even AGI (artificial general intelligence) would struggle with this when humans get this wrong all the time
  8. DBC enforces behavior, but not meaning
  9. Not really DbC. Also, patterns, subpatterns, virtual procedures (methods), qualified references (instances)
  10. Also, note that Salesperson is able to access totalHours, declared in Employee
  11. Mixins were first introduced in 1982, in Flavors
  12. Robot methods will override Car methods of the same name
  13. You have a one million line code base with a hundred developers and things are constantly evolving, of course you won't know your code base.
  14. And it miraculously works
  15. Look how simple Smalltalk is (or Lisp, for that matter).
  16. You can get immutable classes in Python 2, but you have hoops to jump through
  17. Corinna syntax, duh … (singletons!)