Rust stole C++'s best features

preview_player
Показать описание
In this video, we dive deep into the best feature Rust stole from C+.+ I'll break down exactly what these features are and show you how the creators of Rust have innovated on top of them. Stick around till the end where I'll discuss the biggest challenge Rust faces in its quest to compete with and potentially replace C++.

Chapter:
0:00 Intro
0:18 1st feature
3:27 2nd feature
5:33 3rd feature
7:27 Rust major limitation
Рекомендации по теме
Комментарии
Автор

Not "stole", but "borrowed"

konstantinta
Автор

Rust absolutely took RAII, smart pointers, zero overhead abstractions from C++. However I would argue that Rust's generics are more likely been inspired by ML languages like Ocaml and Haskell. I might be wrong about this so please correct me if Im wrong.

torarinvik
Автор

I wish you hadn't blurred your section titles at the beginning. I get that it's good for the algorithm to keep people watching, but it doesn't feel like it's optimized for teaching.

> Rust only allows you to allocate resources using RAII constructs.

There are raw alloc/dealloc functions; they're just unsafe.

> Rust has made generic programming more accessible and safer, while maintaining its power...

There are important things that you can do with C++ templates but not with Rust generics. Templates offer "compile-time duck typing", which is why they're so flexible but also why their compiler errors are noisy. Rust doesn't (yet?) have specialization, and its const features are more limited. Maybe this is nitpicking of me, but your channel is prominent on YouTube, and I think it's important for prominent Rust advocates to get these little details right. Experienced C++ folks tend to pick up on this stuff, and it makes them feel like they can't trust Rust folks to talk about tradeoffs fairly.

oconnor
Автор

Ironically, C++ just got a large proposal called Safe C++. It includes safety-by-default and the unsafe keyword, borrows and lifetimes, MIR and a borrow checker, destructive moves and relocatable types, send/sync traits, and more. If it passes, soon C++ will have stolen Rust's best features right back!

OMGclueless
Автор

What I really miss in Rust is stable ABI, and creating libraries in Rust for Rust apps, to prevent creating Rust apps as one big monolith

adrian_spdef
Автор

A HUGE thing that Rust is missing is dynamic linking of libraries and stable ABI. Everything compiles to a huge binary, which is ok (and even desirable) for big apps but much less so for small tools and helpers.

frozen_spider
Автор

Sadly one of the things Rust still hasn't stolen from C++ is its capability for Compiletime-Programming. Rust's const still feels like C++14 constexpr which is well 10 years old. Really hope to see Rust improve in that regard.

MegaKillzor
Автор

70% of bugs are memory safety issues because of c++ or becaue of ugliness windows C API where struct names are sequence of random characters someone has written by smashing keyboard by hand ?

DJenriqez
Автор

All the examples you shared really demonstrate the elegance of Rust

alexandervantrijffel
Автор

Why is every video on Rust the exact same? Every Rust content creator seems to just re-hash the same three talking points over, and over, and over, and over again. Like, I could already guess two of the three points within three seconds of reading the title.

SkyyySi
Автор

This was a nice video, I like Rust, I'm glad it exists and I'll try to learn some in the future. To be honest the only reason I haven't tried learning it so far is because the code just looks ugly to me. I admit the generics look cleaner though.

Also the argument at 5:00 doesn't seem valid to me, any good C++ programmer would tell you not checking the return value of a non [[nodiscard]] function is a bug in itself. Had you just checked to make sure the iterator was valid to dereference, it would have been the equivalent to Rust's match case. It seems like you intentionally wrote two different pieces of code to do two different things, and then tried to compare them as if they did the same thing?

maxbd
Автор

Rust has manual free types but its all in unsafe. The main thing rust does with RAII that C++ is not the restriction but rather the checking

In C++ when u want to pass refrences u do a .get() or even give a refrence. But nothing actually checks ag9nst uae after free here.

RAII actually makes it easier to do use after free when passing pointers

nevokrien
Автор

C++ template syntax with concepts or auto deduction is actually more readable than Rusts edition... As far as I'm concerned this Rust video was already outdated even before it came out.

DerDoMeN
Автор

glad this language arrived when it did, bridging the web and hardware levels sucks sometimes, it's a big world down there

johnstafford
Автор

You can see the RAII in VSCode, there’s an option showing when drop() is called on an object

Kaptime
Автор

First thought after reading the caption: Undefined behaviour? )

fdfzyuq
Автор

Rust is great for writing self-contained applications. The lack of a way to expose functionality to C limits it for writing libraries. That's a shame, because this is what prevents us rewriting core Linux libraries and makes it harder for Linux kernel development.

mrpocock
Автор

I think one big issue holding compatibility with other languages back is the lack of a defined abi.
Not having an abi prevents other languages to support rust as a direct and efficient ffi target.

For example I am currently designing a language similar to rust but with some personal changes. I would like to support many languages as native abi targets allowing for seamless integration and mixing of code written in the different languages. With a defined abi even direct inline mix and match code would be possible. As my language is similar to rust and holds many of the same guarantees even safe to safe function interaction would work.

redcrafterlppa
Автор

3:04 -- "data races"
Not quite. Most data races (not all) are caused by memory being shared across thread boundaries. Rust prevents this in another way, by requiring data that is shared between threads to implement specific traits (Send and Sync).

TheEvertw
Автор

Thank you for this greatly explained and concise summary!

iceginlychee