Sophia Teaches Jason Rust! – Part 2

RUST情報

Previous title: Learning Rust Homework Review With Sophia – Game of Life

For this Rust episode I will have already implemented a Game of Life simulator https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life as a homework assignment and Jonathan will be reviewing my implementation.

Implement your own Game of Life simulator in rust and join us for the live stream and discussion!

The example from the last stream is currently up at https://github.com/lefticus/learning-rust

☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟

T-SHIRTS AVAILABLE!

► The best C++ T-Shirts anywhere! https://my-store-d16a2f.creator-spring.com/

WANT MORE JASON?

► My Training Classes: http://emptycrate.com/training.html
► Follow me on twitter: https://twitter.com/lefticus

SUPPORT THE CHANNEL

► Patreon: https://www.patreon.com/lefticus
► Github Sponsors: https://github.com/sponsors/lefticus
► Paypal Donation: https://www.paypal.com/donate/?hosted_button_id=PQ4A2V6ZZFQEU

GET INVOLVED

► Video Idea List: https://github.com/lefticus/cpp_weekly/issues

JASON’S BOOKS

► C++ Best Practices
Amazon Paperback: https://amzn.to/3wpAU3Z
Leanpub Ebook: https://leanpub.com/cppbestpractices

JASON’S PUZZLE BOOKS

► Object Lifetime Puzzlers Book 1
Amazon Paperback: https://amzn.to/3g6Ervj
Leanpub Ebook: https://leanpub.com/objectlifetimepuzzlers_book1

► Object Lifetime Puzzlers Book 2
Amazon Paperback: https://amzn.to/3whdUDU
Leanpub Ebook: https://leanpub.com/objectlifetimepuzzlers_book2

► Object Lifetime Puzzlers Book 3
Leanpub Ebook: https://leanpub.com/objectlifetimepuzzlers_book3

► Copy and Reference Puzzlers Book 1
Amazon Paperback: https://amzn.to/3g7ZVb9
Leanpub Ebook: https://leanpub.com/copyandreferencepuzzlers_book1

► Copy and Reference Puzzlers Book 2
Amazon Paperback: https://amzn.to/3X1LOIx
Leanpub Ebook: https://leanpub.com/copyandreferencepuzzlers_book2

► Copy and Reference Puzzlers Book 3
Leanpub Ebook: https://leanpub.com/copyandreferencepuzzlers_book3

► OpCode Puzzlers Book 1
Amazon Paperback: https://amzn.to/3KCNJg6
Leanpub Ebook: https://leanpub.com/opcodepuzzlers_book1

RECOMMENDED BOOKS

► Bjarne Stroustrup’s A Tour of C++ (now with C++20/23!): https://amzn.to/3X4Wypr

AWESOME PROJECTS

► The C++ Starter Project – Gets you started with Best Practices Quickly – https://github.com/cpp-best-practices/cpp_starter_project
► C++ Best Practices Forkable Coding Standards – https://github.com/cpp-best-practices/cppbestpractices

O’Reilly VIDEOS

► Inheritance and Polymorphism in C++ – https://www.oreilly.com/library/view/inheritance-and-polymorphism/9781491961933/
► Learning C++ Best Practices – https://www.oreilly.com/library/view/learning-c-best/9781491954898/

Views:21337
Taqs:c++,rust,learning rust,introduction to rust,rust vs c++,rust ide

