►
Description
Rust is a notably hard language to learn, but its safety guarantees teach valuable skills that can be applied across the industry. Is it possible for college programs to teach Rust to freshman to instill these skills in their students?
More at https://rustfest.global/session/13-rust-for-freshmen/
A
B
B
I
first
started
learning
rust
in
the
spring
of
2019,
while
I
was
taking
computer
systems
a
course
taught
in
c
after
I
heard
about
russ's
memory
guarantees,
I
decided
to
look
into
it
when
I
asked
my
instructors
what
they
thought
about
it.
My
professor
gave
a
very
encouraging
response,
and
so
I
looked
more
into
the
language
and
started
writing
projects
in
it.
I
even
joined
the
community,
and
earlier
this
year
I
became
an
editor
for
this
week
in
rest.
B
My
goal
here
is
to
design
a
freshman
level
computer
science
course
taught
in
rust.
I
want
to
enable
students
with
rus,
powerful,
tooling
and
ecosystem
things
that
they
can
take
advantage
of
for
the
rest
of
their
career.
Russ
error
messages
are
better
than
any
other
language's
error
messages.
They
give
students
a
great
way
to
have
feedback
about
their
code
and
know
exactly
what's
going
wrong
with
it
for
testing
and
documentation.
B
Russ
supports
these.
As
first
class
citizens,
which
is
great
because
students
don't
have
to
worry
about
adding
extra
dependencies
or
adding
extra
libraries
in
order
to
get
their
code
working,
I
want
to
avoid
teaching
some
out
of
scope
topics.
Stacking
heap
allocations
and
threads
are
things
that
are
taught
in
later
courses,
so
they're
not
really
in
scope.
B
B
I
also
want
to
limit
the
use
of
cargo
since
dependencies
and
compiler
configuration
options
are
not
really
necessary
for
students.
First
learning
how
to
code,
I'm
going
to
be
basing
this
course
on
fundamentals
of
computer
science,
2
affectionately,
called
funnies
2
by
northeastern
university
students.
B
The
instructors
want
to
make
sure
that
students
walk
away
from
the
courses
with
good
habits,
naming
conventions,
documentation
and
unit
testing
are
important,
no
matter
what
language
you're
using,
but
encapsulation
is
something
that
students
haven't
encountered
before,
and
so
they
must
learn
how
to
respect
it
in
object-oriented
programming,
the
instructors
don't
introduce
null
yet.
So
I'm
not
really
worried
about
that.
For
now.
B
So
the
first
thing
you
want
to
do
when
you
introduce
students
to
a
new
programming
language
is
to
teach
them
teach
them
the
very
basics.
There
are
numbers,
booleans
and
strings
for
numbers.
In
java,
the
instructors
usually
teach
students
to
use
int.
While
double
is
used
for
floating
point
precision
numbers
for
integers
we're
going
to
be
using
the
i32
type
while
we're
going
to
be
using
f32
for
doubles.
B
This
is
simply
to
keep
a
little
bit
of
consistency.
Even
though
doubles
exact
translation
would
be
an
f64
for
data
types,
we're
going
to
use
c
style
structs
and
for
implementation
blocks,
we're
going
to
keep
it
classic
with
constructors
and
methods
we're
also
going
to
allow
students
to
use
functions,
something
that
they
currently
can't
do
in
java.
Since
that
provides
a
lot
of
great
functionality
for
us
programs,
we
also
have
to
introduce
introduce
students
to
references
since
russ
is
very
dependent
on
manual
pass
by
reference.
B
B
B
B
So
in
rust
this
is
actually
available
to
us
within
the
trait
the
trait
types
we
defined.
The
default
speak
implementation
in
the
declaration
for
the
animal
trait
and,
of
course,
down
below
you
can
see.
I
have
unit
tests
to
make
sure
everything
works
as
properly
something
that
students
will
have
to
get
used
to
the
next
part
of
abstract
classes
is
defining
shared
data
again.
Rust
doesn't
have
a
great
way
of
of
handling
this,
and
so
we
have
to
implement
our
own
object,
which
will
allow
us
to
do
this
ourselves.
B
B
As
you
can
see,
this
is
a
very
simple
dynamic
dispatch
example,
but
it's
enough
to
show
that
it's
possible,
you
have
the
tell
animal
to
speak
function
which
dynamically
dispatches
on
an
animal
reference
and
returns
a
string.
Again.
I
check
to
make
sure
that
all
of
this
is
done
properly
with
my
unit
tests.
B
Next
we're
going
to
look
at
generics
since
they're,
since
they
allow
programmers
to
contain
different
kinds
of
data
in
their
types.
We
have
a
problem
with
this,
though.
Typically,
when
the
instructors
introduce
generic
types,
they
introduce
it
by
re-implementing
the
functional
monad
lists.
B
This
won't
work
in
rust,
rust
actually
has
monads,
and
this
is
not
the
proper
way
to
define
them.
So
we
must
obey
rus
rules
for
de
for
defining
things
that
are
similar.
B
B
B
We
have
the
cons
and
empty
functions
available
to
students
since
they're.
Typically
what
they're
used
to
coming
from
racket,
we
also
have
the
count
method,
which
is
available,
which
iterates
over
all
of
the
items
in
the
list
and
counts
how
many
items
there
are.
As
you
can
see,
we
use
a
match
expression,
something
that
I
was
not
into.
Anticipating
teaching
to
students.
B
Racket
does
have
match
expressions,
but
this
is
something
that
wasn't
introduced
during
fundies
one,
and
so
there's
not
really,
and
so
students
aren't
already
familiar
with
this
idea.
So
this
is
another
thing
that
we
have
to
teach
students
how
to
use
and
how
to
use
properly.
B
We
also
must
use
heap
allocation.
As
you
can
see,
I
get
around
to
the
redund
the
recursive
data
definition
by
using
a
shared
pointer
or
smart
pointer
for
the
rest
of
the
list.
In
my
cons,
this
is
again
something
that
I
didn't
want
to
teach
students,
and
so
this
is
something
that
we'll
have
to
find
a
workaround
for
later.
B
Next,
we
want
to
introduce
function,
objects
to
add
to
existing
behavior
of
types
with
list.
This
is
easy
to
demonstrate.
We
have
the
filter
method
now,
which
accepts
a
predicate
which,
as
you
can
see
at
the
very
top
of
the
file,
is
a
type
alias
to
a
function
that
accepts
a
reference
and
returns
a
boolean
in
the
filter
method.
We
have
the
same
thing
as
count
except
first,
we
check
to
see
if
the
predicate
is
satisfied
by
the
first
and
the
list.
B
B
Instructors,
teach
students
how
how
to
throw
exceptions
when
to
throw
exceptions
which
exceptions
to
use
and
how
to
catch
the
exceptions
with
rust.
Of
course,
all
of
this
goes
away.
You
really
only
have
to
act
on
the
results
type
which
you
can
use
by
checking
whether
or
not
it's
okay
or
an
error,
and
then
returning
the
error
if
needed.
B
So,
as
you
can
see,
we
have
the
animal
shared
implementation
from
earlier,
and
we
also
have
the
dog
implementation
block
from
earlier.
For
both
of
these
constructors
we've
changed
the
result,
type
or
we've
yeah.
We've
changed
the
result,
type
to
be
a
result
where
the
okay
is
an
animal
shared
object.
B
B
Animals
simply
cannot
weigh
negative
weight,
while
in
dog
we
check
to
see
if
the
animal
shared
constructor
returned
an
okay.
If
it
was
an
error,
we
return
the
air.
We
also
check
to
see
that
the
agent
dog
ears
of
the
dog
is
valid
and
we
return
the
error.
If
not,
students
will
use
this
to
have
a
great
understanding
of
how
to
properly
handle
errors
and
since
russ
doesn't
really
allow
any
workarounds
for
error.
Handling.
Students
always
must
handle
this,
which
gives
a
great
habit
for
students
as
they
move
on
in
their
career.
B
In
the
dog
class,
we
have
the
same
animal
method,
which
is
inherited
from
the
animal
interface,
and
you
see
that
we
have
the
instance
of
keyword
being
used.
This
is
a
problem.
This
simply
does
not
have
have
an
equivalent
in
rest.
You
cannot
check
the
type
of
an
object,
in
fact,
russ
erases
the
type
of
an
object
when
you
up
cast
it
into
a
trait
object,
so
this
part
simply
does
not
exist,
which
could
be
a
problem
except
I'm
not
sure
it
is.
B
B
In
fact,
they
should
only
be
checking
equality
between
two
objects
when
they
know
those
two
objects
are
of
the
same
type.
This
introduces
a
lot
of
good
habits
to
students
and
ensures
that
they
walk
away
with
a
lot
of
great
great
skills
and
understanding
of
how
to
properly
handle
the
sameness
of
data.
B
B
B
B
I
think
with
a
simple
crate
that
looks
like
this,
but
this
crate
has
its
own
problem.
It
has
too
much
magic
in
and
of
itself
as
of
right
now
in
funnies
2
students
don't
have
to
depend
on
on
external
libraries
for
anything
except
for
the
animations
and
for
unit
testing.
B
There
are
also
some
honorable
mentions
some
topics
that
I
didn't
get
to
cover
in
this
presentation,
such
as
loops,
mutability
and
algorithms.
These
shouldn't
be
too
hard
to
replicate
and
rust.
So
I'm
going
to
leave
that
alone.
B
Currently
russ
has
an
immature
gui
ecosystem,
which
means
that
there's
got
to
be
a
lot
of
work
done
before
we
have
the
ability
to
have
an
animation
library
sufficient
enough
for
the
course
there
is
the
possibility
of
using
web
assembly
and
having
students
run
their
rus
code
in
a
browser.
This,
of
course,
is
very
flexible
and
could
actually
be
something
that
could
be
used
in
a
course
like
this
there's
also
the
problem
of
cargo
right
now.
Cargo
is
the
easiest
way
to
run
rust
code
without
cargo.
B
B
And
lastly,
there
are
some
topics
that
I'm
leaving
out
for
future
classes,
such
as
lifetimes
lifetimes,
could
be
introduced
in
the
next
course,
while
threads
are
definitely
introduced
in
a
later
course.
Unsafe
is
also
something
that
students
should
learn
how
to
use
and
rust,
but
they
should
only
learn
how
to
use
it
properly.
So
I
think
that
this
would
be
best
used
alongside
the
thread.
B
Lessons
so
is
this
course
viable.
Ultimately,
it
has
a
lot
of
advantages
and
a
lot
of
disadvantages
for
advantages.
It
forces
a
lot
of
good
habits
within
students
simply
by
using
rust
as
the
language
of
choice
and
all
of
the
habits
that
students
learn
with
rust,
are
applicable
to
other
programming
languages,
giving
them
a
lot
of
skills
that
they
can
use
throughout
the
industry.
B
Furthermore,
further
future
concepts
will
enforce
good
habits
within
students.
You
also
have
the
option
type
lifetimes
and
mutability
and
thread
safety
and
all
of
these
things
which
are
included
in
rust,
either
in
the
standard
library
or
in
the
core
library
or
as
a
language
feature
which
students
will
be
able
to
take
advantage
of.
B
B
B
B
B
B
C
Right
interesting,
we've
also
often
considered
here
in
latin
america
as
starting.
Actually
there
are
several
universities
teaching
rust
in
several
courses,
but
none
none
in
basic
courses.
So,
for
example,
like
you
were
saying,
concurrency
and
threading
should
be
in
advanced
courses,
they're
taught
in
that
in
advanced
courses,
but
but
none
you
know
like
as
a
first
programming
language.
So
a
lot
to
think
about.
B
Yeah,
I
I
do
think
that
there's
a
lot
about
about
that
kind
of
stuff
that
is
a
little
bit
more
complicated
for
students
to
learn,
especially
in
their
first
year
of
learning,
computer
science
and
the
instructors
do
a
great
job
of
making
sure
that
they
only
learn
that
later
on
in
their
education.
So
I
think
that
that's
a
good
plan.
C
Right
so
one
of
our
questions
is:
would
rust
be
a
better
fit
for
such
a
course
or
do
you
think
we
should
introduce
things
through
first
through
a
more
basic
language
like
go
to
ease
into
resource
management.
B
I
mean
I,
I
also
write,
go
and
I
think
it's
a
great
language,
but
ultimately
there
are
some
issues
with
go
still.
You
do
have
things
like
the
linter
being
able
to
make
sure
that
people
check
their
error
returns,
but
you
still
have
the
possibility
of.
If
you
don't
have
the
linter,
then
you
may
not
be
checking
to
make
sure
that
error
is
nil
and
so
with
rust,
monadic
option
type
and
result
type.
C
Right
another
suggestion
question
was:
why
not
teach
students
how
memory
actually
works
from
the
start?
Why
shield
them
from
the
complications
and
not
understand
the
difference
between
stack
and
heap,
for
example,.
B
So
right
now
in
my
in
the
curriculum
for
the
computer
science,
students-
that's
just
simply
how
it
is!
You
don't
really
learn
the
the
ideas
of
stack
and
heap
until
computer
systems,
the
course
that
I
was
talking
about-
and
I
think
that
that's
good,
especially
when
you
get
into
like
threading
and
posting
style,
programming
and
manual
stack
versus
heap
right
now.
The
introductory
courses
are
taught
in
racket
and
and
java,
and
you
don't
really
have
to
worry
about
the
stack
versus
the
heap
in
there.
B
So
I
think
that
it's
good
to
still
wait
until
later
to
worry
about
stack
versus
heap,
but
unfortunately,
because
of
russ
still
manual
memory
management.
That's
got
to
be
something
that
has
to
be
worked
around.
C
Right
right
not
to
put
my
own
commentary,
but
I
guess
it
boils
down
to
the
difference
in
two
schools.
One
is
teaching
programming
from
the
machine
up
and
the
other
from
programming
concepts
down
right.
B
C
B
Exactly
the
approach
that
the
instructors
at
my
school
take,
they
want
to
make
sure
that
students
have
the
fundamental
ideas
of
computer
science,
first
implementing
algorithms,
making
sure
that
their
code
works
properly
all
of
their
logic
and
then
eventually,
they
get
deeper
into
the
machine
level.
Ideas.
C
Cool
what
missing
features
rust
feature
would
you
do,
you
think,
would
most
improve
teachability.
B
It's
the
manual
measure
manual
memory
management.
I
think
that's
the
biggest
problem,
so
I
think
that
that
is
what
ultimately
hurts
the
teachability
of
rust
from
the
start
you
can
get
around
lifetimes.
You
can
get
around
reference
passing
but
having
to
have,
for
example,
like
I
showed
the
recursive
data
definitions
having
those
is
so
hard
to
avoid
teaching
about
stack
versus
the
heap
when
right
now,
again,
that's
taught
later
in
the
curriculum.
So
I
think
that
that's
the
part
that
hurts
the
teachability
the
best.
C
B
You
so
much,
I
really
appreciated
being
here.