Rust Programming Language: AMA Deep Dive

Jayson Lennon
Jayson Lennon
hero image

A quick note from the editor:

I recently got to join and moderate a live AMA call that Jayson did with our students in the Zero To Mastery virtual campus.

ZTM virtual campus

Students and I asked questions about Rust, how it works, some technical questions, how he got started learning to code (without the internet 😱), and there were even some ‘out there’ tangents.

You can check out Jayson's answers to the questions from his AMA call below, but first, let me introduce him.

Who is Jayson Lennon and why should you listen to him?

Jayson is a self-taught software developer and Linux computing enthusiast, as well as the instructor of our Zero To Mastery course on the Rust programming language.

Rust Course

Using his knowledge from being industry certified in networking & security, Jayson has designed, written, and deployed reliable and secure Rust-powered full-stack web applications, so he’s highly experienced and also a fantastic teacher.

His lessons are clear, detailed, and easy to follow so his students can understand what will be covered, how to actually implement what they've learned, and then review why it worked as well as common errors and issues that you'll likely encounter.

(Jayson also puts a large focus on giving practical exercises, so that you can practice and immediately apply what you're learning to real projects.)

Want a sneak peek of Jayson's Rust course?

Well we just released a 6 hour Rust 101 teaser on Youtube, or check it out below:

As you can see, he knows what he's talking about when it comes to Rust, so without further adieu, here are Jayson's AMA answers

🙋AMA with Jayson Lennon on the Rust programming Language 🙋

The questions below were either live on the call, or sent in via our Rust Discord channel.

If you want to ask questions for future AMA's, be sure to join our Discord here.

What is the Rust programming language, and what is it used for?

Rust is what I like to call, the “next generation” of programming languages. It checks your work along the way, so it helps catch bugs before they can reach deployment and cause downtime.

You can use Rust for general purposes or any kind of application, but it mostly focuses (and is marketed towards), high-speed and reliable applications that are low on memory usage.

Even though it's mainly used for high-performance projects, I think Rust is great for general purpose as well, because you save a lot of time when working with Rust, as opposed to using a different language and having to crush bugs at 2 am because your server went down.

Instead, you just hit compile and if there’s an issue, Rust will let you know before you deploy!

Do you think Rust's code checking feature is the main reason that people love using Rust?

I think Rust is popular for a lot of reasons because every part of Rust seems to be designed to improve upon the Developer experience, and just makes it so much easier to work with the code, especially with the compiler.

The compiler will even go so far as to print out your code with the error, and then print out a corrected version and say “Hey, you might want to try this code to fix this problem!

To me, that just makes the whole Developer experience really great.

Can you think of any examples of applications or sites that are built on Rust?

In terms of specific applications, there are a lot of Linux command-line tools that have been written in Rust, such as ls and grip. (They’ve been made multi-thread and given modern features such as using icons and things in the terminal.)

There are also a lot of back-end things that have been built with Rust (and which most people won’t have had exposure to), but for example, Discord, a lot of their infrastructure is running on Rust now.

So for big servers such as the ZTM server (our private Developer Discord community), where there are over 300,000 students now... that's a huge amount of data that’s being managed by Rust.

Rust’s ability to crunch through that volume of data quickly is really important for fast web services and a good user experience.

Random question: What is the difference between Rust and the R programming language?

Hmm, not sure about that one! I haven’t used R, but it has no relation to Rust whatsoever.

(It may be that people assume it’s the same tool or a variation, simply because they both start with the same letter.)

Is Rust easy or difficult to learn?

It kind of depends on how you approach learning it. If you come to Rust with no experience, I personally think it’s easy to intermediate difficulty to learn. (As I said before, the compiler is great at guiding you along.)

But if you’re coming in with an Object-Oriented background with years of experience, then you may find that switching over to Rust is slightly more difficult, just because of how it differs from what you already know, and because you’ll be trying to apply object-oriented principles to Rust, which doesn’t mesh well with that approach.

Is Rust a functional programming language?

Rust is a hybrid between functional and imperative. There’s not many of the typical object-oriented programming methodologies in there. There’s no classes or inheritance, but you can sort of emulate those behaviors if you want to, but it’s not the recommended way to use Rust to code.

Do you need a coding background to learn Rust, or could you come in brand new and pick it up?

I think if you’re serious about a career in Software Engineering, then you can for sure pick it up as your first language.

But if you’re more casually programming, or working on some small apps or a website, then it would help to have a little bit of programming experience before you jump into Rust.

What do you think Rust's trajectory will be over the next 10 years? How do you think the language will maybe evolve or advance?

10 years is a pretty long way out, so it’s hard to know. The release cycle for Rust (for new updates) is every 6 weeks, so we basically have a new version and possibly new features every 6 weeks.

Then, every 1.5-2 years, they lock the features down at that point, which allows them to make breaking changes without breaking old code, by using a special addition system that keeps everything separated.

As far as its 10-year trajectory, I think in the next 5 years, people will be using Rust more often for high-speed applications and anything that needs a lot of performance, whereas, in 10 years, I think we’ll see a lot more general-purpose usage, thanks to the compiler and how easy it is to code in Rust.

Is Rust better than Python or C++? And which has the best performance?

As far as ‘best language’ goes, there is no best language, only the best one suited for your needs or goals. However, in terms of performance, Rust does perform extremely quickly and is on par with C and C++. It also has a lot of great features, but without seeing any performance penalties.

(Traditionally if you have a scripting language or a garbage collection language, they have a lot of overhead to make them work and be convenient, but with Rust, you get that same convenience without the performance issues.)

Is Rust based on C++?

No, Rust is its own language. The original compiler was written in OCaml, and then eventually it was bootstrapped, and now Rust is written in Rust.

However, Rust does take a lot of inspiration and examples from different programming languages and paradigms:

For example

When you create a variable or object in Rust, the way it does this is that when you create it you own it, and so that piece of memory is yours for that variable.

The idea for things like that was taken from C++, but Rust formalized it into a system where it kind of tracks everything for you, which is how you get the great performance along with the ergonomics.

What areas of embedded systems are the Rust programming languages best suited to?

As far as embedded systems go, you’ll need to target some of the more popular chips so, the really small ones that are in calculators and things would probably not be the best choice.

But for a Raspberry Pi or similar, Rust would be a great choice for those because there are targets and you can compile for those chips.

The best option if unsure is to simply check that your chipset has support so you can overcome any issues.

What is the best text editor or IDE to use with Rust?

For Rust, I would recommend either VScode or Clion.

CLion actually wrote their own Rust plugin which will analyze the code for you and get you autocompletions and all that good stuff.

VScode uses Rust Analyzer which is an open-source project. This means that when new commits are added from Rust updates, VScode is the first IDE to update and adopt those changes and features.

Can we use Rust instead of Python, for quantum computing?

I haven’t done anything with quantum computing so I’m not sure sorry. I do know that Python is pretty popular for creating bindings and things for Machine Learning, so I would probably stick with Python for now.

Does Rust have the potential to replace C, as the default HFT programming language?

I haven’t done any (HFT) high-frequency trading programming, however, given the risk involved in HFT, I would assume that you would want as many things checking your code as possible.

With this in mind, I would imagine that over time people would transition to Rust so that they don’t have any erroneous transactions that could lose millions of dollars in a couple of minutes!

What is the best way (in your opinion) to become a Developer?

The best way to become any Developer is to just start writing code.

The job is to write code and build things, so if you start off building a small project and gradually add more features before moving on to bigger projects, you’ll start to broaden your horizons.

Also, don’t stick with just one specific segment of the market. Try different things to see what you like and don’t like, and find what you’re good at. Eventually, you’ll have enough projects and be able to make a portfolio so that you can sell businesses on your skills and get a career.

What should a Junior Developer do to prepare for interviews?

Algorithms!

Interviewers love to give you the algorithm and data structure questions, so spend a few months practicing those, nail the interview, and then once you get the job you can just do the easier stuff!

Note:

We have a course here at Zero To Mastery exactly on these Data structures + Algorithm interview questions.

How do you get over the constant feeling of "I don't know enough?"

I always have that feeling of not knowing enough, but I get over it by building things.

For example

If I set a goal to build a specific project, I work on it until completed. Seems simple, but by being able to finish it, I now know that I know enough in that particular area which can give you confidence.

The thing with programming is that there’s always something new to learn, and you’ll never know it all. When you realize that though, it’s freeing and allows you to push through it and adapt.

Also, there’s always something. Usually, some small detail that you didn’t know ends up being the crux of a project. The thing is, by learning it during the project, you’ll know it far better than if you never had that hands-on experience.

Don’t try to know everything. Instead, focus on learning the 20% that’s important and then learn to adapt and learn how to learn efficiently!

How long did it take you to get your first Developer job?

For me, it was 3 years and it involved lots of making projects and submitting applications.

It can help if you have a degree, so if you’re in an economic position where you can go to college and get a degree, then that’s probably something that could help, mainly because the software that they use to filter applicants will often check for “must-have degree” before it moves you to the next section.

There are ways to get around this, such as great pitches or being recognized in coding comps, etc. (You can also do freelance work, ethical hacking, bug bounties, and other things without the degree or needing to be hired.)

How can you stand out when making a career transition to becoming a Developer?

For practice and experience, work with the projects that are part of the tutorials and video training, but then take the next step and expand on those.

Dive into learning how they work and add new features, and then once you get comfortable with this, start making your own projects completely from scratch, as this will help you stand out.

This way you have a foundation to start with so it’s not so daunting, and then you can build on it and differentiate yourself from the crowd.

Note:

ZTM student Duaij did exactly this by building a small app to solve a problem for his current company, and they went ahead and paid for his education to become a full-time Developer!

Are there any common questions that you get from students about Rust that we haven't covered so far?

Rust is pretty complex and there are a lot of elements, so there’s never one specific question that stands out, more a range of them across the board.

That being said, we do have a Discord channel in the ZTM Discord dedicated to Rust where people can ask anything, but no, nothing that stands out right now sorry.

What are the differences between Rust and Go? Were they designed for the same purposes and which do you prefer?

I prefer Rust over Go, simply because I think Rust has a lot more features, and I really like the compiler because it catches all my bugs!

As far as the differences, Rust is more of a general-purpose language so you can kind of use it for anything. Whereas Go is more designed for Google with microservices etc.

Also, Go follows the more traditional programming models that people might be more familiar with. This means that hopping into Go is really easy (assuming you have previous coding knowledge), compared to hopping into Rust, simply due to the differences and extra work required to learn Rust.

If you know Python or Javascript, you’ll find Go an easier language to get into and be fairly efficient in a couple of weeks.

What are some of your favorite resources that you used when self-learning?

My self-learning path is a little bit different than what is possible today because when I started I didn’t have the internet or access to programming books or courses.

I kind of stumbled my way at the time through Windows 95, and eventually, I found a help document buried deep in the Windows folder that had QBASIC and some very basic commands, and with that, I learned to automate my Math homework.

I didn’t want to do homework as a student, and then from there I just kept going.

As I said, my path is a lot different from what would be typical today!

Lazy programmers are really efficient at making stuff that automates things 😉

What sort of starter projects do you recommend that take advantage of Rust's features?

For starter programs, I always go with the GNU utilities such as ls, cat, or echo. Really easy ones to get started with.

The reason I always recommend those, especially if you have LS or GRIP, is because you can just start simple and just do the bare bones that you need to do, but you can keep adding features to them as you keep learning more about Rust.

For example

You can start with just loading files and just reading through one at a time, and then you can start adding on parallel processing threads, etc.

After that, you can start doing optimization with the different string parsing, and then add even more features like colors and it just keeps going on and on, because there are so many features you can add.

Who invented Rust? Who are the people behind it?

Graydon Hoare created Rust as a pet project while working at Mozilla.

Mozzila found out about their work and then started to fund the project, which makes sense because web browsers are one of the most complicated softwares around. They’re basically an operating system with a whole bunch of features and so the code becomes more and more complicated over time.

But because Rust's compiler helps to remove that complexity due to it checking everything, it made total sense for Mozilla to help fund its creation. (Rust checks every single line on every compile!)

What areas do you think Rust could improve?

It would be great if Rust had a garbage collected interface, so that if you ever just want to throw something together and not have to worry about dealing with lifetime issues, or if you make too many copies of data then you could.

It would be nice to just have a way to say “Hey, I just want to turn garbage collected mode on”, and then just ignore all the issues with tracking things.

That might already be doable with some fancy macros or a language feature, but it would be great to have something like that built-in, to help people ease their way into Rust and not worry about managing memory by hand.

Do you use 'unsafe' mode often?

I’ve been programming in Rust for around 6-7 years now, and I’ve never used unsafe a single time.

Rust has memory safety guaranteed, and that enforces a type system, so if you tell the compiler you’re working with someone's name for example, then you can’t just convert that person’s name into a truck or a vehicle or something, as that’s not allowed.

But as soon as you go into the unsafe mode, you can go to that individual chunk of memory and just tell the compiler, “Hey, this is actually something completely different to what it’s listed as, but trust me, I know what I’m doing”.

That’s the purpose of unsafe mode. To manually tell the compiler that you want to convert something or interpret it differently than what the language thinks is happening.

But like I say, in 7 years I’ve never run into an issue where I needed to use unsafe because when you go into unsafe you lose some of the benefits of the compiler, and I would prefer to let my code run smoothly!

That being said, if you have a background in C++, then you might want to use this mode to let you run and bypass learning some of the Rust processes.

Can you make games with Rust?

When it comes to Game Development, I always ask 2 questions:

  • Do you want to make a game?
  • Or do you want to make a game engine?

If you want to make a game, then I recommend using Unity or Unreal engine, because those engines are already built and ready for you to make a game on.

But, if you want to make a game and do all of the programming, then you’ll probably spend 80-90% of your time just making the engine before you can even get to the point where you start making the game itself!

However there are multiple crates (which are libraries in Rust) that allow you to make games and one of them does have a built-in editor, so it’s similar to Unity but it’s very bare-bones.

The other crates are more focused on collision detection or graphics drawing and other things. So you totally could use Rust to develop a game, but ask yourself if you want to make a game or an engine first.

Are there any plans for more topics or projects to be added to the ZTM Rust Programming course?

As far as topics go, we update the courses every year on ZTM, so as new features get added to Rust, they’re going to show up in the Rust course.

And as far as projects go, drop something in the Discord channel and let us know what you want to work on. If enough people also want that project then we’ll get it made.

Where to learn more about Rust?

If you want to learn more about the Rust programming language and follow a step-by-step training program with examples and tutorials, then check out Jayson’s course on Rust here.

More from Zero To Mastery

[Full Guide] Learn To Code For Free in 2024 & Get Hired in 5 Months (+ Have Fun Along The Way!) preview
Popular
[Full Guide] Learn To Code For Free in 2024 & Get Hired in 5 Months (+ Have Fun Along The Way!)

Updated for 2024 (including A.I. & ChatGPT). In 2014, I taught myself how to code & got hired in 5 months. This is the step-by-step guide I used. Now 1,000s of other people have also used it to learn to code for free & get hired as web developers.

ZTM Career Paths: Your Roadmap to a Successful Career in Tech preview
Popular
ZTM Career Paths: Your Roadmap to a Successful Career in Tech

Whether you’re a beginner or an experienced professional, figuring out the right next step in your career or changing careers altogether can be overwhelming. We created ZTM Career Paths to give you a clear step-by-step roadmap to a successful career.

How To Get Paid While Learning To Code preview
How To Get Paid While Learning To Code

Learning to code takes time, but that doesn't mean you can't get paid for being a coder while you're still learning... Here's 10 methods you can use, today 💰.