コメント

  • コメント (26)

  • トラックバックは利用できません。

    • @mateusoliveira2776
    • 2024年 3月 14日 7:30am

    I like that you can’t default values on structs. Feels simple. You use the simple tools you have, good practice and common sense to accomplish stuff. Other people also starting doing it and it becomes best practice. You have a struct, you have member/associated functions and that’s it. Coming from kotlin with “class”, “data class”, “value class”, “sealed class”, “object”, “companion object”, “inner class”, “enum class” etc., each with it’s own quirks and perks… I really needed something that’s just a set of simple, powerful, building blocks, lol.

    • @yato3335
    • 2024年 3月 14日 7:30am

    The task manager thing can be a virus. Some sort of a Bitcoin miner. I had this at my PC and I had to reinstall Windows. These things has gotten really insidious.

    Windows OS doesn’t do it like that. It does this only when you’re truly AFK.

    • @pmcgee003
    • 2024年 3月 14日 7:30am

    Neighbours (tv show) is only just ending now.

    • @semigsedem
    • 2024年 3月 14日 7:30am

    As a rust beginner I really appreciated all the small things covered, that I didn’t learn from the documentation / books. Thanks alot for this content. I love the 10 seconds thinking pauses for Jason to decide if a certain rust language feature makes him “uncomfortable” (concerned about concistency and safety) 🙂

    • @Rypervenche
    • 2024年 3月 14日 7:30am

    I hope you do more Rust episodes in the future.

    • @benedyktjaworski9877
    • 2024年 3月 14日 7:30am

    Assert on index before indexing a vector indeed might help the optimizer. Rust adds bounds checks on indexing, so if you do `vec[index]`, Rust will add panicking `index < vec.len()` bounds checks here. Now, if you did `assert!(index < vec.len());` yourself earlier, those automatic checks will be elided. So if you need to eg. loop over some values and do indexing in that loop, putting an assert before the loop is a good idea for optimization. Rust has also an unsafe `.get_unchecked(index)` method that works like indexing in C or C++ without any bounds checking, but most often when you know the value passed must be correct it’s just better in Rust to use the safe indexing and do the assert before.

    • @DenisKhoroshev
    • 2024年 3月 14日 7:30am

    Nomadic function is an std::function which moves around a lot.

    • @s4ecki
    • 2024年 3月 14日 7:30am

    I can really reccomend IntelliJ with the rust plugin, just works flawlessly for me.

    • @whydoineedausername1386
    • 2024年 3月 14日 7:30am

    It bothers me that you copied the original values instead of just setting them to std::usize::MAX originally and explicitly calling usize::wrapping_add in the Iterator implementation

    • @paulm.bendixen6682
    • 2024年 3月 14日 7:30am

    Is partitioning into separate files not best practice in rust?

    • @flyingsquirrel3271
    • 2024年 3月 14日 7:30am

    3:31:00 just create a let binding to the board returned by life.next()? and use mem::swap to put it into the life and get the other board out of it.

    • @flyingsquirrel3271
    • 2024年 3月 14日 7:30am

    52:30 just make that closure return a result and use the ? within it and when calling it 😉

    • @kein3001
    • 2024年 3月 14日 7:30am

    Rust anylezer is using all your cores if you do not configure it to use less

    • @VladyVeselinov
    • 2024年 3月 14日 7:30am

    Can’t wait for part 3

    • @jroberts3425
    • 2024年 3月 14日 7:30am

    This is a great series, thanks!

    • @whytevuhuni
    • 2024年 3月 14日 7:30am

    I really like this Turner/Turner combo: one of you is very skeptical and sharp, the other’s always very cheery and permanently smiling, which makes for nice interactions. I’m glad you guys got together on this.

    • @ian3084
    • 2024年 3月 14日 7:30am

    self.x is great to enforce. It’s about time for a language with some nice, damn strict conventions.

    • @komolunanole8697
    • 2024年 3月 14日 7:30am

    There’s a rather loud background noise at times (at 3:10:50 for example), which slowly ramps up and then suddenly dies down. Is the mic picking up a computer fan?

    • @Measter21
    • 2024年 3月 14日 7:30am

    I can sympathise with you from the other side about getting the struct field names and types the wrong way round. I’ve been writing some C++ recently for the first time in years, and I keep doing it the Rust way.
    And those semi-colons after class/enum definitions. I forget those every time.

    • @EmbeddedSorcery
    • 2024年 3月 14日 7:30am

    Any cast in C++ is codesmell?? I work with bare metal embedded code a lot, and see this VERY often. I’m not sure I see the issue. Some peripherals and IC’s have data types that are in various forms that the micro needs to handle, and that is often going to involve some sort of integer reformatting. IAR compiler doesn’t even warn you when you use reinterpret_cast in a constexpr assignment lol.

    • @Diventurer
    • 2024年 3月 14日 7:30am

    While Rust does solve some problems, the syntax is so unnecessarily cumbersome that I don’t think I’ll use it.

    • @mithradates
    • 2024年 3月 14日 7:30am

    On the subject of unwrap at 1:13:00, Programming Rust has a good quote on the rare cases where unwrap() or .expect() is okay and sometimes even preferable that I think explains the usage quite well:
    “That said, situations do come up where a Result value truly can’t be an
    error. For example, in Chapter 18, you’ll see that the Write trait defines a common set of methods (.write() and others) for text and binary output. All of those methods return io::Results, but if you happen to be writing to a Vec, they can’t fail. In such cases, it’s acceptable to use .unwrap() or .expect(message) to dispense with the Results.
    These methods are also useful when an error would indicate a condition
    so severe or bizarre that panic is exactly how you want to handle it.
    fn print_file_age(filename: &Path, last_modified: SystemTime) {
    let age = last_modified.elapsed().expect(“system clock drift”);

    }
    Here, the .elapsed() method can fail only if the system time is earlier than
    when the file was created. This can happen if the file was created recently, and the system clock was adjusted backward while our program was running. Depending on how this code is used, it’s a reasonable judgment call to panic in that case, rather than handle the error or propagate it to the caller.”

    • @TheOfficialFred96
    • 2024年 3月 14日 7:30am

    All of these IDE problems would be solved with the Rust plugin on Clion, which is must better atm lol

    • @DamianReloaded
    • 2024年 3月 14日 7:30am

    For c++ I decided to start using lambdas instead of macros in a library I’m coding right now.

    • @mithradates
    • 2024年 3月 14日 7:30am

    I love this series! As someone mostly only familiar with Rust it gives me the chance to get some exposure to a bit of C++ thinking and terminology at the same time.

    • @arthurararuna
    • 2024年 3月 14日 7:30am

    The video got trimmed out to only 2h… Where is the other 1h30?