Jack O'Connor
Jack O'Connor
  • 9
  • 133 394
Rust can Compete with Python
The slower version: th-cam.com/video/dA9khrib_lMS/w-d-xo.htmllides: jacko.io/rust_python/slides/
Contents:
00:00 Intro
04:31 Enums (and null pointer bugs)
14:58 Destructors (and resource leaks)
37:15 Aliasing Rules (and "spooky action at a distance")
51:54 Functional Languages
55:28 Standalone Scripts
The Cargo script RFC: rust-lang.github.io/rfcs/3502-cargo-script.html
I didn't consciously write my slides this way, but in retrospect the main sections exactly match the "What makes Rust work" concepts from this 2019 article: without.boats/blog/notes-on-a-smaller-rust/
มุมมอง: 4 091

วีดีโอ

[SLOWER VERSION] Rust can Compete with Python
มุมมอง 6113 หลายเดือนก่อน
The faster version: th-cam.com/video/OQTwvycftJU/w-d-xo.html Slides: jacko.io/rust_python/slides/ Contents: 00:00 Intro 04:53 Enums (and null pointer bugs) 24:48 Destructors (and resource leaks) 1:02:58 Aliasing Rules (and "spooky action at a distance") 1:22:29 Functional Languages 1:26:33 Standalone Scripts The Cargo script RFC: rust-lang.github.io/rfcs/3502-cargo-script.html I didn't consciou...
A First Look at Lifetimes in Rust
มุมมอง 3.7K8 หลายเดือนก่อน
The slow version: th-cam.com/video/WgXV_0HiwOc/w-d-xo.html Contents: 00:00 Intro 01:22 Starting Code 04:01 A Broken Function 06:03 A Generic Function 10:01 Explicit Lifetimes 14:30 A Common Mistake 16:24 Subtyping and Variance Code: - starting: play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6eeecd2b7b1e63ae0a50886eff6ba0c9 - broken: play.rust-lang.org/?version=stable&mode=debug...
[SLOWER VERSION] A First Look at Lifetimes in Rust
มุมมอง 1K8 หลายเดือนก่อน
The fast version: th-cam.com/video/-gkvOoxgp8E/w-d-xo.html Contents: 00:00 Intro 01:13 Starting Code 05:58 A Broken Function 09:24 A Generic Function 17:12 Explicit Lifetimes 26:00 A Common Mistake 27:50 Subtyping and Variance Code: - starting: play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6eeecd2b7b1e63ae0a50886eff6ba0c9 - broken: play.rust-lang.org/?version=stable&mode=debug...
Unsafe Rust is not C
มุมมอง 27K2 ปีที่แล้ว
Unsafe Rust is like C in some ways, but there are tricky rules that unsafe Rust has to follow that don't exist in C. C also has some tricky rules of its own. This is a talk about some of these differences, particularly when it comes to pointer aliasing. I've gone through the autogenerated subtitles and made lots of corrections, so hopefully the subtitles are tolerable if not great. Contents: 00...
A Firehose of Rust, for busy people who know some C++
มุมมอง 85K3 ปีที่แล้ว
Slides: jacko.io/firehose_of_rust The slower version of this talk (2h32m): th-cam.com/video/FSyfZVuD32Y/w-d-xo.html Contents: 0:00:00 introduction 0:04:03 references and mutable aliasing 0:06:54 reference lifetime examples 0:22:12 mutable aliasing examples 0:50:16 move semantics 1:10:50 Arc Mutex String Links from screenshots in slides: godbolt.org/z/891s6z4Tb th-cam.com/video/xnqTKD8uD64/w-d-x...
[SLOWER VERSION] A Firehose of Rust, for busy people who know some C++
มุมมอง 8K3 ปีที่แล้ว
Slides: jacko.io/firehose_of_rust The faster version of this talk (1h24m): th-cam.com/video/IPmRDS0OSxM/w-d-xo.html Contents: 0:00:00 introduction 0:04:41 references and mutable aliasing 0:08:01 reference lifetime examples 0:29:57 mutable aliasing examples 1:10:26 move semantics 2:01:10 Arc Mutex String Links from screenshots in slides: godbolt.org/z/891s6z4Tb th-cam.com/video/xnqTKD8uD64/w-d-x...
Bao, a general purpose cryptographic tree hash, and perhaps the fastest hash function in the world
มุมมอง 3.9K5 ปีที่แล้ว
UPDATE for 2020: The Bao project at the time of this talk was two things, a custom tree hashing mode based on BLAKE2, and an implementation of verified streaming based on that tree mode. In the year after I gave this talk, the tree mode evolved into BLAKE3, which we released on January 9, 2020. The current version of Bao no longer defines a tree mode of its own, but instead implements verified ...
BLAKE2b and the bao tree mode: SIMD and multithreaded hashing in Rust
มุมมอง 7436 ปีที่แล้ว
This is a lightning talk from the 28 August 2018 Rust NYC meetup. I've tried to take out the audio noise, but it's still pretty hard to hear, apologies. I've hand-written the subtitles to compensate, and I recommend turning those on. Repo links from the talk: github.com/oconnor663/blake2b_simd github.com/oconnor663/bao Event page: www.meetup.com/Rust-NYC/events/253565886

