Rust 101 – 29: Trait objects and object safety

Trying to explain why the rules for object safety are the way they are, and how to create and use a trait objects.

Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe

This section (Trait objects): 28: Dynamic dispatch, 29: Object safety, 30: Patterns, 31: Exercise D1, 32: Exercise D2, 33: Exercise D3

Links:

The course materials for this series are developed by tweede golf. You can find more information at github.com/tweedegolf/101-rs and you can sponsor the work at github.com/sponsors/tweedegolf. They are released under the Creative Commons Attribution Share Alike 4.0 International license.

This series of videos is copyright 2024 Andy Balaam and the tweede golf contributors and is released under the Creative Commons Attribution Share Alike 4.0 International license.

Rust 101 – 28: Dynamic dispatch

Explaining how to hold on to something even when we don’t know its exact type, just what trait it implements.

Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe

This section (Trait objects): 28: Dynamic dispatch, 29: Object safety, 30: Patterns, 31: Exercise D1, 32: Exercise D2, 33: Exercise D3

Links:

The course materials for this series are developed by tweede golf. You can find more information at github.com/tweedegolf/101-rs and you can sponsor the work at github.com/sponsors/tweedegolf. They are released under the Creative Commons Attribution Share Alike 4.0 International license.

This series of videos is copyright 2024 Andy Balaam and the tweede golf contributors and is released under the Creative Commons Attribution Share Alike 4.0 International license.

New home for my videos: video.infosec.exchange

Huge thanks to Micah Scott for hosting my videos on diode.zone until recently.

My videos are moving to video.infosec.exchange/a/andybalaam – please update all your feeds. (Thanks to Jerry Bell for running that – please donate!)

You can follow this blog for an “always” reliable source of truth for my stuff.

Following me on Mastodon at @andybalaam@mastodon.social is likely to be pretty reliable too.

I will remove the live recordings from diode.zone quite soon, to free up space. I will leave the lectures up there for as long as possible, but they may go away at any time.

Why I won’t link to AI resources

I received a very kind email today from someone who had found my page Resources for year 6 teachers on coding and programming helpful, and wanted to suggest another link for me to add, about AI resources.

I’m sure it was a helpful and useful link, but I didn’t feel able to add it. Here’s the email I wrote explaining why:

Hi,

Thank you for your email, and I’m really glad you found the resources on my web site helpful.

I’m very sceptical about AI, and so cautious about recommending resources about it. Of course, I think it’s important for students to learn about the techniques involved and the potential benefits and harms it can have for our society, but before I could link to resources I would need to do lots of research to be sure I could stand behind what was being said.

If you are surprised to hear I feel quite negatively about AI, my concerns fall in three different areas:

  • taking other people’s work and passing it off as your own – systems like ChatGPT and DALL-E consume vast amounts of copyrighted material and produce output that is derived from it without any reward for the people who created it.
  • incorrect results, dangerous behaviour and bias – many companies are promoting AI assistants and even AI “friends”, making bold statements about their reliability, despite numerous example of bots being “tricked” into saying dangerous things (e.g. promoting suicide) or simply acting in biased ways (e.g. Amazon’s recruiting AI that was biased against women). Machine learning models are characterised by the fact that we don’t know how they work, so we can’t make any supportable claims about how they will behave.
  • environmental impact – training these models takes vast amounts of energy and water. These costs are currently being hidden by the huge amount of money being invested in the hope that there will be a great return in terms of value. I don’t think much value has been generated so far…

Of course, I believe we will eventually integrate AI into our society, and hopefully in a responsible way (although I have my doubts) but right now I see it as mostly a massive hype cycle, like cryptocurrency and “the cloud” before it.

I’m sorry I can’t provide links to back up my arguments, but I am suffering from the same problem: I don’t have time to check my sources properly so I can be sure I’m sending you reliable information. I do encourage you to research further!

So, apologies for not being able to help (and for writing you an essay!) but I can’t add the link you so kindly suggested.

Good luck in your project,

Andy

Rust 101 – 27: Exercises for module C (q2)

Implementing a simplified form of Mutex.

Series: Language basics, More syntax, Traits and generics, Building applications, Concurrency and parallelism, Trait objects, Async, Unsafe

This section (Concurrency and parallelism): 24: Parallelism, 25: Threads, 26: Exercise C1, 27: Exercise C2

Links:

The course materials for this series are developed by tweede golf. You can find more information at github.com/tweedegolf/101-rs and you can sponsor the work at github.com/sponsors/tweedegolf. They are released under the Creative Commons Attribution Share Alike 4.0 International license.

This series of videos is copyright 2024 Andy Balaam and the tweede golf contributors and is released under the Creative Commons Attribution Share Alike 4.0 International license.