►
Description
This talk is about how Rust can help you write fast, correct scientific software. We'll investigate what makes Rust a viable alternative to the the conventional choices of Python and C++ but will also take a look at the challenges and potential downsides of choosing Rust for your next project.
More at https://rustfest.global/session/6-considering-rust-for-scientific-software/
A
B
B
So
scientific
software
is
sort
of
an
interesting
case
where
you
have
these
very
strict
requirements,
but
oftentimes
it's
written
by
a
very
small
team,
maybe
even
one
person
or
a
couple
people,
and
they
have
very
limited
time
and
resources
because
usually
they
have
other
commitments,
maybe
they're
professors
or
students
or
researchers,
and
this
is
actually
a
case
where
correctness
of
the
software
is
very
important.
B
So
it's
it's
possible
that
scientific
papers
will
be
published
based
on
the
results
and
it's
important
more
so
than
in
other
fields,
that
we
try
and
make
sure
our
programs
are
as
bug-free
as
possible,
especially
when
sort
of
research
is
sort
of
on
the
line
based
on
these
results.
B
B
B
I
think
we
need
to
combat,
especially
when
we
build
our
own
software
for
people
to
use
so
working
in
the
radiation
field
and
sort
of
going
to
engineering
school.
There's
the
standard
case,
study
of
the
therac-25
and
and
sort
of
the
the
issues
with
it.
So
the
therap-25
was
a
radiation
therapy
device
manufactured
by
atomic
energy
of
canada
limited,
and
it
was
part
of
six
major
accidents
between
1985
and
1987,
and
I
don't
want
to
minimize
the
issues
with
this
project.
B
So
there
were
a
number
of
sort
of
complex
factors
that
went
into
the
problems
that
the
therap-25
had.
You
know
there
were
management
issues
or
you
know,
project
oversight,
issues
and
allegedly
there
was
only
one
developer:
who
did
the
entire
software
for
this
machine,
but
also
investigators
did
find
that
data,
races
or
concurrency
bugs
in
the
thera-25
control
software
contributed
to
the
accidents,
and
I
think
this
just
goes
to
show
a
little
bit
that
software
bugs
do
have
real
world
consequences.
B
And
usually
it's
not
this
serious.
You
know,
maybe
we
just
have
to
rerun
our
our
code
to
do
another
analysis
job,
but
it
is
the
case
that
software
does
affect
real
people
and
we
have
to
be
careful
to
try
and
avoid
bugs
as
much
as
possible.
B
But
this
also
brings
some
problems
because
python
is
actually
usually
quite
slow
of
a
language,
and
this
is
so
when
people
need
performance,
they
start
to
reach
for
languages
like
c
and
c
plus,
and
these
are
sort
of
the
bedrock
systems,
programming,
languages
that
support
python,
and
here
I'm
sort
of
skipping
over
a
lot
of
other
languages.
So
for
things
written
in
fortran
and
julia,
I
think
all
these
languages
are
very
important
and
they
definitely
have
their
place,
but
I'm
not
going
to
talk
about
them
specifically
here.
B
So
an
issue
I
have
with
the
current
landscape
of
of
sort
of
scientific
computing
is
that
moving
from
python,
which
is
a
lot
of
people's
first
language
to
something
like
c
plus
plus,
which
is
you
know,
sort
of
a
more
performance,
oriented,
expert
level,
programming
language.
B
This
should
be
a
natural
step,
because
many
popular
python
libraries
depend
on
c
plus
plus
as
sort
of
a
back
end.
Language
and
they're,
actually
written
mostly
in
c
plus,
plus
and
sort
of
wrapped
up
nicely
in
python,
for
people
to
use
and
researcher
time
is
usually
very
precious.
So
a
lot
of
people
want
to
know
how
to
speed
up
their
code
or
get
better
performance,
and
sometimes
this
is
actually
a
very
difficult
thing
to
do
in
python.
It's
necessary
to
move
to
another
language
like
c
plus
plus,
but
unfortunately,
right
now.
B
This
is
a
very
difficult
transition
step
and
you
know
there's
a
lot
of
factors
going
on
here
and
you
know
the
two
languages
are
very
different,
have
different
goals,
but
it
is
a
problem
because
you
know
I've
definitely
seen
people
leave
projects
because
they
don't
feel
they're
they're
up
to
the
task,
or
maybe
they
just
abandon
their
efforts
and
and
sort
of
keep
using
python.
B
And
I
think
here
rust
really
starts
to
shine
as
a
viable
alternative
to
c
plus
plus,
because
you
can
achieve
the
same
or
very
similar
performance,
but
with
a
kinder
sort
of
more
gentle
systems,
programming,
language
explicitly
designed
for
non-expert
users
and
that's
what
a
lot
of
scientific
software
developers
identify.
As
so.
I
think
it's
sort
of
a
very
important
use
case
or
possibility
for
rust,
as
is
sort
of
an
alternative,
back-end
implementation
language
to
achieve
certain
performance
goals,
and
then,
of
course,
you
know
right
away.
B
There
are
maybe
some
reasons
not
to
use
rust.
So,
given
the
comparative
age
of
all
the
languages,
rust
is
relatively
young.
It's
only
five
years
old
or
you
know
it's
been
five
years
since
its
1.0
release
and
python
is
actually
around
30
years
old
and
c,
plus
plus,
is
around
40.,
and
it's
likely
they're
going
to
be
around
for
a
lot
longer
as
well.
B
B
Ways
of
doing
things
and
sort
of
more
into
sort
of
a
correct
way
of
doing
things,
and
especially
for
beginners.
I
think
this
is
very
helpful,
so
I
know
that
you
know
the
first
few
months
of
my
writing
c,
plus
plus
it
certainly
wasn't
very
good
and
I
was
making
all
sorts
of
sort
of
out
of
bounds,
errors
and
and
other
issues
that
just
wouldn't
happen
and
rust.
B
Another
issue,
of
course,
is
that
you
already
have
a
large
code
base
written
in
another
language
and
the
the
saying
is
that
you
know
a
lot
of
times.
The
the
right
tool
for
the
job
is
the
one
you're
already
using,
and
I
think
this
is
definitely
the
case,
and
I
don't
think
that
people
should
be
rewriting
their
projects
completely,
but
I
would
say
you
know,
maybe,
if
there's,
if
there's
a
new
component
and
you're
sort
of
looking
for
an
alternative
language,
I
think
rust
is
a
really
good
choice
for
this.
B
Another
point
might
be
that
there
is
an
important
library
that
you
depend
on.
That's
actually
missing
on
the
rest
side
of
things,
and
you
know
this
is
definitely
a
valid
concern.
Rust's
ecosystem
is
smaller
than
that
of
python.
Of
course,
python's
is
enormous
and
that
of
c
plus
plus,
just
because
it's
younger,
but
there
are
ways
to
access
python
and
c
plus
plus
code
in
rest
as
well
and
finally
have
things
like
concerns
about
a
single
vendor.
B
B
I
want
to
write
the
fastest
code
I
can
with
as
few
bugs
as
possible,
and
I
sort
of
want
both
those
things
at
once
and
it's
a
bit
of
a
vague
goal,
but
rust
here
really
helps
me,
because
entire
classes
of
bugs
are
eliminated
compared
to
another
sort
of
unsafe
systems.
Programming,
language-
and
this
means
I
can
actually
focus
my
time
on
developing
a
better
algorithm
or
actually
doing
some
other
work
and
not
having
to
worry
about
bugs
as
much
as
I
would
in
another
language.
A
B
So
I
think
in
some
regards
c
plus
really
cares
about
its
expert
developers
and
rust
does
too,
but
it
also
spends
a
lot
of
time
making
sure
that
the
languages
is
sort
of
suitable
for
for
non-expert
programmers,
which
is
often
the
case
for
scientific
researchers
who
may
not
identify
as
experts
and
finally,
there's
built-in
documentation
and
testing,
and
this
is
sort
of
an
area
where
I
don't
really
want
to
spend
any
time
sort
of
wrangling
external
tools
or
you
know,
fixing
issues
with
them
and
also
having
sort
of
an
integrated
package
manager
and
rust
as
a
game
changer,
because
personally,
I
consider
time
spent
writing
build
system
code
to
sort
of
be
a
necessary
evil,
and
I
want
to
minimize
as
much
as
possible
so
rust's
sort
of
first
class
dependency
management
is
is
really
important
to
me
and
it
sort
of
it
lets
me
do
focus
my
time
on
more
important
things.
B
So
sort
of
jumping
right
in
just
to
some
of
the
rest
features.
I
find
very
useful
for
writing
numerical
code.
I
just
want
to
sort
of
preface
this
by
saying
that
more
than
one
feature,
I
think
it's
the
sum
total
of
these
features,
which
is
important,
so
you
can
sort.
A
B
B
So
right
off
the
bat
we
have
no
implicit
conversions
between
primitive
types
and
so
at
the
top
here,
we're
actually
trying
to
divide
two
integers
and
get
a
floating
point
number
out
and
rust
is
stopping
us
and
saying
actually
there's
mismatched
types
here
and
we
expected
a
floating
point
number
f64,
but
we
found
integers-
and
this
is
a
very
common
beginner
mistake
and
it's
nice
that
it's
caught
right
away
here
and
you
know,
having
you
know,
it's
not
the
most
complex
bug,
but
having
it
caught
and
sort
of
addressed
right
away
is,
is
a
big
deal.
B
So
this
can.
This
can
be
a
little
bit
noisy.
Sometimes
so
here
we're
trying
to
convert
between
a
32-bit,
unsigned,
integer
and
convert
it
into
the
platform's
size
of
integer
and
rust
is
is
not
happy
here
either
because
it
wants
us
to
do
an
explicit
conversion
where
we
try
and
we
try
and
convert
the
number.
B
So
having
these
things,
sort
of
caught
up
front
is
really
important,
because
the
more
things
that
you
catch
and
compile
time,
the
less
you
have
to
worry
about
at
runtime,
and
this
is
sort
of
a
theme
within
rust
and
it's
something
that
the
type
system
really
helps
with.
B
So
as
much
as
possible,
it's
not
going
to
let
you
do
unsafe
operations
and
oftentimes
the
convenient
thing
or
the
thing
that
people
default
to
is
is
the
safe
method,
and
there
are
ways
of
you
know
saying
you
know.
I
actually
know
what
I'm
doing
here.
I
want
to
do
this
thing
specifically,
but
for
the
most
part
safe
defaults
are,
I
think,
a
good
choice,
especially
for
beginners.
B
B
The
element
is,
is
sort
of
the
safe
default
way,
and
we
see
here
that
we
actually
get
a
panic
which
is
sort
of
like
rust's
way
of
you
know,
winding
down
the
system
and
stopping
everything
and
exiting
so
we
have
a
panic,
and
it
says
you
know
the
the
length
of
this
vector
is
three,
but
we
try
to
get
the
tenth
element.
So,
of
course,
this
is
a
bug,
but
you
know
right
now:
a
lot
of
performance
irritated
developers
are
saying.
B
B
You
know
we
can
do
the
sort
of
the
quick
or
maybe
the
performance
oriented
thing,
but
we
have
to
tell
people
that
we're
doing
it
and
rust's
way
of
doing
this
is
using
these
unsafe
blocks.
If
there's
a
potentially
memory
unsafe
operation
going
on.
So
it's
the
same
same
sort
of
examples.
We
have
a
vector
with
three
elements
and
we're
trying
to
get
the
tenth
one,
but
right
away,
it's
a
lot
noisier.
So
we
have
this
unsafe
block
which
says:
okay,
something
unsafe
is
potentially
happening
here.
B
You
know
it's
it's
sort
of
the
programmer's
way
of
saying:
okay
compiler,
you
know
get
out
of
my
way.
B
I
really
want
to
do
this,
but
for
people
reviewing
your
code,
it's
very
helpful
because
you
can
right
away,
go
to
the
unsafe
block
and
and
sort
of
the
reviewing
cost
or
the
surface
area
of
your
review
is
shrunk
because
a
lot
of
times
you
just
look
at
the
unsafe
blocks
and
see
if
they're,
okay
and
here,
of
course,
this
is
not
okay,
so
we're
trying
to
get
the
tenth
element
of
a
vector
with
only
three
and
of
course
this
is
going
to
give
us
a
garbage
answer
and
rest
documentation
does
a
really
good
job
of
saying.
B
You
know
this
is
actually
not
recommended
and
use
it
with
caution,
and
this
is
you
know
this.
This
unsafe
block
is
sort
of
the
visual
equivalent
of
that.
It's
saying
you
know
something
potentially
dangerous
is
happening
here
and
just
be
extra
careful
when
you're
using
it
and
having
this.
This
opt-in
low-level
control
is
what
sets
rust
apart
from
a
lot
of
other
memory,
safe
languages,
because
a
lot
of
times,
you
really
do
know
what
you're
doing
and
rust
will
say.
B
You
know
go
ahead,
no
problem
but,
like
I
said,
the
the
unsafe
block
is
sort
of
very
helpful
here,
because
it
it
reduces
the
the
onus
on
on
a
code
reviewer
or
yourself
to
look
at
where
potentially
dangerous
things
are
happening,
and
I
think
another
another
feature
of
rust.
That
really
sort
of
is
is
good
for
numerical.
B
Programmers,
especially,
is
that
floating
point
numbers
are
treated
with
a
lot
of
caution,
and
you
know
there
are
entire
books
written
on
handling
floating
point
numbers
correctly,
and
I
think
this
is
the
right
choice
in
a
lot
of
cases.
So
here
we
have
some
potentially
surprising
code
where
we're
adding
0.1
to
itself
three
times
and
if
that's
equal
to
0.3
we're
going
to
print
out,
you
know
got
0.3,
but
otherwise
we're
going
to
print
got
something
else,
and
so
this
is
a
bit
of
a
common
beginner
mistake.
B
B
In
warning
us
and
saying
that
floating
point
types
can't
be
used
in
patterns,
because
this
is
not
a
very
good
way
of
doing
things
and
there's
better
ways
of
of
achieving
the
same
result,
and
this
this
warning
in
particular,
is
actually
going
to
be
an
error
in
later
versions
of
the
compiler,
and
this
is
this
is
sort
of
a
bug
where
it's
it's
may
not
be
obvious
right
away,
but
having
it
caught
at
compile
time
is,
is
a
big
deal,
and
so
sometimes
this
can
be
a
little
bit
annoying.
B
So
the
sort
of
default
way
of
sorting
floating
point
numbers
doesn't
actually
work.
So,
if
you're
trying
to
sort
this
vector
of
floating
point
numbers,
you'll
come
up
with
an
error
that
says
that
there's
a
trait
bound,
that's
not
satisfied
and
I'm
sure
there's
a
good
reason
for
this,
and
you
know
generally
the
reason
is
that
not
a
number
or
you
know
the
infinity
values
might
be
tricky
to
have
a
total
ordering,
because
you
know
the
nand
or
not.
A
number
value
is
not
actually
equal
to
itself.
B
So
there's
all
sorts
of
little
celsius
here
and,
of
course,
you
can
sort
floating
point
numbers
and
rust.
There's
a
you
know,
there's
this
sort
of
standard
way
of
doing
it
and
it's
in
the
rest
cookbook
as
well,
but
myself
personally,
I
do
prefer
you
know
if
I
have
to
do
a
little
bit
more
code
at
the
source
and
which
saves
me
from
bugs
later
on.
B
This
is
a
trade-off
that
I'm
comfortable
making
and
I'd
like
to
make
in
my
code,
but
another
thing
that
that
rust
does
really
well
is
actually
it's
quite
a
good
prototyping
language
or
debugging
language,
especially
given
that
it's
also
a
low-level
programming
language.
So
here
we
have
a
custom
data
structure,
called
cool
data
and
we
have
these
vectors
of
floating
point
numbers
in
it,
but
we
also
you
know
when
you're,
when
you're
writing
code
and
prototyping,
you
really
want
to
print
out
the
value
of
your
your
data,
often
and
sort
of
see.
B
B
We
can
add
this
one
line
to
our
code
and
it
says
essentially
give
me
a
debug
representation
of
my
structure
and
then
we
can
call
this
debug
method
and
have
printed
out
a
really
nice
representation
of
our
data,
and
this
is
great
for
prototyping,
because
you
know
I
just
want
to
see
what's
happening
and
I
want
to
start
a
step
through
my
code
and
it's
a
very
useful
thing
and
I'm
using
this
all
the
time.
B
C
B
B
B
And
you
know,
without
any
external
tools,
we
can
write
a
unit
test
and
check
it
right
away,
and
you
know
this
really
removes
a
lot
of
the
friction
around
testing,
especially
compared
to
other
languages
where
you
might
need
an
external
framework
and
removing
friction
means
that
people
are
going
to
do
it
a
lot
more
and
it's
it's
sort
of
an
easier
tool
to
do,
and
I
find
myself
writing
unit
tests
a
lot
more
frequently
in
rest
than
I
would
in
another
language,
like
c
plus,
where
it's
a
little
more
tricky
and
I
think
in
particular
documentation
tests
are
really
a
killer
feature
for
scientific
code
because
a
lot
of
scientific
code.
B
You
need
a
lot
of
examples,
and
this
is
a
way
to
make
sure
your
examples
continue
to
compile.
Even
if
you
change
your
code,
so
here
we
have
some
documentation
test
where
it's
it's
sort
of
the
same
examples
before,
but
this
will
actually
be
published
as
part
of
our
documentation
and
having
this
ability
to
write
example,
code
and
but
also
use
it
as
documentation
is
sort
of
is
a
really
big
deal
because
you
can.
B
You
can
really
do
two
things
at
once,
and
this
will
also
ensure
that
your
example
code
doesn't
go
out
of
date,
which
can
be
a
big
deal
if
you're
refactoring
your
your
project,
so
sort
of
taking
together
rus
safety
guarantees
and
the
fundamentals
of
the
language
have
a
large
qualitative
impact
on
what
kind
of
code
we're
capable
of
writing,
and
I'm
just
going
to
use
the
example
of
of
data
races
or
these
sort
of
concurrency
issues
in
multi-threaded
code.
B
B
And
so
the
thing
that
sets
rust
apart
is
that
software
engineering,
best
practices
are
built
into
language
and
core
tools,
and
I
think
that
choosing
rust
is
going
to
have
the
biggest
impact
on
small
resource
constrained.
Teams
who
don't
identify
as
expert
software
developers
and
rus
place
in
scientific
computing
is
a
language
with
the
speed
and
power
of
c
plus
plus,
but
it's
also
a
systems
language
explicitly
designed
for
non-experts,
and
it's
designed
to
lower
barriers.
B
C
We
have
a
couple
question
and,
for
example,
here:
what
do
you
think
about
saiton
as
a
natural
net
step?
Do
speed
up
python
code.
B
Yeah,
so
I
think
I
think
there
are
definitely
a
lot
of
alternatives
here.
Personally,
I
haven't
really
done
a
lot
of
psython
myself,
but
I
think
it's
not
you
know
having
having
the
rust
ecosystem
is
also
a
really
important
thing
and
having
sort
of
these
examples
of
different
ways
to
do
things
or
or
being
able
to
pull
a
lot
of
dependencies
into
your
project
and
and
sort
of
experiment
with
them.
B
Yeah,
so
I've
definitely
played
around
a
bit
with
the
pi
03
project
or,
I
think
the
pi
oxide
project,
and
so
this
is
a
really
nice
way
you
can,
you
can
do
a
you,
can
integrate
rust
into
into
python
just
by
exposing
it
as
sort
of
a
python
module,
or
you
could
also
use
the
python
code
in
rust
as
well.
C
Okay,
well,
we
don't
have
more
time,
I'm
sorry,
but
we.