►
Description
RustConf 2019 - Flatulence, Crystlas, and Happy Little Accidents by Nick Fitzgerald
Sometimes programming Rust can feel like serious business. Let's reject the absurdity of the real world and slip into solipsism with generative art. How does Rust hold up as a paint brush? And what can we learn when our fantasy worlds bleed back into reality?
A
A
Alright
yeah,
so
I
do
rust
things
for
work
these
days,
I
do
the
intersection
of
rust
and
webassembly
and
I
like
to
make
fast
things
I
like
to
make
robust
and
reliable
things,
I
like
to
create
tools
that
have
good
developer
experiences
and
support
many
different
use
cases
and
help
other
people
build
fast,
robust
and
reliable
things
and
I
love
my
job.
But
you
know
it's
a
lot
of
serious
business
right.
So
what
am
I
doing
in
my
spare
time
outside
of
work?
Well,
you
know
flashback
to
you
know
a
year
ago
or
so.
A
A
I
think
a
really
good
example
of
this
is
process
13
by
K
series
and
the
way
that
this
image
is
generated
is
kind
of
behind
the
scenes,
there's
actually
a
simulation
of
a
bunch
of
circles
moving
around
and
whenever
the
circles
overlap
or
kind
of
touch
each
other.
A
line
is
drawn
from
the
center
of
one
circle
to
the
other
circle,
and
you
know
these,
the
sorry
no
code
says
you
know,
draw
these
trellises
or
create
this
like
echoing
spiderweb
effect.
A
This
is
something
that
emerges
from
the
process
to
delight
us
and
to
surprise
us,
and
you
know,
I-
could
look
at
pieces
like
this
and
really
appreciate
their
beauty.
You
know
both
on
an
artistic
and
technical
level,
but
I
wasn't
quite
overcome
by
the
urge
to
make
this
stuff
myself
yet
because
there's
still
something
missing
for
me,
there's
nothing
physical,
that
I
could
hold
in
my
hands
and
that's
when
I
discovered
pen
plotters.
So
a
pen
plotter
is
a
robot.
A
It
has
an
arm
and
a
hand,
and
you
take
a
pen-
and
you
put
your
pen
in
the
robots
hand,
and
you
say
please
draw
something
for
me
and
then
kind
of
crucially
important.
You
know
it
actually
draws
what
you
ask
it
to,
and
so
now
you
can
actually
have
a
physical
pen
and
paper
artifact
of
your
generative,
algorithm
and
I
think
that
this
physical
pen,
plotter
medium,
actually
allows
for
even
more
emergence
than
then
software
does,
because
there
are
more
variables
that
you
don't
have
complete
control
over.
A
For
example,
a
pen
doesn't
draw
a
perfect
euclidean
lines
with
zero
area.
Different
pens
have
different
widths,
they
have
different
colors,
a
ballpoint
pen
is
going
to
draw
a
different
line
from
a
fountain
pen.
Is
gonna
draw
a
different
line
from
a
marker.
It's
gonna
be
different
from
a
gel
pen
and
ink
bleeds,
and
so
you
have
to
kind
of
grapple
with
that,
or
maybe
you
can
purposely
move
your
pen
even
slower
to
get
more
bleeding
and
kind
of
use
that
as
an
artistic
effect,
colors
combine
just
like
the
ways
you
can
combine.
A
Glazes,
and
maybe
you
draw
a
blue
line
on
a
yellow
line,
and
now
you
have
a
unique
green
that
you
don't
have
any
marker
to
draw.
The
only
way
to
get
that
is
through
combination,
I,
think
that
this
piece
by
Paul
Records
really
takes
advantage
of
the
medium
superbly,
the
way
that
the
rectangles
overlap
and
the
colors
combine
kind
of
suggests
a
transparency
and
a
depth
kind
of
like
a
third
dimension
that
doesn't
really
exist
in
the
code.
A
That
only
comes
out
once
you
put
it
on
paper
and
this
physicality
of
the
pen
of
the
pen
plotter
medium.
This
is
what
I
was
missing
from
generative
art
in
general,
and
so
at
this
point,
I'm
hooked
and
I
make
my
decision.
I
want
to
make
algorithmic
art
and
I
want
to
bring
it
into
the
physical
world
with
a
pen
plotter,
so
I
bought
an
ACCI
draw,
which
is
a
popular
pen
plotter
these
days.
But
at
this
point,
I
have
a
whole
lot
more
excitement
than
I.
Have
knowledge.
A
Svg
talks
about
shapes
and
paths,
and
these
shapes
and
paths
are
described
within
an
abstract,
coordinate
space
and
what
the
pen
plotter
can
actually
do
is
it
can
scale
that
coordinate
space
up
and
down
to
the
size
of
the
paper
that
it's
drawing
on
or
the
size
of
the
drawing
that
you're
making,
and
then
it
will
draw
those
scaled
shapes
and
paths.
So
how
many
people
here
know
HTML
or
XML
all
right?
Everybody,
that's
awesome!
So,
as
you
can
see,
SVG
is
also
a
text
format
that
features
many
pointy
brackets.
A
So
if
you
search
crates
I/o
for
SVG,
the
first
hit
is
the
SVG
crate
and
that's
what's
used
here.
It
gives
you
this
really
nice
builder
style,
API
for
kind
of
describing
and
composing
SVG
elements,
and
you
can
get
surprisingly
far
using
just
the
SVG
crate.
So
what
this
is
doing
is
it's
actually
drawing
a
triangle,
and
the
data
is
a
sequence
of
strokes
in
the
coordinate
space,
and
this
is
ultimately
what
controls
the
pen.
So
it
says
you
know,
move
to
this
point
and
then
draw
a
line
to
that
point,
etc.
A
The
path
element
is
sort
of
like
the
styles
for
the
strokes.
So
what
this
is
saying
is
that
these
strokes
should
be
thick
and
they
should
be
blue
and
then
the
area
that's
inside
should
be
filled
in
pink
and
then.
Finally,
the
document
is
sort
of
the
whole
SVG
image
and
describes
what
kind
of
box
in
that
coordinate
space
is
ultimately
rendered
as
the
image
now
to
get
the
SVG
from
you
know.
A
Your
computer
to
the
EXCI
draw
I
use
this
tool
called
saxy,
and
it
gives
you
this
really
nice
web
front-end
for
kind
of
controlling
the
Pens
up
and
down
height
and
kind
of
centering
on
the
page
and
I
can't
recommend
it
highly
enough
if
you're
using
an
actually
draw
use,
saxy
and
so
here's
the
results
of
of
rendering
it
on
the
left.
That's
a
software
rendering
of
triangle
SVG
and
on
the
right.
A
This
is
a
photograph
of
triangle
SVG
as
drawn
by
the
pen
plotter
with
gel
pen
on
black
paper,
and
so
we
said
that
these
lines
should
be
thick
and
they
should
be
blue
and
that
the
inside
should
be
filled
pink
and
yes,
the
software
renderer
did
that.
But
the
pen
plotter
can't
because
it
can
only
draw
with
the
color
of
the
pen
that
you
gave
it
and
it
basically
ignores
any
sort
of
fill
so
now
that
I
can
generate
SVG's
and
I
can
plot
SVG's,
I
kind
of
set
an
exercise
for
myself.
A
How
many
different
ways
could
I
fill
a
rectangle
with
interesting
pattern
of
strokes
where
I
parameter?
I
parameterize
this
fill
by
like
a
darkness
value
where
a
zero
darkness
value
means
basically
empty.
There's
no
strokes
in
there
and
a
one
darkness
value
means
it's
completely
full
and
there's
just
strokes
covering
the
whole
thing.
So
basically,
how
many
implementations
of
this
trait
could
I
make
here
are
a
few
of
the
results.
A
So
this
is
rectangle
eight
with
darkness
values,
0.1
0.5
and
0.9,
and
the
algorithm
to
generate
rectangle
eight
is
to
move
some
distance
D
along
each
of
those
outer
edges
of
the
rectangle.
And
so
now
you
have
four
points
and
you
connect
those
points
by
into
a
new
quadrilateral,
and
then
you
continue
recursively
on
that
new
quadrilateral.
Until
basically,
everything
meets
up
in
the
center.
A
This
is
rectangle,
and
the
algorithm
for
rectangle
is
to
choose
a
random
point
within
the
rectangle
and
then
start
generating
boxes
outwards
until
it
meets
the
corners
of
the
outer
rectangle.
And
so,
if
you
have
like
a
lower
darkness
value,
you'll
get
fewer
boxes
that
are
kind
of
spaced
a
little
bit
further
apart
and
you
do
a
higher
darkness
value.
A
So
here's
a
photo
of
that
same
image
as
drawn
by
the
pen
plotter
with
black
ballpoint
pen
on
white
paper
after
plotting
I
was
kind
of
hit
with
another
surprise,
which
is
that
the
lines
drawn
by
the
pen
were
much
thicker
and
darker
than
the
lines
drawn
by
the
software
renderer.
And
so
it
doesn't
really
look.
You
know
like
stained
glass,
so
much
anymore.
A
Often
the
hardest
part
is
exterior
at
a
blank
canvas
and
simultaneously
having
an
infinite
number
of
options
of
things
that
you
could
do,
but
also
not
even
knowing
what
those
infinite
things
are
and
I
think
the
best
thing
to
do
in
this
situation
is
to
completely
sidestep
the
problem
by
defining
some
set
of
constraints
and
then
as
an
exercise,
fulfilling
that
those
constraints
in
as
many
ways
as
you
possibly
can.
So
how
many
ways
can
you
fill
a
rectangle?
How
many
ways
can
you
create
a
custom
brushstroke
that
follows
a
given
path?
A
How
many
ways
can
you
visualize
Perlin
noise,
which
is
a
noise
that
gives
you
smooth
gradients
of
values
instead
of
just
random
values?
How
many
different
kinds
of
random
Walker's?
Can
you
create
that
move
through
your
coordinate
space
and
interesting
ways?
Maybe
one
is
a
particle
with
random
force
applied
to
it?
Maybe
another
is
a
pendulum
that
swings,
but
then
randomly
chooses
to
swing
from
the
other
side
and
it
moves
around
and
then
once
you
have
these
kind
of
base
things,
how
can
you
combine
them
in
interesting
ways?
A
Can
you
tile
the
rectangles
and
then
vary
the
darkness
value
in
interesting
ways?
Can
you
take
the
path
drawn
by
one
of
your
random,
walkers
and
feed
that
into
one
of
your
custom
brushstrokes?
The
other
thing
that
I
think
I
really
took
away
from
this
is
that
you
don't
need
much
to
start
making
plotter
art.
You
don't
need
to
learn
a
big
framework
like
processing
or
p5.js,
or
nanou
or
open
frameworks.
A
You
can
just
start
doing
this
stuff
now,
and
so
these
first
pieces
were
made
with
just
the
SVG
crate
and
SVG
is
already
a
pretty
rich
language
for
making
drawings
and
I
mentioned
this.
Because
learning
new
frameworks
can
be
intimidating,
they
tend
to
have
wide
API
surfaces
and
many
concepts
to
learn,
and
sometimes
the
best
way
to
start
something
is
to
just
hit
the
ground
running
and
then
later,
once
you
have
a
problem
that
a
framework
can
solve
for
you.
Maybe
that's
the
time
to
reach
for
the
framework
right.
A
And
so,
when
you
start
running
into
these
sorts
of
problems
like
now
is
the
time
to
reach
for
a
library
that
helps
you
out
or
to
find
a
framework
that
that
will
do
this
stuff
for
you
or
you
can
create
your
own
personal
framework,
like
I,
did
I
started
digging
into
the
rabbit
hole
of
computational
geometry
and
kind
of
collecting.
My
utilities,
together
and
I
named
this
set
of
crates
fits
Jen's
art,
but
you
know
as
a
name
fit
shins
are
it
was
really
just
too
bloated
and
so
to
release
some
of
that
pressure.
A
A
What
I
really
like
about
this
photo
is
the
way
that
there's
these
kind
of
zones
of
crystals
that
fit
together
and
there's
these
kind
of
lines
radiating
out
from
their
centers
that
almost
look
like
exploding
fireworks
and
they
have
this
kind
of
colorful
pinwheel
effect
going
on
I
think
this
is
really
quite
cool
and
very
inspiring,
and
so
I
would
like
to
make
you
know
some
plotter
art.
That's
inspired
by
crystal
microscopy
like
this,
and
these
zones
really
remind
me
of
Voronoi
diagrams.
A
So
we
can
use
this
understanding
of
Voronoi
diagrams
to
actually
design
an
algorithm
for
generating
crystal
inspired
art,
and
so
what
I
came
up
with?
Is
this
choose
endpoints
to
be
your
seeds
and
then
for
many
more
n
random
points
for
each
of
those
find
which
seed
is
closest
to
it
and
then
draw
a
line
to
it,
and
the
hope
is
that
these
lines
are
going
to
create
that
sort
of
exploding,
fireworks,
aesthetic,
and
so
this
simple
algorithm
actually
works
pretty
well.
A
Here
it
is
plotted
on
black
paper
with
white
gel
pen
and
already
I
can
see
the
resemblance
right.
I
can
see
the
zones
I
can
see
the
fireworks.
The
only
difference
from
the
algorithm
that
was
just
presented
is
that
these
lines
going
all
the
way
to
the
seed
there
kind
of
stopping
partway,
just
to
give
it
a
little
bit
more
breathing
room
and
be
a
little
less
crowded,
and
next
I
wanted
to
get
more
crystals
of
varying
sizes.
A
You
know
smaller
and
big
ones,
and
so
my
idea
for
that
was
like
what,
if
I
assigned
each
of
these
crystals
or
each
of
the
seeds,
a
gravity
level
and
well,
it
didn't
really
come
out
at
all
how
I
intended,
but
you
know,
I,
think
it
looks
kind
of
cool
it
really
doubled
down
on
maybe
the
explosion
style.
So
you
know,
ultimately
it's
a
happy
little
accident
at
the
other
thing.
A
This
is
another
variation
where
now
we're
only
choosing
points
from
within
a
circle,
and
maybe
it
looks
like
a
contaminated
petri
dish,
but
I
think
maybe
this
is
my
favorite
of
the
series.
So
it's
kind
of
cool
and
this
final
variation
is
using
colors
for
that
pinwheel
effect
directly
and
and
so
the
AXI
draw
can
only
hold
a
single
pen
with
a
single
color
right
and
so
to
plot.
This
I
had
to
actually
split
out
each
of
those
colors
into
different
SVG
layers
and
then
in
between
plotting.
Each
of
those
layers.
A
So
is
this
kind
of
famous
saying
that
good
artists
copy,
but
great
artists,
steal
and
since
I'm
really
new
at
this
I'm
happy
to
aim
for
just
good
but
I
think.
The
lesson
here
is
to
find
inspiration
in
something
and
then
copy
it.
And
you
know
maybe
that
something
is
somebody
else's
plot
or
art,
that
you
want
to
learn
how
it
works,
or
maybe
it's
some
vintage
1960s
plotter
art
that
you
want
to
bring
into
the
modern
era.
A
Or
maybe
it's
translating
something:
that's
completely
unrelated
to
computers
and
to
plotters
into
the
plotter
medium,
for
example.
Maybe
the
patterns
of
cracks
on
the
glaze
of
some
pottery
piece
that
you
really
like,
or
maybe
it's
the
way
that
plants
and
flowers
and
leaves
kind
of
grow
at
this
in
this
mathematical
way.
A
A
Looking
for
the
unexpected
I'm
trying
to
be
surprised
and
so
I
don't
actually
know
what
it
is,
that
I
should
be
encoding
into
the
type
system
yet
because
I
haven't
found
it
yet,
and
so
what's
really
happening
is
that
there's
this
feedback
loop
where
I
generate
some
SPG's
and
then
I?
Look
at
the
SVG's
and
I
say:
oh,
this
is
cool.
Oh,
that's,
not
cool
I
go
back
and
I
tweak
the
program
and
I
look
at
the
new
SVG's
and
I
go
oh
yeah!
A
A
So
luckily,
this
nice
person,
Benjamin
wrote
an
article
about
what
kind
of
tooling
and
infrastructure
you
might
want
when
you're
doing
generative
art
and
lays
out.
You
know
how
to
solve
a
bunch
of
problems,
including
this
kind
of
instant
feedback
problem
and
his
advice
is
use
a
file
watcher
and
whenever
you
change
any
source
file
in
your
project,
automatically
recompile
the
project
automatically
rerun
it
and
generate
a
new
image
and
if
it
compiled
okay
and
it
generated
a
new
SVG
image.
A
Okay,
then
actually
save
that
image
in
your
repository
and
make
a
git
commit
like
just
automatically,
and
so
this
way
you
never
lose
any
image
that
you
will
ever
generate,
and
you
have
exactly
the
code
that
generated
that
image.
So
maybe
you're
riffing
on
one
idea
right
now.
You
can
always
go
back
at
a
later
time
and
riff
on
a
completely
different
idea,
and
this
is
like
exactly
the
kind
of
thing
that
you
cannot
do
with
pottery,
so
I
implemented
a
command
line,
tool
for
the
farc
framework
and
I
really
enjoy.
A
You
know,
saving
all
of
these
images
and
stuff,
and
it
did
speed
up
my
feedback
loop
a
little
bit,
but
it
really
didn't
solve
the
problem.
This
doesn't
look
that
different
from
the
last
version
with
a
feedback
loop,
and
so
it's
like
yeah
I'm,
not
manually,
kicking
off,
compiles
and
I'm,
not
manually
running
the
program,
but
I
am
still
waiting
on
those
compiles
to
finish
in
this
language.
That's
kind
of
infamous
for
not
having
great
compiled
time
straight
and
I'm
still
doing
all
this
context.
A
Switching
with
this
alt
tabbing
back
and
forth
and
I'm
still
refreshing
manually,
so
I
actually
wanted
to
dig
into
like
what
kinds
of
commits
am
I
actually
making,
and
so
I
looked
at
a
random
sample
of
commits
from
one
of
my
projects
that
was
using
the
file
watcher
tool.
I
went
through
each
of
those
commits
and
I
categorized.
What
kind
of
change
was
that
making
and
it
fell
into
just
three
buckets
algorithmic
changes?
A
Are
you
know,
sort
of
the
beefier
changes,
things
that
are
changing
loops
or
introducing
if
else's,
and
these
sorts
of
things
constant
changes
are
me
saying
I'm
using
this
normal
distribution
that
I'm
sampling
random
numbers
from
what?
If
the
standard
deviation
was
0.5
instead
of
0.6?
How
would
that
affect
the
image
and
formatting
changes?
A
Are
me
running
rust
format
essentially-
and
you
know,
I
kind
of
knew
deep
down,
but
to
to
have
empirical
evidence
that
I'm
spending
the
majority
of
my
time,
like
sixty
percent
of
my
time,
waiting
on
compiles
to
change
five
into
seven,
like
it
kind
of
blows
my
mind.
So
what
I
really
wanted
was
some
way
to
have
constant
values
in
my
program
that
I
could
actually
change
in
between
runs
of
the
program
without
recompiling
the
program,
so
I
invented
this
brand
new
thing,
which
I
call
user
constants.
A
It
creates
a
form
input
dynamically
in
the
web,
UI,
which
is
kind
of
what's
on
the
left
here,
and
you
can
actually
go
into
that
form,
input
and
tweak
the
constant
value-
and
this
is
gonna-
create
a
post
request
from
the
web
UI
to
the
local
server.
The
local
server
is
going
to
update
the
environment.
Variable
it's
going
to
rerun
the
program
to
generate
a
new
SVG
and
then
the
local
server
is
going
to
send
that
new
SVG
back
to
the
web,
UI,
where
the
preview
is
refreshed
automatically.
A
Additionally,
I
discovered
this
simple,
effective
thing
that
some
people
call
window
management
yeah.
So
now,
I'm
actually
running
a
split
screen
with
Emacs
on
one
side
and
the
web
UI
on
the
other
side,
and
so
I.
Don't
need
to
do
all
this
context,
switching
anymore,
because
I,
just
kind
of
have
everything
at
my
fingertips
now
and
and
so
for
constant
tweaking,
which
were
60%
of
my
changes
right.
A
The
critical
path
for
my
feedback
loop
is
now
just
edit,
the
constant
and
then
essentially
look
at
what
the
images
that's
updated
and
like
technically,
yes,
I
do
need
to
rerun
the
program,
but
it
happens
automatically
for
me
and
I'm
not
waiting
around
for
the
program
to
finish
running
all
right.
This
is
rust
unless
we
were
doing
something,
you
know
pretty
bad,
it
should
be
pretty
quick
and
so
the
previous
screenshot.
It
says
it
took
less
than
10
milliseconds
to
generate
that
image,
which
is
really
just
barely
human
perceptible.
A
So,
finally,
my
feedback
loop
is
near
instantaneous
and
as
a
results,
I'm
able
to
explore
more
ideas
faster
than
I
previously
could
and
that's
helping
me
make
new
pieces
that
I'm
increasingly
happy
with
such
as
this
one
and
at
the
end
of
the
day,
I
have
a
hobby.
That
is
not
work,
something
that's
just
for
me
and
I'm
having
fun
making
algorithmic
art
with
rust
and
bringing
it
into
the
physical
world
with
a
pin,
plotter
I
hope.
A
My
story
has
inspired
some
of
you
to
try
your
hand
at
plotter,
art
or
generative
art
in
general,
or
maybe
even
pick
up
pottery
but
I.
Think
a
lot
of
these
takeaways
are
kind
of
generally
applicable,
not
just
to
artistic
programming
but
professional
programming
and
maybe
even
other
domains
as
well.
You
know:
can
you
define
constraints
for
yourself
to
make
a
problem
smaller
or
easier
to
solve?
Can
you
break
something
down
into
pieces?
A
If
you
want
to
learn
something,
try
copying
it
if
you
want
to
bring
fresh
new
ideas
into
your
domain
copy,
something
from
another
domain,
and
if
you
want
to
boost
your
efficiency,
you
should
treat
your
iteration
time
actually
as
an
optimization
problem,
and
you
should
profile
and
gather
empirical
evidence
about
what
you're
doing
and
what
you're
waiting
on.
And
then
you
should
customize
your
tools
or
even
build
your
own
custom
tooling,
to
make
that
faster.