ความคิดเห็น

  • @nd7024
    @nd7024 5 วันที่ผ่านมา

    This is the video I wish I saw when I started with rust

  • @franciscogarridodefigueire591
    @franciscogarridodefigueire591 7 วันที่ผ่านมา

    I tried the code in the minute 15:00 myself, and using compiler explorer like in the video found that this rust UB does not happen anymore from rustc 1.75.0 forward. Can anyone else confirm this as I dont seem to find the explanation specified in the 1.75.0 update change log.

    • @oconnor663
      @oconnor663 7 วันที่ผ่านมา

      Thanks for catching this. To reproduce the same bug on current Rust, I need to add #[inline(never)] above foo(). Here's an updated godbolt: godbolt.org/z/T6od4qsoz. Using cargo-bisect-rustc, it looks like the first nightly that "broke" the original example was 2023-10-19. Of the commits that went in that day, it looks like one of them was an LLVM update, which was probably the culprit: github.com/rust-lang/rust/pull/116840. I'll add this to the list of errata in the video description, and I'll add the updated godbolt to the list of links.

  • @LeonMerk123
    @LeonMerk123 หลายเดือนก่อน

    Nice vid but you sound like you're on cocaine

  • @Lapatate-s1l
    @Lapatate-s1l หลายเดือนก่อน

    Very nice explanation . Really appreciate that

  • @adityamwagh
    @adityamwagh หลายเดือนก่อน

    Hey, how did you make these slides? Seems like a great way to explain programming concepts!

    • @oconnor663
      @oconnor663 หลายเดือนก่อน

      Reveal.js :)

  • @buensofvida
    @buensofvida 2 หลายเดือนก่อน

    brilliant way of presenting the nuts and bolts, thank you 👍

  • @soniablanche5672
    @soniablanche5672 2 หลายเดือนก่อน

    It would probably be undefined behavior in C if you declared x and y as restrict pointers, that tells the compiler x and y cannot be aliased so it optimizes accordingly and always return 42

    • @oconnor663
      @oconnor663 2 หลายเดือนก่อน

      Correct!

  • @JJSogaard
    @JJSogaard 2 หลายเดือนก่อน

    Before I started using Rust, I thought it was a bit of a cult. Well... I'm afraid I've become a cultist...

  • @dhruvkhara
    @dhruvkhara 3 หลายเดือนก่อน

    Amazing explanation, thanks!

  • @Takatou__Yogiri
    @Takatou__Yogiri 3 หลายเดือนก่อน

    great video.

  • @Takatou__Yogiri
    @Takatou__Yogiri 3 หลายเดือนก่อน

    came after seeing your "Shameless self-promotion :) th-cam.com/video/OQTwvycftJU/w-d-xo.html"

    • @codemob
      @codemob 2 หลายเดือนก่อน

      same!

  • @Iturner72
    @Iturner72 3 หลายเดือนก่อน

    this is exactly the content i am looking for! incredibly well put together, thanks for this mr O'Connor :)

  • @meanmole3212
    @meanmole3212 3 หลายเดือนก่อน

    Great job!

  • @BrianMelancon
    @BrianMelancon 3 หลายเดือนก่อน

    Excellent tutorial! I like that you not only explain how the Rust features work and why they work that way, but you also give examples to show the reasons that they work the way they do. This is the clearest explanation I've seen on the topic.

  • @nerd-nq5ic
    @nerd-nq5ic 3 หลายเดือนก่อน

    The perfect Rust video doesn't exi-

  • @phenanrithe
    @phenanrithe 3 หลายเดือนก่อน

    Python and Rust are completely different animals for completely different purposes, and they'll never compete with one another. Python is great for interactivity, learning, and easy-to-make scripts, when clarity and accessibility are important. It also has a lot of libraries. Rust is good for memory-safe and quick programs, but it's too complex and distracting for a learner and not interactive. Python is GC, Rust isn't. Python is mature and Rust isn't. Python is OO and Rust isn't (really). Don't compare apples and oranges.

    • @kevinmcfarlane2752
      @kevinmcfarlane2752 3 หลายเดือนก่อน

      The underrated F# is a better fit with Python than Rust and is more mature and can play better with the Python ecosystem.

    • @stretch8390
      @stretch8390 3 หลายเดือนก่อน

      Comparing programming language apples and oranges is a great way to figure out what one might prefer or need for a particular problem though.

  • @julkiewitz
    @julkiewitz 3 หลายเดือนก่อน

    57:54 is the reason why the whole complaning about "undefined behaviour should be defined" makes absolutely no sense. It just stems from lack of understanding of how an optimizing compiler works in detail. There is no useful way to define undefined behavior.

  • @julkiewitz
    @julkiewitz 3 หลายเดือนก่อน

    That's the video for all the ignoramuses that claim that Rust is overcomplicated. No, Rust is exactly as complicated as the problem that it's solving. Many people write undefined behaviour in C without ever knowing it, all it takes is one recast. Not to mention the absolutely ridiculous performance hit that comes from poor optimization coming from pessimistic aliasing analysis. Yes, you don't run into that sort of an issue often, but in larger code bases you inevitably will run into a problem like this. And it can literally take weeks to track down.

  • @stewartli5395
    @stewartli5395 3 หลายเดือนก่อน

    very true. thank you :)

  • @boyangwang1507
    @boyangwang1507 3 หลายเดือนก่อน

    Love you!

    • @boyangwang1507
      @boyangwang1507 3 หลายเดือนก่อน

      Just encountered something in our code base today. Our FileStatus contains two bools, isOpen and isClose. So this creates 4 combinations, but some of them are not valid

    • @oconnor663
      @oconnor663 3 หลายเดือนก่อน

      ❤️❤️❤️

  • @danielrhouck
    @danielrhouck 3 หลายเดือนก่อน

    27:00 Rust, like everyone else, does *not* guarantee cleanup code will be called correctly every time. It will in this case (as with any RAII language) but `std::mem::forget`, `Box::leak`, and reference cycles are all possible in safe Rust.

    • @theopantamis9184
      @theopantamis9184 3 หลายเดือนก่อน

      Well yes but you cannot really miss the fact that you called such functions by yourself (or the dev of a lib that you use but a good lib will always handle cleanup) or choose to use a type of ref that allows ref cycles, which can still be cleaned up sooner because you have often clear distinction and restrictions between strong, that clean up resources when all dropped, and weak ref that cannot.

    • @lukasloen4659
      @lukasloen4659 3 หลายเดือนก่อน

      I believe it's also not called on statics either Not to say I don't love Rust with all my heart.

  • @isotope3491
    @isotope3491 3 หลายเดือนก่อน

    Good job not being red in this video ;) (Also, great video as always!)

    • @oconnor663
      @oconnor663 3 หลายเดือนก่อน

      Taking it one step at a time over here :)

  • @odayprogrammer
    @odayprogrammer 3 หลายเดือนก่อน

    except no one can read it

    • @earomc
      @earomc 3 หลายเดือนก่อน

      You can. It's maybe a bit hard for a beginner but it's very readable at latest after a couple weeks.

  • @BooksumDev
    @BooksumDev 3 หลายเดือนก่อน

    except no one can read it

  • @nevokrien95
    @nevokrien95 3 หลายเดือนก่อน

    In python there IS SPECIFCLY with for the reasource issue and its quite nice. No need to pretend thst this is something we run into because it's not actually a thing in python

    • @oconnor663
      @oconnor663 3 หลายเดือนก่อน

      Did you make it to 24:26? My goal with the open_outputs function was to talk about a case where `with` doesn't work for us. Another issue there that I didn't go into in this recording, is that lists aren't context managers in Python, so there's not an easy way to use the list of ScreamingOutputs with a `with` statement in the caller.

    • @nevokrien95
      @nevokrien95 3 หลายเดือนก่อน

      @oconnor663 YES which is why I am complaining. You can't show bad python code and complain about the languge. In python the idiomatic way to do IO is With database.connect() as dc: Which automatically gcs the thing when you raise or similar. This is why you will see ALL the material online about python and file IO use a with statment

    • @oconnor663
      @oconnor663 3 หลายเดือนก่อน

      ​@@nevokrien95 Forgive me if I'm repeating something you already understand, but my main point here is that `with` doesn't work in functions like this. If you have a function that's constructing a database connection and *returning* it, and you use `with` in that function, you'll return a *closed* connection and your caller will crash. If it's possible for exceptions to come up in that function after the connection has been opened, and you want to do cleanup correctly in that case, you have no choice but to use try/except (or maybe something more complicated like passing down a contextlib.ExitStack).

    • @nevokrien95
      @nevokrien95 3 หลายเดือนก่อน

      @oconnor663 you open the with externally then send it in... for 99% of cases this works fine. Because most the time you either have 1 static connection in main OR you open a connection per action. In the rare cases you don't it's likely not something you anyway want to do in python for other reasons.

  • @nejathakan5521
    @nejathakan5521 3 หลายเดือนก่อน

    💪

  • @ethanchristensen7388
    @ethanchristensen7388 3 หลายเดือนก่อน

    For the Rayon example, did you consider talking about parallel folding/reducing as an alternative to mutexes? It's faster (I think?) at the cost of learning how to use a functional approach

    • @oconnor663
      @oconnor663 3 หลายเดือนก่อน

      Do you mean like rayon's .sum() method? I'm sure you're right that that would be faster, but the main point of the slide is to show what happens when the closure mutably borrows its environment.

    • @ethanchristensen7388
      @ethanchristensen7388 3 หลายเดือนก่อน

      @@oconnor663 For showing the power of the borrow checker, that's a good example. Yes, there's the sum method, but for more general purposes, there's reduce and fold.

  • @Ambister
    @Ambister 3 หลายเดือนก่อน

    gonna need this version for the mutex part from the original talk :D

    • @oconnor663
      @oconnor663 3 หลายเดือนก่อน

      I do have a slower version of that talk! Is this what you're looking for? th-cam.com/video/FSyfZVuD32Y/w-d-xo.html

  • @Ambister
    @Ambister 3 หลายเดือนก่อน

    brilliant

  • @braden-wong
    @braden-wong 3 หลายเดือนก่อน

    Been a huge fan ever since you released the tutorial on lifetimes! Please put out more videos, I can't stop watching them!

  • @nejathakan5521
    @nejathakan5521 3 หลายเดือนก่อน

    ❤️

  • @scheimong
    @scheimong 3 หลายเดือนก่อน

    Just to interject that there is already a pretty decent rust interpreter named evcxr. Nowadays I use it as my bash replacement whenever a script starts to get too complex.

    • @stretch8390
      @stretch8390 3 หลายเดือนก่อน

      Did not know that. Will be checking it out, thanks!

    • @wassim-akkari
      @wassim-akkari 2 หลายเดือนก่อน

      Yes I use it all the time, it's awesome.

  • @JoJoModding
    @JoJoModding 3 หลายเดือนก่อน

    Re the pathological example around 24:00: This is a consequence of Stacked Borrows rules. Stacked Borrows is overtly strict, since it wants to allow the optimizer to always _add writes to mutable references._ Therefore, it does a "fake write" whenever such a reference is created, and this fake write means the shared reference must die (since otherwise adding an actual write is wrong). As you point out, this is often unintuitive, since no actual write happened. Tree Borrows, the alternative aliasing model for Rust (that we really need to add to the playground) is more lenient. There, your pathological example is not UB. But it loses some optimizations about writes. Which of these will be the official one in the end is as of yet undecided.

    • @JoJoModding
      @JoJoModding 3 หลายเดือนก่อน

      Full disclosure: I am a coauthor of the Tree Borrows rules. If you have any feedback/questions, just ask them here.

    • @oconnor663
      @oconnor663 3 หลายเดือนก่อน

      Oh wow, it's awesome to hear from you. I don't know much about exactly how Tree Borrows is different, but I have to turn it on to get Miri to accept casting a &T into a &ReadOnlyCell<T>, so I'm excited about that :)

    • @JoJoModding
      @JoJoModding 3 หลายเดือนก่อน

      @@oconnor663 Here are some slides that explain it by example: perso.crans.org/vanille/share/satge/arpe/etaps.pdf

  • @wassim-akkari
    @wassim-akkari 4 หลายเดือนก่อน

    Wooow I never thought before that generics in rust include the lifetime with the type. that's a great insite that was completly missing from my understanding thanks alot for this!

  • @mikeyangyang8816
    @mikeyangyang8816 4 หลายเดือนก่อน

    Having the drop function just an empty function is badass. That is so cool that I no longer hate Rust. But I still like C++ more❤

  • @AlejandroColomar-n2q
    @AlejandroColomar-n2q 4 หลายเดือนก่อน

    In 32:17, you say you think the casts [from `(int *)` to `(Foo *)`] are allowed. That's true, since any casts between data pointers are allowed (as long as there are no alignment or similar issues; let's ignore that part). However, I think the same rule of the previous example applies: You cannot access the data through that pointer. You must cast back to `(int *)` before dereferencing. So, the access to `foo1->y` is already illegal (access through a wrong type) even if you would remove the other (partially-overlapping) write.

    • @AlejandroColomar-n2q
      @AlejandroColomar-n2q 4 หลายเดือนก่อน

      You'd need to use either memcpy(3) or a union to be allowed to do type punning.

    • @oconnor663
      @oconnor663 4 หลายเดือนก่อน

      What's the rule on "header" structs? Like if the first field of `struct foo` is of type `struct foo_header`, can I pointer cast between them in some cases? I'm not aware of any rule that says yes, but this also seems to be something that C projects (like CPython) do constantly, as sort of a simple kind of inheritance.

    • @AlejandroColomar-n2q
      @AlejandroColomar-n2q 4 หลายเดือนก่อน

      @@oconnor663 It's <port70.net/~nsz/c/c11/n1570.html#6.5.2.3p6>. That rule still requires that the structures are within a union. So, yes, most C programs that use such structures do trigger UB. For some reason, there's a misconception about this rule, and people seem to believe that just by sharing a first member, two structures are at least partially compatible. That idea probably comes from times _before_ ANSI C, and back then before standard C this was probably true in compilers of that era. There was a discussion about the sockaddr(3type) structures, which are a clear example of UB. Those APIs predate ISO C, and force the programmer and libc to cause UB. It was decided to add wording in POSIX.1-2024 to clarify that compilers must make sure that sockaddr(3type) structures don't cause UB even if they should according to the general rules of ISO C, by using any compiler-specific means (such as compiler attributes that make the types compatible even if they aren't).

    • @AlejandroColomar-n2q
      @AlejandroColomar-n2q 4 หลายเดือนก่อน

      @@oconnor663 <port70.net/~nsz/c/c11/n1570.html#6.5.2.3p6>

    • @AlejandroColomar-n2q
      @AlejandroColomar-n2q 4 หลายเดือนก่อน

      @@oconnor663 It's 6.5.2.3p6. For some reason, youtube was removing my comments with a link. That rule still requires the use of a union. And yes, most programs violate that rule. That misconception that the common initial sequence allows seemingly unrelated structures to be compatible probably comes from the times before ANSI C. Back then, compilers allowed such uses. Now they don't anymore. It's interesting that sockaddr(3type) is a POSIX API which makes a bad use of that rule in the standard. It is a standard API that forced users and libc to invoke UB. The wording in POSIX.1-2024 was changed to say that implementations must use any compiler-specific features (such as attributes) to avoid invoking UB in uses of that API, which according to general ISO C aliasing rules is UB. So, it's basically a recognition that the rules conflict with pre-ISO C.

  • @cereal_learner
    @cereal_learner 4 หลายเดือนก่อน

    Wonderfully 'simply explained' 🙂

  • @srnissen_
    @srnissen_ 4 หลายเดือนก่อน

    I've written a lot of C++ and C. Perhaps too much, because I understood the "pathological example" almost immediately - in the sense that I opened up the playground and every experiment I made came out exactly as predicted, which was a a funny experience because I've barely ever touched Rust, and never Unsafe. But if you're used to thinking about what is- and is-not UB in C/C++ and what optimizations you're hoping to achieve when you use the Restrict keyword (and how Restrict shenanigans can quickly turn UB) then the Rust example almost explains itself. I'm glad you showed it to us, this is really good stuff. EDIT: C.f. the bit about a "false positive" in the borrow-checker - I'm glad you illustrated that "I wish the borrow checker would allow this" is functionally equivalent to "I wish the compiler was less certain about pointer providence so it would be forced to write slower code."

  • @scheimong
    @scheimong 4 หลายเดือนก่อน

    Lifetimes are extremely frustrating for a long stretch of the Rust learning curve, but the moment you finally get it is truly a wonderful experience. That moment for me happened when I was submitting a major PR to the bat project last year, where I had a function that takes an iterator of 2-tuple of two references, one of which is a struct with a distinct lifetime parameter, and returns a hashmap with a reference as the key. It's quite a mouthful but the details aren't super relevant. So I had this feeling that there was going to be a lifetime issue when I wrote the function without explicit annotations, despite RA not immediately yelling at me for it (there were other outstanding errors; lifetimes are checked last). Indeed there was an error, but I wasn't scared or confused because I understood exactly what the issue was. There were four places that needed explicit lifetimes: three in the input iterator and one in the output hashmap. I annotated them appropriately with two lifetime parameters, then very confidently added an outlives bound. And the error went away. `'t: 'r,`. It was less than ten characters but words can hardly describe my immense self-satisfaction. If there is such a thing as "my proudest single line of code", this would be it because it encapsulates the mastery of a very difficult concept. At that moment (or even thinking back about it now) I almost felt like an arcane wizard, if this makes any sense. It was the event after which I could tell myself and everyone, "yeah I understand lifetimes now" and by extension "I've graduated being a Rust beginner" without any imposter guilt. Anyways that's probably enough self gloating. If anyone's interested seeing the code, it's a function named `get_syntax_mapping_to_paths` in the bat repository.

  • @t3chrs
    @t3chrs 6 หลายเดือนก่อน

    Scoped threads fixes your thread example around 1:17:00 with a lot less fuss.

    • @oconnor663
      @oconnor663 6 หลายเดือนก่อน

      Very true. Part of the reason I didn't use scoped threads is that this video came out a year before they stabilized, so I would've needed to pull in crossbeam. But also I didn't want to use a strategy that *only* works in small examples. I wanted the code to look more like it would if you had persistent threads doing work "in the background".

    • @t3chrs
      @t3chrs 6 หลายเดือนก่อน

      @@oconnor663 makes sense. I guess I hadn’t realized the release date of the video.

  • @TheOnlyJura
    @TheOnlyJura 6 หลายเดือนก่อน

    What is this colorscheme please?

    • @oconnor663
      @oconnor663 6 หลายเดือนก่อน

      "Solarized light" ethanschoonover.com/solarized/

  • @robervaldo4633
    @robervaldo4633 6 หลายเดือนก่อน

    Rust is very, very interesting, thanks for these amazing explanations

  • @_noisecode
    @_noisecode 6 หลายเดือนก่อน

    I really can't overstate how incredible this talk is (along with all the other stuff on your channel). Your clear and warm presentation style, your commitment to rigor in your explanations, and your well-crafted examples are all very genuinely impressive and appreciated. Hoping you make more educational content like this--I'll be tuning in.

    • @oconnor663
      @oconnor663 6 หลายเดือนก่อน

      It really feels good to hear that, thanks :)

    • @enticey
      @enticey 3 หลายเดือนก่อน

      Yes, truly incredible way of teaching.

  • @ukaszdrozdz6200
    @ukaszdrozdz6200 6 หลายเดือนก่อน

    Great video! Commenting for the youtube algorithm :)

  • @VigneshD25
    @VigneshD25 6 หลายเดือนก่อน

    That generic based demonstration just gave the answer !!!

  • @NotherPleb
    @NotherPleb 7 หลายเดือนก่อน

    Your examples are really good and this helped me a lot on my Rust journey. May I take your examples and present them to my team and ofc I'll credit you.

    • @oconnor663
      @oconnor663 7 หลายเดือนก่อน

      Absolutely!

  • @garrettsmith5760
    @garrettsmith5760 7 หลายเดือนก่อน

    Thank you for creating this talk! This is exactly what the industry needs -- to bridge the gap between between how you did things in C/C++ and how you could do them in Rust.

  • @kotem13
    @kotem13 8 หลายเดือนก่อน

    42:10 wouldn't this assembly cause incorrect behavior if the int64_t pointer is pointing to two int32_t elements in the middle of the array? I guess that the compiler makes the assumption that the 64bit pointer can't point to the middle of the array because a pointer cast like that is undefined behavior (?) I don't know the rules to this kind of pointer casts, honestly

    • @oconnor663
      @oconnor663 8 หลายเดือนก่อน

      Yes it would certainly cause problems, but the way I like to think about it is that the "strict aliasing" rules define those problems to be the programmer's fault rather than the compiler's fault.

    • @jordanb722
      @jordanb722 4 หลายเดือนก่อน

      As much of the video mentions, the C standard specifies that compilers may assume pointers of different types don't overlap in memory. The uint64 is a different type to the uint32 array, so the compiler can make an optimisation that is broken if that rule is also broken. The uint32 pointer is the same type as the array - and by the rules laid down by the standard, the compiler cannot assume that it occupies a different location in memory, so it has to do the calculation the long way, in case the pointer is overwritten midway through. I imagine there is some logical justification to this in the sense that, generally speaking, in a well-formed program data of different types should not overlap in memory (and data of the same type shouldn't overlap at different addresses), but some common techniques like subsetting part of a struct with another struct probably run afoul of this more often, and is why things like Linux (which use that technique a lot) need strict aliasing to be turned off.

  • @sbx1720
    @sbx1720 8 หลายเดือนก่อน

    so clear explanation. it clicks instantly when you go through the problem and reach the solution. well done. thanks

  • @JohnPywtorak
    @JohnPywtorak 8 หลายเดือนก่อน

    I am not sure overloading Type in this way to think about lifetimes is good. It confuses me because a String and a String are the same Type. I know you add a little to try and explain that. It is appreciated, but adds indirection that is ultimately confusing. I understand why T & T was fine, that makes sense generically. I though would not try and explain by using generics. I want to understand this way of thinking, but I find I am worse off as opposed to just knowing the element string reference has to life as long as the contents of the vector do. Straight to the point.

    • @oconnor663
      @oconnor663 8 หลายเดือนก่อน

      Hey that's good feedback. This is an experiment for sure, and the conclusion might be that teaching it this way isn't worth the extra time and potential confusion.