have you ever wanted to be able to code
and rust to make your programs blazingly
fast fearlessly concurrent or just plain
awesome well today you're in luck
because in this series I'm going to take
you from rust zero to rust hero and
since we're about to embark on an
awesome coding journey together let me
know why you are on this ship in the
comments below so what are you going to
learn today you're going to learn why
rust is awesome how to install rust on
your computer and we'll also create your
first rust program but before we get
started a little bit about me my name is
Leo and I've been progr python for about
a decade now and on my first birthday I
graduated with a computer science degree
21 years ago okay maybe it wasn't on my
first birthday and I'm still young at
heart but uh I started learning rust
because I ran into speed and safety
issues When developing my automated
trading algorithm that's my why so
what's yours did you remember to post
your why in the comments below and
speaking of old programming languages
have come a long way in the last 52
years but two massive problems have
remained a giant headache for developers
I like to call them M&M's but they're
definitely not that sweet the two
problems are multi-threaded code and
memory safety but with rust all that
changes due to Innovative use of
ownership moves and borrows and while
you're likely not to understand what
this means just yet you will by the end
of the series but what you can
understand is that rust is awesome
because it's super fast and safe and
usually you only get one of the other
but with rust you get both so now let's
get this bad boy installed installing
rust is is super easy all we need to do
is go to rust-lang org click get started
and then copy this script right here
what this does is it uses curl to
download the rustup script at sh. rust
up. RS and then passes it to Shell you
can see when I run it it downloads the
installer I'm going to press one for the
default and you'll notice that there's a
warning CU I already have rust installed
and to check to see if it installed
properly you can type rust up update
this will update rust and you can also
check the compiler version rust c--
version you can see that I'm on Rust
1.76 now before we start creating some
blazingly fast code we want to make our
IDE or editor blazingly awesome yeah
that didn't sound great but whatever um
what you want to do is go to your
extensions and make sure you have rust
analyzer installed you click install and
if you can see what rust analyzer does
it provides code completion you know
Imports definitions things like that so
it just makes things so much easier here
so once that's installed we can go ahead
and create our first rust program and
we'll start by creating a new file we'll
call this hello. RS and then we will
create a main function the main function
is a primary entry point for rust and
many other languages so we'll create an
FN for new function we'll call it main
we're not passing in any parameter so
there you know there's nothing between
the left and right parentheses then we
have two curly brackets we type print X
exclamation mark Cuz we're actually
using a macro here hello comma world and
then we'll end this with a semicolon
save it and then we want to go ahead and
compile it so we'll type rust C and then
we will enter our file name which is
hello.rs and you'll notice when we do
that it creates another file that is the
binary to run it so we'll type hello and
that runs it I can type LS here to see
that here's the code and here's the
binary
but in truth you're rarely if ever going
to use Russ C to compile your code
you're likely going to use cargo which
is Russ official build system and
package manager long story short we'll
we'll dig into all the details later but
essentially it helps you manage all of
your dependencies there's some other
functionality around build automation
testing and document generation and
Publishing packages but essentially
let's just take a look and see what this
thing does for now and how it helps us
as a new R developer so we'll type cargo
new hello world and this will create a
new folder and in this folder we're
going to have some additional files now
we're going to see this cargo. TL file
which you know essentially tells cargo
all of our dependencies the version all
this other stuff we have a g ignore and
under here we have this Source folder
and our main. RS file which essentially
helps us create uh you know this binary
which we already created and it looks
extremely similar to what we already had
before uh with one small difference
we're using the print macro here and
we're using the line hello world there
just so we can get that extra carriage
return we could use Russ C to compile
this but instead let's use cargo so CD
hello world and we'll type cargo run and
what this will do is it'll actually
compile it as you can see right here and
then it also runs it and it has a
different Target where we can see it's
Target debug hello world so we can see
this new folder Target debug and then
here's our hell World essentially when
we are developing we're not going to do
all of the optimizations we would for
production code it just helps speed up
the compile times although that's not
really an issue with just this hello
world with rust installed and your
editor blazing fast click on this video
to take your next steps in your rust
Journey