The C Programming Language is Over 50 Years Old, So Today I Learned Rust

preview_player
Показать описание
If you've ever programmed in C or C++, you know that its incredibly easy to make mistakes. These mistakes manifest in the form of bugs that can leave your code either broken or taken advantage of.

In this video, we dive face fist into a new language: Rust. Rust was developed by Mozilla with an emphasis on performance and memory safety. This is the first video of many where we discuss Rust concepts and eventually program embedded platforms with Rust.

🏫 COURSES 🏫

🔥🔥🔥 SOCIALS 🔥🔥🔥

0:00 Introduction
1:48 Rust Hello World
2:43 Rust Binaries
3:32 Rust "Safety"
5:20 Crashing Rust
6:49 Embedded Rust
Рекомендации по теме
Комментарии
Автор

As all C programmers say, with great power comes great 'segmentation fault at line 115'

timecubed
Автор

Hi my friend, as a fellow C programmer, who switched to Rust a year ago after 30+ years of C. I would highly recommend dropping the OS packaged rust (i.e. using apt or rpm) and use rustup instead! The packaged versions tend to be several version behind, and Rust is hyper evolving right now (including the stable version. for example there is a major CVE that got addressed in 1.58.1 that plagues all previous versions). Also, with rustup you will get the latest and greatest version of rust-analyzer which in-turn makes integration with IDEs a lot cleaner.

TrustifierTubes
Автор

The binary is huge because this is an unoptimized version. You can get it way smaller if you compile it in release mode.

There's no runtime in Rust. All the checks are made at compile time.

nscarlos
Автор

In rust you don’t necessarily need to provide the “return” or the semicolon on the last line as long as it’s what you intend to return from your function

notshbn
Автор

C succeeded because it enabled engineers to get stuff done. Whether Rust overtakes C depends on whether Rust developers can get stuff done more quickly to the point that the advantages are clear. This means the learning curve must not be too steep, and there cannot be chronic situations where the developer has to learn something that won't be used for another sixth months.

disgruntledtoons
Автор

5:10 - Just want to add something here, you can *always* dereference a pointer safely, unsafe mode also allows dereferencing *raw* pointers.

hugoit
Автор

What I'm not quite get is why its positioned as a replacement to C and not C++. Its much much more complicated than C with all impl/move/async/smart pointers/generics/lifetimes semantics, whereas C is basically an assembler macroses. So I think rust should in theory replace C++ then, but speaking of C++ - there's already 20'th redaction with move semantics/smart pointers/generics etc and lots of code analysis too. So idk, having nothing against Rust though, but this obsession on "replacing" C....

KyrychenkoAnton
Автор

What happens in unsafe stays in un-

SEGMENTATION FAULT(core dumped)

nickscurvy
Автор

C is 50 years old but still a top 3 language. It won't be going anywhere anytime soon.

ertugrulghazi
Автор

There are other languages as old as C, even older. But nobody ever hears about them anymore, because they weren't so good or didn't have such uses as to still hold up after so many years, as opposed to C (or are still used in niche cases, not popular ones). So "old" isn't really an argument. It's an excellent language in so many ways.

tompycz
Автор

Rust's biggest draw back in embedded is the limitation of architectures it supports due to LLVM. Now this can change, but as of right now, if LLVM doesn't support a chip, neither does Rust. And LLVM is lacking in a few areas. Hope to see this improve though.

toddmartin
Автор

5:38 noo, 12345 doesn't point to anything, it's just a number. The type of the **number** is usize! The usize definitely doesn't mean "undefined size", it means "unsigned pointer-sized integer" lol, like size_t in C

kangalio
Автор

Seconded, would love to see Rust running with Raspberry Pico.

mikeywisniewski
Автор

You can actually enable dynamic linking instead of static to get lesser binaries, AFAIK

vicshcher
Автор

It's great that you are excited about memory safety. You talked about it a lot in the video, but Java had memory safety back in 1995. That's 27 years ago! To me, one of the most interesting features of Rust is thread safety. This is the first time I ever heard of a language that guaranteed thread safety. IMHO, that's much more important (and more revolutionary) than memory safety.

PeterSramka
Автор

I like the way this video was presented, and welcome to the Rust community! The only thing I'd like to mention is that I've noticed some of the information/code you share is not (entirely) correct, and might cause confusion for others.

- Rust does not require explicit return statements, the last expression will be the return value; unless you want to perform an early return.
- I would recommend using Rustup to install the rust compiler and other very useful tools, such as cargo (the package manager used by rust), and generally includes a more recent version of the compiler as well.
- The binary you compiled was not optimized, therefore it will also include debug symbols among other things which drastically increase the size.
- usize does not stand for undefined size, it stands for unsigned size, which is the unsigned variant of size (signed is called isize) which is a pointer sized integer that varies in byte size depending on the target architecture you are building for; for example, on a 32 bit target, this is 4 bytes and on a 64 bit target, this is 8 bytes.

Anyways, keep it up.

elertan
Автор

You keep saying that Rust is similar to Python but I just don't see it. At a glance it looks like C. Am I missing something?

DavidRodriguez-dfgt
Автор

It is easy to make mistakes in C but they're not impossible to avoid if you're aware of a few simple rules. Failing that, there are tools to help you like static analyzers. Adding optional extensions to the C language for safety and reliability would, in many cases, be a better approach than doing a complete rewrite in a different language.

saturdaysequalsyouth
Автор

The rust docs are pretty good. I have been passively reading them for about two weeks 🙂

vitorsantos
Автор

C and C++ never die. The most powerful and the most versatile languages ever made. People just need different experiences and that’s why they are making alternatives.

TekCroach