Тёмный

An introduction to structs, traits, and zero-cost abstractions by Tim McLean - Rust KW Meetup 

Rust
Подписаться 62 тыс.
Просмотров 30 тыс.
50% 1

This video was recorded during the Rust KW Meetup in Kitchener-Waterloo, ON, Canada on May 9, 2018.
www.meetup.com/Rust-KW/events...
This talk is targeted at programmers with experience in other languages but who are new to Rust. We will start with a quick introduction to structs and traits, then look at how we can use structs, traits, and generics to build abstractions and write better code without sacrificing performance.
Talk written and presented by: Tim McLean ( / mclean0 )
Recording: Mark Sherry

Наука

Опубликовано:

 

7 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 22   
@flyingsquirrel3271
@flyingsquirrel3271 6 лет назад
Great talk, thanks a lot! The part about the difference between the compilation of generics vs trait objects was an eye opener for me :)
@manjunath3929
@manjunath3929 5 лет назад
We need more talks like this. This helps the way we code by understanding the performance implications.
@MarcosScheeren
@MarcosScheeren 5 лет назад
Wow! Great talk! Dove into the compiler optimizations while keeping the explanation simple and direct.
@mkvalor
@mkvalor 5 лет назад
I know I'm 9 months late, but I really enjoyed this video. You did a really great job of clearly explaining a complex topic. I wanted to mention that it is not necessarily true that the compiler generates more code in the templated case. Just because the compiler could generate implementation code for all the different Logger types does not mean that it is under obligation to do so. At the time of compilation, it is set in stone which implementation(s) will be required, so the compiler is free to generate only the code which is required at each generic reference. In a typical logging scenario, this would be one kind of logging for the entire binary, across all function calls which uses such a reference. And, indeed, that is what your analysis of the object code reveals at the end.
@teenageoperator7246
@teenageoperator7246 2 года назад
damn - short, sweet, and to-the-point. fantastic!
@sandtrick
@sandtrick 3 года назад
New to programming here. Worked about halfway through nand2tetris and this talk was fuel on the fire! Accessible and interesting. Thank you!
@astarothgr
@astarothgr 4 года назад
Clear presentation, straight and to the point!!
@GautamSinghSinsinwar
@GautamSinghSinsinwar 6 лет назад
Great presentation Tim!
@binrui
@binrui 5 лет назад
Amazing talk, clear my doubts about traits! Thanks a lot!
@WasifHasanBaig
@WasifHasanBaig 5 лет назад
Very insightful, thanks!
@YzorYzor
@YzorYzor 4 года назад
Really awesome talk!
@GlobalYoung7
@GlobalYoung7 2 года назад
thank you
@MikaelMurstam
@MikaelMurstam 2 года назад
The last part was really interesting. I wonder if it's the same in C++.
@David-ws3rw
@David-ws3rw 4 года назад
From the presentation I didn't understand if the runtime polymorphic version of the function can cohesist together with the compile-time polymorphic version of the same function...
@debasishraychawdhuri
@debasishraychawdhuri 4 года назад
The only performance problem with rust is when the borrow-checker rejects perfectly sound code that would be more performant than what it takes to satisfy the borrow checker. Otherwise, it has a zero-cost abstraction. But the borrow-checker is one of my favorite features.
@geshtu1760
@geshtu1760 4 года назад
I wasn't aware of the possibility of using generics in place of trait objects. Are there places where you can't do that?
@erlendpowell2644
@erlendpowell2644 4 года назад
The generics approach is considered much more idiomatic, and should be preferred in general. Where you wouldn't be able to use generics, would be in scenarios where you need dynamic dispatch (i.e. when using trait inheritance).
@AvindraGoolcharan
@AvindraGoolcharan 3 года назад
21:05 Generics vs Traits
@cdharmateja4726
@cdharmateja4726 5 лет назад
How to see that machine generated code?
@peter9477
@peter9477 2 года назад
Probably objdump with -s (I believe... going by memory here).
@bitflogger
@bitflogger 3 года назад
Or, make the compiler work as much as possible. Compile once, execute a billion times. Good choice.
@julkiewicz
@julkiewicz 5 лет назад
In my experience generics used in this style don't scale well. If your method internally uses X which then internally uses Y, Z, W, then the template function ends up having to expose X, Y, Z, W. It grows and grows with each level of wrapping. You can use generics in this style in C# or Java or any other more traditional language. And in C# at least with structs it essentially also incurs zero cost. It would be cool to invent a zero-abstraction pattern that actually scales.
Далее
🦀  Rust Copy trait VS Clone trait
5:47
Просмотров 2,6 тыс.
Luiza Rasulova #luizarasulova
00:37
Просмотров 613 тыс.
Rust on ESP32 - Creating an HTTP api
16:43
Просмотров 1,9 тыс.
RustConf 2023 - How Powerful is Const
22:58
Просмотров 13 тыс.
Lec 2 | MIT 9.00SC Introduction to Psychology, Spring 2011
1:11:16
Elliptic Curves - Computerphile
8:42
Просмотров 540 тыс.
RustLatam 2019 - Without Boats: Zero-Cost Async IO
32:24
Traits in Rust
11:44
Просмотров 96 тыс.
Rust Structs, Traits and Impl
24:53
Просмотров 33 тыс.
S-Pen в Samsung достоин Золота #Shorts
0:38