►
From YouTube: RustFest Rome 2018 - Adam Kelly: Rust, For Science!
Description
Rust seems like a perfect candidate for scientific computing, building fast and efficient algorithms for scientific research and data science, but why isn't it there yet? Explore the state of scientific computing in Rust, from where it shines to it falls down, to where we can improve as a community, and learn about Rust in an area that has so much potential.
https://rome.rustfest.eu/sessions/rust-for-science
https://media.ccc.de/v/rustfest-rome-4-rust-for-science
A
I'm
going
to
be
talking
about
using
rust
for
scientific
programming,
so
I'm
gonna
be
talking
about
what
makes
rust
a
good
language
to
use
for
scientific
computing,
some
interesting
stuff
we
can
do
in
rust
and,
finally,
some
sort
of
areas
we
can
improve
on.
So
my
name
is
Adam.
If
you
want
to
follow
me
on
Twitter
or
github,
my
names
up
there,
so
I
want
to
start
out
with
what
scientific
computing
actually
is.
A
So
when
we
talk
about
scientific
computing,
we're
referring
to
the
tools
and
techniques
and
algorithms
that
are
needed
to
solve
the
problems
that
you
come
across,
and
maths
and
engineering
and
in
science,
and
you
could
sort
of
break
this
up
into
a
few
parts.
So
it's
going
to
be
things
like
numerical
analysis
and
simulation,
so
that's
gonna,
be.
A
Okay,
so
things
like
simulating
physical
systems,
doing
sort
of
high
performance
computing
on
supercomputers
clusters,
multi-threaded
programming
and
then
data
science.
So
that's,
like
you,
know,
statistical
analysis,
machine
learning,
so
I'm
really
going
to
be
more
talking
about
the
first
two,
because
data
analysis
is
completely
different
sort
of
thing.
So,
if
you
look
at
how
scientific
software
usually
gets
developed,
it
usually
follows
this
sort
of
process,
so
they
usually
starts
out
with
an
implementation
need
or
an
idea.
So
that
could
be.
You
have
a
new
idea
for
an
algorithm.
A
You
need
to
just
run
a
calculation
or
you
have
to
re-implement
something
from
a
paper
and
it
usually
goes
from
there.
You
might
then
go
to
a
higher-level
language
like
Python
and
then
you'll
probably
implement
something
there.
So
Python
is
usually
chosen
first
or
MATLAB
or
any
other.
Any
of
those
sort
of
language
is
chosen
first
because,
first
of
all,
because
it's
easy,
it's
very
easy
to
get
started.
A
Most
of
the
people
that
do
this
sort
of
programming
aren't
computer
scientists,
they're
physics,
students,
math
students,
people
are
just
interested
and
you
probably
wouldn't
have
that
big.
Much
of
a
programming
background
and
higher-level
languages
make
it
quite
easy
to
get
started,
so
you
might
write
your
prototype
and
then
you
go
you
see.
Oh
I
can
improve
my
a
little
bit
and
you
go
back.
You
write
a
little
bit
more
and
then
you
might
realize
that.
Oh
there's,
this
really
big
part.
That's
bottlenecking!
A
All
my
code
I
need
to
then
go
and
rewrite
that
in
a
lower
level,
language
and
that
usually
boils
down
to
rewriting
it
and
C
and
C++,
and
it's
usually
for
like
two
reasons:
it's
usually
one
because
of
just
tradition,
because
well,
science
doesn't
move
quite
as
quickly
as
programming,
doors
and
well.
C++
is
used
a
lot
already,
and
so
you
might
just
use
that
already
and
there's
also
tools
for
ecosystems.
A
Libraries
there
already,
so
it
usually
goes
into
writing
that
sort
of
thing
and
then,
after
that
it
could
be
benchmarking
publishing
a
paper
just
publishing
the
software
whatever.
But
it's
mainly
that
stuff
there.
The
rewriting
step
is
where
rust
would
come
in.
So,
let's
see
if
I
can
change
this,
so
there
is
a
few
problems
with
just
going
and
rewriting
a
big
section
of
your
code
in
C++,
especially
if
you
don't
have
that
much
experience.
Oh.
A
There
you
go
so
first
of
all,
it's
harder
to
debug
this
sort
of
code.
So
if
you
don't
have
a
lot
of
experience,
it's
very
easy
to
do
a
sort
of
guess
and
check
approach
to
programming.
So
you
write
a
little
bit
and
then
you
might,
you
know
open
up
a
raffle,
see
if
it
works
and
you
might
create
a
new
file,
just
try
and
run
it.
A
So
it's
not
the
sort
of
things
that
you
might
normally
do
where
you
might
write
tests
or
any
of
that
sort
of
thing,
and
that's
a
lot
harder
to
do
when
you
use
a
language
like
C
or
suddenly
you
have
to
compile,
because
it's
not
as
quick,
you
can't
just
iterate
as
fast,
and
it's
also
going
to
be
harder
to
learn.
So
if
you
pick
up
a
language
like
Python,
it's
very
easy
to
just
you
know:
go
TextEdit
here
and
put
in
stuff.
A
You
don't
really
need
that
much
background
knowledge,
whereas
if
you're
writing
in
a
lower-level
language,
you
have
to
know
a
little
bit
more
about
well
memory
and
how
things
actually
work
and
referencing
things
and
you've
got
to
sort
of
have
a
fairly
good
idea,
especially
if
you're
trying
to
well
get
well
performing
code
and
that
ties
into
the
next
bit,
which
is
it's
very
easy
to
write
bad
code.
So
it's
very
easy
to
write
code.
That's
not
going
to
be
memory
safe!
A
It's
gonna
have
all
sorts
of
issues
that
you
wouldn't
come
across
in
languages
like
MATLAB,
which
is
like
race
conditions
like
you
might
not
know
that
this
sort
of
thing
could
even
be
an
issue.
It's
very
easy
to
do
that.
So
it's
this
sort
of
place
where
rust
can
actually
help
out.
So,
let's
see
so,
for
example,
if
we
want
to
do
something
like
testing,
so
here
is
a
function.
It
just
does
a
factorial.
A
So
if
I
was
writing
this
in
Python
and
I
just
wanted
to
see
if
it
work,
I'd,
probably
just
go:
I'd
open
up
the
Python
interpreter
and
I
just
type
in
a
few
things
and
see
if
it
matches
up.
Where
is
it's
not
usually
that
easy
to
do,
especially
if
you
have
to
keep
trying
to
do
that,
whereas
a
language
like
Ross,
you
can
just
well
add
a
test
because
it's
built
into
the
language.
So
it's
those
sort
of
things
that
become
really
really
easy
and
also
for
the
writing.
Better
code.
A
Russ
does
a
lot
of
sort
of
what
guarantees,
but
also
a
lot
of
features
that
make
it
a
lazier.
So
here's
a
piece
of
code,
but
this
might
not
be
the
best
way
to
write
this
out
so
tools
like
Clippy
and
the
linters
will
sort
of
say:
oh
well,
you
can
actually
see
where
you're
trying
to
iterate
through
that.
Well,
that's
actually
an
iterable,
so
you
can
go
and
you
can
rewrite
this
a
little
bit
differently
and
that
will
improve
your
code
in
the
long
run.
So
it's
there's
loads
of
features
and
Russell.
A
I
could
help
this.
Well,
things
like
the
memory
and
thread
safety.
So
that's
not
something
you
have
to
learn
or
think
about
things
like
the
built-in
benchmarking
built-in
documentation,
built-in
dependencies,
all
things
that
are
hard
enough
to
get
set
up
in
languages
like
C
and
C++,
especially
if
you
don't
have
that
much
experience,
and
then
things
like
well
there's
a
lot
of
good
libraries
and
roasts.
There's
integration
like
great
FFI
support
and
then
also
other
features
like
web
assembly.
So
gonna
look
a
little
bit
more
specifically.
So
let's
look
at
multi-threading.
A
So
if
I
want
to
do
some
sort
of
algorithm
here
is
of
numerical
integration
or
a
very
simplified
version,
but
basically
we're
just
sort
of
trying
to
calculate
the
area
under
a
function,
but
it
mainly
comes
down
to
a
loop
there,
we're
just
summing
things
up.
So
this
is
exactly
the
type
of
thing
that
you
might
come
across
and
you
might
want
to
parallel
eyes
and
tools
and
rust
can
make
that
really
easy.
A
For
example,
we
can
just
take
the
Ray
on
crash,
we
put
it
in
our
cargo
tunnel
and
then
we
just
import
it,
and
we
don't
have
to
think
about.
Well,
trying
to
find
the
libraries
and
trying
to
add
compiler
flags
and
fixing
or
make
files
or
you
can
just
go,
and
you
can
just
rewrite
your
function
and
it
works
pretty.
Well,
it's
pretty
readable.
You
don't
have
that
much
extra
complexity
that
comes
with
it
and
then
there's
also
other
stuff
like
we
can.
That
was
obviously
like
built-in
threading
libraries.
A
A
Systems
and
then
sort
of
row
specific
stuff
like
cross
P,
so
another
thing
is,
as
I
said,
integration
with
other
tools
so
in
the
scientific
community.
There's
are
a
lot
of
very
well
implemented,
pre-existing
tools
and
there's
no
real
point
in
rewriting
things
from
the
ground
up
when
they've
already
been
well,
optimized
really
really
heavily.
So,
for
example,
let's
say
I
want
to
run
some
code
in
parallel
on
a
supercomputer
or
a
cluster
or
a
group
of
machines.
A
The
usual
way
you
do,
that
is
with
MPI
message,
passing
interface,
and
this
is
basically
just
a
C
specification
for
pretty
much
a
library.
Well,
every
computer
that
runs
this
would
probably
have
a
different
version
and
they're
pretty
heavily
optimized
for
the
hardware.
So
it's
not
gonna
be
something
you
want
to
rewrite,
but
it
is
something
you
can
still
used
through
rust.
So
here's
what
I'd
have
to
write
in
C.
So
it's
just
taken
straight
out
of
an
example,
but
I
can
go
in
rust.
A
I
can
just
import
a
library
and
then
I
can
well
run
it
write
it
and
rust,
and
it
runs
perfectly
well
and
it's
the
same
for
a
lot
of
other
C
libraries
there's
a
lot
of
binding
crates
that
are
already
there.
It's
really
easy
to
create
new
ones
with
tools
like
well
bind
gen
and
there's
also
things
like
web
assembly,
which
are
allow
us
to
do
stuff
on
the
web.
A
A
You
know
anyway,
so
it's
a
it's
a
simulation
of
a
double
pendulum.
You
might
have
seen
it,
but
you
can
sort
of
break
it
up
into
two
parts.
There
was
the
simulation
part
which
is
written
in
rust
and
then
there's
also
supposed
to
be
a
graphics
part,
but
I
clearly
made
a
mistake
somewhere,
but
they're
separate,
so
I
don't
have
that.
It's
not
that
closely
coupled
so
it
means
I
can
go.
I
can
just
take
that
rust
code
and
I
can
take
it.
There.
A
I
can
compile
it
to
web
assembly
and
then
I
can
well
run
it
in
the
web
with
the
browser,
and
then
we
can
get
skip
something
we
can
get
something
that
we
can
actually
run
so
hopefully
this
will
actually
work
there.
So
that's
what
it's
supposed
to
look
like
I'm,
not
in
the
browser,
so
it's
the
same
code
that
I
could
run
on
my
computer
really
quickly
and
I
can
run
in
the
browser
as
well,
and
that
has
a
lot
of
applications,
especially
in
places
where
you
might
want
to
share
your
code.
A
So
there's
been
a
lot
of
efforts
and
Rost
I
think
I've
seen
at
least
three
crates,
but
a
lot
of
them
get
some
discontinued
like
oh
well,
there
was
this
certain
change
in
rust,
1.16
and
now
we
can't
use
it
unless
you're
on
the
nightly
compiler
from
that
exact
day
or
they
just
don't
get
maintained.
But
there
is
a
project
that
came
out
not
that
long
ago,
under
the
Google
Organization
and
it's
e
e,
CX
or
and
it
allows
us
that
we
can
do
jupiter
notebooks
using
rust.
A
So,
for
example,
here
it
is
of
doing
Fibonacci
numbers
computing
them
and
well
it
doesn't
work
perfectly
like
it
doesn't
run
on
Mac.
It
doesn't
run
on
Windows.
You
can't
kill
it
halfway
through
or
it
won't
run.
But
it's
the
type
of
thing
that
is
being
developed
in
rust
that
you
will
be
able
to
use,
hopefully
at
some
point
so,
and
that
gives
other
things
like
a
raffle,
which
means
you
can
do
those
sort
of
quicker
valuations
of
a
few
things
were
and
also
well
stuff.
A
You
can
bring
it
to
your
own
code,
so
Ross
seems
like
a
really
pretty
good
option
for
doing
this
sort
of
programming,
but
it
has
a
lot
of
issues
as
well.
The
main
reason
why
you
wouldn't
pick
Ross
to
do
this
sort
of
thing
would
probably
be
the
ecosystem.
It's
something
that
you
probably
look
at
very
closely
when
you're
trying
to
choose
your
language-
and
you
probably
just
want
to
use
the
tools
that
are
available
already
and
well.
It
is
nice
that
we
have
a
lot
of
binding,
sprites
and
stuff.
A
If
a
lot
of
the
time,
it's
just
more
convenient
to
take
someone
else's
code,
they
wrote
and
see,
and
then
just
you
know,
put
in
your
other
bits
and
then
you
don't
actually
even
have
to
write
it
from
scratch
and
you're.
Not
thinking
about
your
make
files
because
your
advisor
already
did
it
for
you,
so
it's
those
sort
of
things
that
really
aren't
the
best
for
someone
new
coming
you
to
roast
when
you're
like
okay,
there's
a
lot
of
libraries
which
don't
really
have
every
feature
or
they
have
the
core.
A
But
that
specific
thing
you
need
to
do
just
isn't
implemented
yet,
and
that
can
be
a
real
barrier
to
entry
as
well
as
sometimes
there's.
This
perception
that
roast
is
just
for
systems
programming
or
that
it's
a
difficult
language
which
isn't
really
the
case,
but
that
can
be
a
little
bit
of
a
barrier
as
well,
so
I
think
that's
all
I
have
time
for
so.
Thank
you.
B
So,
what's
your
opinion
on
sort
of
bridging
the
gap
between
performance
and
readability
with
languages
which
sort
of
aim
for
both
and
for
a
more
for
a
syntax,
more
similar
to
math
like
Julia,
and
do
you
think
there's
a
future
there
in,
like
the
Russ
community,
generally
speaking,
building
tools
that
bind
to
julia
code?
Similarly
to
how
you
have,
let's
say
the
non
by
stuff
or
like
the
stuff
built
on
top
of
it?
That's
a
lot
of
C++
code
and
essentially
helping
make
scientific
computing
fast
in
Python.
B
A
C
A
C
A
Fortran
is
sort
of
weird
you
don't
really
see
it
that
much
anywhere
apart
from
in
science,
there's
a
lot
of
really
big
libraries
that
are
written
in
Fortran
there's.
The
real
problem
is
why
some
someone
wouldn't
pick
up
for
Tron
to
write
something
new
would
be
there's
it's
not
really
modern,
there's
not
really
a
lot
of
resources
for
learning
it
and,
as
I
said
before,
most
of
the
people
that
are
going
into
this
sort
of
computing
wouldn't
have
done
that
much
computer
science.
A
They
might
have
done
one
class
or
two
classes
in
school
to
like
learn
this
sort
of
thing
and
usually
Fortran
isn't
chosen
that
much.
It
is
chosen,
but
it's
not
chosen
that
much
and
it's
especially
hard
to
sort
of
get
started
with,
because
there's
not
the
same
resources
and
community
that
would
be
even
wet
languages
like
C
and
C++.