The Rust Standard Library is SO Confusing...Until Now!

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 77

  • @TravisMedia
    @TravisMedia  9 місяців тому

    To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/TravisMedia . The first 200 of you will get 20% off Brilliant’s annual premium subscription.

    • @hammerheadcorvette4
      @hammerheadcorvette4 8 місяців тому +1

      🤔🤔 4:05 Where's the link to the Rust book? You said you'd put a link, but I see everything but it? 🤔🤔

    • @xE92vD
      @xE92vD 8 місяців тому

      ​@@hammerheadcorvette4just search for rust the book

  • @rtdietrich
    @rtdietrich 9 місяців тому +34

    I do it exactly as you described. At the beginning I wanted to avoid it because it means a lot of work, but what has to be done has to be done

  • @jongeduard
    @jongeduard 9 місяців тому +11

    For me learning the language was all those things at the same time. Analyzer, Book, Docs, Rustlings, while reading trying everything extensively. Hours of clicking around through Rust source code. Everything is zo amazingly accessible.
    And I really have to say that the library source code is actually very easy to read, which you showed for a short time in the video. It has been written in a beautiful way.
    If anyone has ever looked at C++ source code, oh man, what a difference. Like from another planet.
    Most important for me was the choice of learning this language and making it a goal on a different level. Professionally I develop in C# mostly, but I have always explored lots of languages. And I became aware Rust as really a different kind of thing which is clearly going to be ever more important in the future, so I decided to go 100 percent for it. And I feel thankful for this. It's now my favorite programming language.
    And yeah, some mention Zig as great as well, but that language is less mature and further away from mainstream. And Rust is still better in safety. I might explore some day as well though. Maybe it's amazing too.

  • @pedroluzio
    @pedroluzio 6 місяців тому +3

    Just a tip, in VScode type hints are not just ON/OFF, you can configure them so that they can show only when you press, CTRL/CMD+OPTION/ALT, with "editor.inlayHints.enabled": "offUnlessPressed", and you also have the reverse. I like this feature, because the hints can become verbose and push ur code 1000 characters to the side. I usually have them off till I press.

  • @p2k7777
    @p2k7777 9 місяців тому +5

    10:16 that's the standard library implementation itself

  • @alfred0231
    @alfred0231 9 місяців тому +4

    I think that the trig functions give a quick insight into how Rust standard library structures code.

  • @kennystrawnmusic
    @kennystrawnmusic 8 місяців тому

    Starting with the core and alloc libraries - which are what you need to use when following Rust OSDev tutorials - is what made the standard library easier to grasp on my end. Once you know how to navigate the core library and once you know how to navigate the alloc library, then by the time you try to navigate the standard library, you’ve already learned bits and pieces of it.

  • @crab-cake
    @crab-cake 8 місяців тому

    when i first started learning rust 3-4 years ago i had that exact problem. the docs didn't make sense to me for the longest time. i think i would've progressed much faster if they weren't so technical and didn't lack context. the book is great and rustlings is also great, but i think it would be helpful if there was an interactive repl tutorial built into the browser. not sure if you've heard of sveltekit before, but it has a wonderful repl tutorial.

  • @a_maxed_out_handle_of_30_chars
    @a_maxed_out_handle_of_30_chars 6 днів тому

    this was a good advice, thank you :)

  • @akauppi2
    @akauppi2 9 місяців тому +2

    Today, I came across an SO comment about std::sync::mpsc (the channel-thing). “Some think it wasn’t a good idea to place channel to the std, but now it’s too late.” That was insightful. Opened me more braveness to look at non-std crates, instead.

  • @Said-n7o
    @Said-n7o 9 місяців тому +3

    Thank you for showing how to read I have been unable to start reading docs after reading the book

  • @dabunnisher29
    @dabunnisher29 8 місяців тому

    This is SOOOOO TRUE!!!! Thank you for all you do.

  • @yiraqcic1348
    @yiraqcic1348 9 місяців тому +7

    More and more Rust content. Thanks a bunch for everything you do !

    • @CallousCoder
      @CallousCoder 9 місяців тому

      I have some rust stuff too, but even more Zig stuff. Which is just a better low level language ;)

  • @jasonbraithwaite9204
    @jasonbraithwaite9204 6 місяців тому

    Excellent video, really invaluable, thank you 👍

  • @rashidul0405
    @rashidul0405 5 місяців тому

    This is a very nice video Man.

  • @subhankarn
    @subhankarn 9 місяців тому +1

    where is the link for the Rust book?

    • @sammy709
      @sammy709 9 місяців тому +4

      google

    • @TravisMedia
      @TravisMedia  9 місяців тому +4

      doc.rust-lang.org/book/

    • @galk32
      @galk32 9 місяців тому +1

      in terminal: rustup doc --book

    • @subhankarn
      @subhankarn 9 місяців тому

      @@TravisMedia thank you for sharing the link

  • @andsviat
    @andsviat 5 місяців тому

    This is fantastic! Next video - How to turn on your computer. Also important for programmers, because they might not know.
    PS: The very first part makes me wonder why would a person learn a programming language if they can't read and follow links?

  • @simonkalu
    @simonkalu 9 місяців тому +4

    Rust is a power house. It is a well crafted language and to some extent resembles Typescript. I am currently comparing two the two to see where the syntax looks alike etc. It is a very interesting and robust language that cuts across many domains. I tried Rust + Vite + Wasm and the result was amazing. @Travis, what is your view on Rust job market or getting a Rust jobs?

    • @TravisMedia
      @TravisMedia  9 місяців тому +4

      I feel like the Rust job market currently is largely if not mostly a senior Rust engineer market. Things could definitely change though with more adoption and use cases. It’s a tough language to get good at, but once good at it I think one could become very marketable in it.

    • @simonkalu
      @simonkalu 9 місяців тому

      @@TravisMedia thanks for the swift response 😊. What's your thoughts, Rust looks like something that will take forever to master because of the volume of materials that one has to consume to understand how things work to solve problems? 😀. I am a programmer based in Nigeria 🇳🇬 and work in the oil and gas sector. I am currently, looking for a remote gig to support my income. What tech stack can one easily focus on to quickly grab a remote job especially for those of us that live in Africa. What lang is in high demand from your view? Kindly reply

    • @Hellbending
      @Hellbending 9 місяців тому

      @@simonkalu not exactly qualified to answer, but I’ll give my two cents lol
      If you would google any of the top most used languages, you’re probably going to see something along the lines of JavaScript/typescript as react and python, given the current booming AI industry model.
      Both are pretty much a standard, run-of-the-mill programming languages at this point in time and potentially tough to get a job in due to the fact that yes people love them. Yes, they always need people to work, but it also follows the path of everyone else, which tends to means that you have more competition as well.
      I’m not sure what you’d be able to put to use overall. If you’re wanting to stick within mining and gas etc. type of industry then I could imagine that a low level language like C or C++ might do you some good if you’re looking at moving into something to do with Arduino, or on board chips for instance. (and if you put your head down, and I mean really learn the ins and outs of C and C++.) You’re likely to come away with a benefit that a lot of people don’t end up seeing as they are less common of a language than the aforementioned ones.
      (just be prepared that you are going to have to learn security related content in order to get a good handle on it that, and if you’re going to be using in a sector such as one with regulations of basically any kind)

    • @xavierverne5654
      @xavierverne5654 5 місяців тому

      Python. If you want easy path and correct money. Rust if you can afford big investment, but more money later on.

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 9 місяців тому +1

    The standard library is a really limited, even no regexp there. Yes, you can easily to find 3rd party implementation of version 0.0.36.... But which one to use? How effective and correct the implementation? Nobody knows, you can get an answer like that: It works for me, and hopefully will work for you... You got it.

    • @noahhounshel104
      @noahhounshel104 9 місяців тому +6

      There is no regex implementation in the standard library for exactly the reasons you are asking about in choosing a regex implementation library. There are many possible ways to implement it with their own pros and cons. Since there is no consensus on the best, there is no standard library implementation.

    • @kamertonaudiophileplayer847
      @kamertonaudiophileplayer847 9 місяців тому

      @@noahhounshel104 You touched a very good point, if you know what you need then take own implementation, otherwise use the standard. But the standard is missed in Rust.

    • @noahhounshel104
      @noahhounshel104 9 місяців тому

      @@kamertonaudiophileplayer847 the point is that there's no standard because the people making the standard library aren't mind readers. If you don't know what you want or need, why would they possibly be able to determine that for you?
      Especially when it comes to regular expressions there are hundreds of variations, and the regex itself is an entirely separate language, with languages like Python and Ruby having different, distinct dialects which are incompatible with each other. What version should they implement? Should they allow backtracking in regexes? That runs the risk of some severe bugs like the cloudflare outage in 2019. There are a million implementation specific questions that make your "small" addition to the standard library immensely more complicated than you think it is.
      This is the very reason the Rust developers have expressed regret in the decision to include hashmaps in the standard library. The "standard library" hashmap is orders of magnitude slower than 3rd party implementations because of the compromises they made on the hashing algorithm safety, because it's "default" and they cannot read your code and know if it's appropriate to use a faster, less secure algorithm.

  • @justiceessiel6123
    @justiceessiel6123 9 місяців тому

    Dfs algorithm in terms of his advice

  • @CallousCoder
    @CallousCoder 9 місяців тому +6

    The Rust stdlib is just too big and I hate the factory builder patterns with a passion. That was already a bad idea in Java, why copy it?
    I will never be a Rust fanboy, as a C/C++ guy. I still have to find a way how to have 3 different thread functions access the same vector without using Arc

    • @jackhales6179
      @jackhales6179 9 місяців тому +3

      Rust is cool, Zig is cool, Python is cool, C++ is cool, its all just tech

    • @CallousCoder
      @CallousCoder 9 місяців тому

      @@jackhales6179 Python isn’t cool 😁Python is a toy. 😄

    • @CallousCoder
      @CallousCoder 9 місяців тому +1

      @@jackhales6179 except Python isn’t cool it’s slow 😂

    • @jackhales6179
      @jackhales6179 9 місяців тому +1

      @@CallousCodercool slow 😎

    • @CallousCoder
      @CallousCoder 9 місяців тому

      @@jackhales6179 Naah any language without { } or begin end or that isn't strongly typed isn't cool. 😶‍🌫

  • @Wilkbezstada
    @Wilkbezstada 9 місяців тому

    Jensen told to not learn code.

  • @p2k7777
    @p2k7777 9 місяців тому

    The micro edits are jarring

  • @CitizensCommunity
    @CitizensCommunity 9 місяців тому

    Oh, I hate the advice 'follow the links.' It's a terrible way to learn, as it never ends and constantly creates new rabbit holes that lead to frustration. I skipped the Rust book, and once I grasped the basic usage by quizzing gippty, I read Mara Bos's 'Rust Atomics and Locks' to transition from Python to low-level code. Looking things up until you can continue reading gives you the context for how things are used and a reason for learning them. Going back and reading the Rust book afterward filled in any gaps I missed and allowed me to understand some points they were making, which I highly doubt I would have grasped if I read it first.

  • @christianm4906
    @christianm4906 9 місяців тому +4

    Why consider learning Rust if its future is so uncertain, especially given that there are other languages on the horizon that offer clean interoperability with existing C/C++ and Python code, such as Mojo, CPP2, Carbon, and even Zig? I am under the impression that Rust's approach is a failure from day one. Its future seems likely to resemble that of the D programming language or Dart, with the notable difference that Dart was saved by Flutter, without which it might have failed. In contrast, approaches like TypeScript and C++ seem much more successful in terms of adoption compared to Dart and the D programming language. The Rust extern function approach to integrating with other languages is as good as having nothing at all. This is not a good time to learn Rust. As soon as the first production-ready version of either Carbon, CPP2, or Mojo gets released, Rust's future will resemble the present of the D programming language.

    • @TravisMedia
      @TravisMedia  9 місяців тому +12

      There's some pretty big adoption of Rust (to explicitly move away from C/C++, by recommendation of the US CISA) by Microsoft, Google, etc. Who knows what the future will bring, but I don't see Rust at all going the way of Dart.

    • @christianm4906
      @christianm4906 9 місяців тому +3

      @TravisMedia Then why Microsoft engineers are working on cpp2 an Google engineers are working on Carbon? It's been at least 12 years since we first heard of Rust, and despite the extensive marketing campaign it has received, it is still considered a niche programming language. Don't get me wrong, I'm not saying Rust is a bad programming language. In fact, it might have few missing features in C/C++ , but its approach forces developers to either write everything from scratch or deal with the pitfalls of the 'extern-function approach' for integration with the outside world. The industry has invariably proven that this approach is a failure from day one. A very good example of this is the Dart programming language. It was originally intended to replace JavaScript, and despite being better than JavaScript in many ways, it miserably failed to do so. Similarly, Rust is unlikely to succeed in replacing C or C++. The reason is that Rust and C++ are fundamentally incompatible. I see more future in replacing C/C++ with other approaches such as CPP2 or Carbon if the first production-ready versions of those languages are released, which seems very likely to happen soon. Once that happens, there will be even less chance for Rust to replace C or C++. Mojo also looks a much more attractive alternative than Rust as it can run as fast as C, it offers memory safe features like Rust while being easier to use an compatible with python. Also, note that C++ and TypeScript are very successful languages in terms of adoption because their approach doesn't require rewriting everything from scratch. You just change the extension from .js to .ts in your JavaScript programs and start seeing results in terms of migration right away. Similarly, with C++ and C; you compile a C program with a C++ compiler and start seeing results. That's why industries are reluctant to migrate to Rust. This approach is in opposition to code reusability, which is too important to give up.

    • @CallousCoder
      @CallousCoder 9 місяців тому +3

      @@TravisMedia I am not a real fan of Rust, I will never be a fanboy I don't like verbosity and the indent and bracket heavy syntax. But I don't see it going anywhere. I do believe that Rust won't win the embedded market and realtime markets. I think Zig will jump into those because there's so much C code that will need to be used for ages (especially in critical systems you don't just make a new implementation as code needs to be audited and certified and costs time and money). Zig sits perfectly in there it can use those libraries without function wrappers it can compile everything and it's actually pretty safe.

    • @steveoc64
      @steveoc64 9 місяців тому +2

      @@TravisMedia the CISA recommendation is to choose memory safe languages wherever possible.. it then lists a number of them. Rust is 1 entry in a long list

    • @christianm4906
      @christianm4906 9 місяців тому +2

      @CallousCoder I totally agree with this comment. Code reusability is key for new programming languages to succeed. The trend is clear for programming languages that have been successfully adopted. TypeScript interoperates with JavaScript, C++ interoperates with C, and Kotlin, which I forgot to mention before, interoperates with Java. In this respect, I see a clear advantage of Zig over Rust. Not to mention Mojo, which has not only beaten Rust in performance but also supports memory-safe features with a cleaner syntax and can interoperate with Python. Cpp2 and Carbon solve the problems with C and C++ while offering a cleaner syntax and interoperation with C/C++ code. To add more salt to the wound, Rust has already become too verbose and complex, so much so that even the Rust developers are feeling frustrated with it. I know a few government agencies might be advocating for memory-safe languages, but it doesn't necessarily have to be Rust. In fact, there are memory safety languages out there with far greater adoption than Rust, such as Java, C#, Python, Swift, and Go. And if performance is also important, Rust has to compete with the already industry-established C and C++, now Cpp2, Carbon, Mojo, Zig, and Go. As I said before, it is not a good time to learn Rust and reinvent the wheel in a language just for the sake of doing so. Rust didn't replace C or C++ and it never will. Just check GitHub, Stack Overflow, and other statistics. The truth is that much more code is being written in C and C++ than in Rust. It's been like that for decades. A new programming language, to succeed, needs to guarantee code reusability; otherwise, it will miserably fail

  • @erikpaulsen3111
    @erikpaulsen3111 9 місяців тому +2

    I am still confused and refuse to do homework. The lack of JSON, XML and SQL in the standard library implies that the borrow checker logic dislikes text management and trees.

    • @matthiskalble3621
      @matthiskalble3621 9 місяців тому +19

      No these are things that do not belong Ino the std library as standards for these things might change (eg you need to update it if a new feature comes in one of these languages). That is why there are some de facto standard crates (serde etc)
      For SQL there are just like 1000 different backends, it is not the stdlibs job to support those

    • @matthiskalble3621
      @matthiskalble3621 9 місяців тому +2

      Also it is supposed to be minimal, not feature complete for everthing

    • @andrewf8366
      @andrewf8366 9 місяців тому +4

      Are there languages with those in the standard library?

    • @kitlith
      @kitlith 9 місяців тому

      ​@@andrewf8366python comes to mind

    • @joshuaPurushothaman_
      @joshuaPurushothaman_ 9 місяців тому

      ​@@andrewf8366Python has json I think. I'd say it's fair to have those... I think serde is regarded as pretty standard for use though. Like how python asyncio needs a pip install (iirc), but is pretty much de facto?

  • @kevinkkirimii
    @kevinkkirimii 9 місяців тому

    Unless I have no other option, I am not touching rust again.... Zig all the way.

  • @deadmarshal
    @deadmarshal 9 місяців тому +2

    Rust is a joke!