12 Things to Help You Learn Rust

  Переглядів 89,750

Gary Explains

Gary Explains

День тому

The Rust programming language is gaining more and more momentum due to its memory safety features. Here is the first video in a new series about Rust starting with the basic things you need to understand like loops, variables, functions, tuples, strings and more!
What is Rust: 0:38
How to install Rust: 3:23
Println!: 4:29
Mut and mutability: 10:19
Shadow variables: 11:40
Constants: 13:49
Basic Types: 15:03
Strings: 17:05
Tuples: 20:08
Arrays: 22:35
Expressions and statements: 24:00
Functions: 26:39
Loop and while: 31:33
For loop: 33:13
Introduction to Android app development: www.dgitacademy.com
Let Me Explain T-shirt: teespring.com/gary-explains-l...
Twitter: / garyexplains
Instagram: / garyexplains
#garyexplains

КОМЕНТАРІ: 209
@Redoxeon
@Redoxeon 4 роки тому
LOVE RUST! Been doing my senior project for my CS degree in Rust to help me really learn it. Been an absolute blast!
@khebchiabdallah7445
@khebchiabdallah7445 3 роки тому
Can i ask what a type of project ?next year i will do my senior project also
@unixpert321
@unixpert321 3 роки тому
Yes please tell what type of a project
@VivekYadav-ds8oz
@VivekYadav-ds8oz 2 роки тому
I would like to say that Rust is unlike other languages where you can learn as you go/while experimenting. I'd really recommend reading through the resources people mentioned before jumping in (steep learning curve).
@hansdampf2284
@hansdampf2284 Рік тому
I recently tried to learn emacs lisp with experimenting. First exercise was to calculate if a year is a leap year. I was just sitting there, staring at the screen. I knew how to do it, but I had no clue about how to do it in emacs lisps syntax. :D
@miloszivkovic6256
@miloszivkovic6256 4 роки тому
Upper case separated but underscores is called "SCREAMING_SNAKE_CASE"
@FranzzInLove
@FranzzInLove 4 роки тому
Rust has a great documentation that is even available offline when you install it, and in the documentation there is the rust book which explains all its concepts with practical examples. I think it's a must to go through it because it's quite different than typical languages I think (although I only really know C and python).
@UnicycleSoul
@UnicycleSoul 4 роки тому
I quite like their documentation but I find it that using crates and wiring them together is a general nightmare.
@VivekYadav-ds8oz
@VivekYadav-ds8oz 2 роки тому
@@UnicycleSoul Quite the opposite case for me. Cargo makes including dependencies as easy as it can be. Literally just the name and version of the library you wanna use, and boom it's done.
@Zeadar
@Zeadar 4 роки тому
Video on utf-8 would be nice!
@hpp6116
@hpp6116 4 роки тому
Agree! That would be interesting.
@nick_eubank
@nick_eubank 4 роки тому
Here’s an amazing video on Unicode / utf 8: ukposts.info/have/v-deo/hZmboZumf299tWg.html
@hakunkamminga3915
@hakunkamminga3915 3 роки тому
@Axton Aarav if you download other people's code meant to "hack" things this channel is not for you XD
@AbhishekBM
@AbhishekBM 3 роки тому
There's that one on computerphile by Tom Scott. It's a nice one.
@SirLoinOfHamalot
@SirLoinOfHamalot 4 роки тому
Thank you so much, I was just wondering about this language and wasn't quite sure where to begin. Hats off to you Gary
@aviralrastogi
@aviralrastogi 4 роки тому
Great Timing! I've been thinking for a while to learn Rust (I already know C and a little C++). The video was very clear, fast and efficient. Loved it. Will be eagerly waiting for next lecture Professor!
@gilmoretj
@gilmoretj 4 роки тому
Great introduction to Rust. I am looking forward to the next instalment in this series. I would also be interested in your presentation of UTF-8.
@jonathanquarles3708
@jonathanquarles3708 4 роки тому
I'm so glad to see you cover this
@DM-cg7mw
@DM-cg7mw 2 роки тому
Quickest, most consise Rust introduction I've see yet. Kudos!
@marcusk7855
@marcusk7855 4 роки тому
I like it. Thanks for the intro. Something to do while in lock down. Learn a new language.
@eignnx_1738
@eignnx_1738 4 роки тому
I really like your explanation of String vs str. Not a complete definition but I think very good when you're hearing "rust has 2 string types" for the first time.
@sorenrood
@sorenrood 3 роки тому
Great intro video. I'm going to be using rust at work in the next few weeks and this is helping me to get a basic understanding. I was educated in C++ and so far, they are very similar!
@ictflow2012
@ictflow2012 4 роки тому
Thank you for our Lesson Uncle Gary. It was very clear and informative.
@TurboGoth
@TurboGoth 2 роки тому
You're showing some fantastic breadth on this vid, Gary. I'm, foremost, a programming nerd and I've been following you for your hardware coverage and have been delighted with it for its accessibility. But I, myself, with a degree in computer science, am just beginning with Rust and I love it. They've run with the C++ community's long refined practice of RIAA memory semantics and have turned an art to a science with their fundamental build of a programming language atop it. It's amazing. The Rust-lang book is my homepage as I plod through it all. The borrowing tricks are very clever and to be completely honest, I wish there was a garbage collected version of the language so as to relax the learning curve so that the final jump to rust could be just laser focused on the borrowing and ownership stuff. It is real crazy and cool. I like garbage collection less and less as I reason through how graph algorithms absolutely destroy the CPU cache with frequent invalidations. And the CPU cache isn't just a nice-to-have on the side. Good performance can't be had without it.
@wgedwardsvideo
@wgedwardsvideo 2 роки тому
This is a great introduction to the Rust language. Gary really does explain and in a clear concise manner.
@alliejr
@alliejr 4 роки тому
Wow, Gary. You did sooo much work here. 👏🏽👏🏽👏🏽
@1MarkKeller
@1MarkKeller 4 роки тому
The Professor keeps on professing!
@maerroc
@maerroc 4 роки тому
At 14:07 I guess you wanted to say that constants are always imutable (instead of mutable).
@danchovanes2612
@danchovanes2612 3 роки тому
This is a great style of video! I'm curiously prodding around the outsides of Rust to see what it's like and this is a terrific introduction to core concepts and features without being overly verbose or lengthy
@nathanshields3743
@nathanshields3743 2 роки тому
Brilliant way of explaining things! Well Done!
@HoussemFathallah
@HoussemFathallah 4 роки тому
Excellent and elegant introduction to rustlang. Thank you for the video !
@geocine
@geocine 3 роки тому
I would pay for a full course on rust explained by you, This is really very clear and straightforward.
@clarionisige6124
@clarionisige6124 3 роки тому
Thanks for the video I started rust this year and I found it fascinating
@mikelawson3315
@mikelawson3315 3 роки тому
Hey Gary, I'm late to the party but I want to dive into rust programming and this video gave me an excellent introduction. Thanks a lot!!
@odw32
@odw32 4 роки тому
Nice overview! I would really love a video on how to make code more... Rusty. I often still feel like I'm writing very iterative code, and would love some "instead of X, try using a more idiomatic pattern like Y" examples. Also something along the lines of "How not to panic!() when you see angled brackets". Memory safety and borrowing can be confusing for a bit -- But I found that the real brainteasers start when you encounter generics, traits, boundaries and macros -- and that's usually pretty quickly because Iterators, From/Into conversion and Result/Optional are so prevalent in other people's crates.
@box5evey
@box5evey 3 роки тому
Very clearly explained, you've got another subscriber!
@AungBaw
@AungBaw 4 роки тому
Thank you professor
@tkadado
@tkadado 3 роки тому
Thanks Gary. You convinced me to learn Rust in this nice video
@jonbikaku6133
@jonbikaku6133 2 роки тому
I know its not the niche of your channel, but can we please get a full Rust course 🙏🙏 This explanation was fantastic! The little things you mentioned on the side were actually very helpful in clearing many misconceptions I would have assumed initially. Please give us all of Rust you know 🙏🙏
@scheimong
@scheimong 2 роки тому
I am about a year into learning and using Rust, about as old as this video is. Now I can really appreciate why Rust has been the most loved language in SO surveys for 6 years running. On a management level, projects leaders like it because the compiler catches so many bugs, which means they can put more trust on every of their programmers (junior and senior) to produce reliable, bug-free code. On an individual level, programmers like it because of all the modern ergonomics Rust brings to the table - type inference, Python-like string templating, iterators, message channels, official build tool, world-class documentation, and so much more. And of course to tie it all together, the programs that come out is hella fast - nearly as performant as well-optimised C and Cpp, and leagues above interpreted languages such as Python. It's a language so good it only existed in people's dreams, right up until it actually happened.
@HappyCheeryChap
@HappyCheeryChap 4 роки тому
Excellent video! I've just started learning Rust, and I learnt a lot from this video. One minor suggestion: I found myself needing to seek back-and-forth a bit from the resulting output back to the code that produced it. It would have been nice to have both on screen at once. I know there's limited space when using big fonts for videos, but you could crop out the run/debug/stable buttons along the top, and it would create enough space for a few lines of output at the bottom. This (needing to seek back-and-forth) is one of the things where article/books are often better than videos (much quicker to seek by just moving your eyeballs than fiddling with the seekbar), so this would help get closer to that efficiency. You could still hide the output before you're ready to show it, but just leave the code on screen too when showing the output. Having a different background color for code vs output would be nice too. Alternatively doing something like quokka where you show the output as a comment on the same line as the code means that the viewer doesn't need to try to mentally match things up.
@grishminkarki9460
@grishminkarki9460 3 роки тому
I am also learning rust☺, I have just finished ownership chapter and started next topic i.e about structuring data using struct keyword.
@bigdummyhead2162
@bigdummyhead2162 2 роки тому
TOC: 4:06 println! : 4:25 mut : 10:19 shadow variables : 11:40 constants : 13:49 types : 15:03 Strings : 17:05 tuples : 20:08 arrays : 22:35 expressions and statements : 24:01 functions : 26:38 loop and while : 31:32 for : 33:13 closing statements : 35:06
@GaryExplains
@GaryExplains 2 роки тому
Thanks for the time indexes, but you do realise that I had included that in the description already?
@rtsa4633
@rtsa4633 3 роки тому
Thank you. This helped a lot :)
@akbarghurbal
@akbarghurbal 3 роки тому
Every minute of this video is valuable ... I have just started learning Rust this week; and I only know python (2 years experience)... and this video helped me a lot... please do more Rust programming stuff.
@avejst
@avejst 4 роки тому
Interesting intro Thanks for sharing :-)
@alexandregiraud6885
@alexandregiraud6885 3 роки тому
Very instructive, thanks !
@joaocesarlima7339
@joaocesarlima7339 4 роки тому
Excellent video! Thanks!
@samlikestocode7200
@samlikestocode7200 4 роки тому
Nice one. It would be nice if you do a video on Haskell too.
@silakanveli
@silakanveli 4 роки тому
Fantastic video!
@ZOO4201
@ZOO4201 3 роки тому
Thanks for this
@CreativeJE
@CreativeJE 4 роки тому
Thanks man rust is quite easy and you explained it clearly
@kiranpreet6932
@kiranpreet6932 4 роки тому
Gary, what a great intro. Thanks
@GaryExplains
@GaryExplains 4 роки тому
Glad you like it
@McTroyd
@McTroyd 4 роки тому
Looking forward to the second video, but I'll throw in a vote for UTF8 as well!
@TibinThomas1993
@TibinThomas1993 4 роки тому
Good work. Thanks.
@somcho
@somcho 3 роки тому
looking forward to seeing the sequel to this on memory, ownership and borrowing
@autohmae
@autohmae 3 роки тому
He did do this one: Dynamic Memory Allocation in C - malloc, free, and buffer overflows
@anant6778
@anant6778 3 роки тому
*BOOOOM* Let makes so much more sense !
@yareps
@yareps 4 роки тому
UTF8 lesson? Yes, please!
@anandsuralkar2947
@anandsuralkar2947 Рік тому
damn this is so good i was having hard time gettin rust ur video is gem.
@GaryExplains
@GaryExplains Рік тому
I am glad it was helpful. 👍
@josemfacuna6754
@josemfacuna6754 4 роки тому
excellent! Thanks
@tomswan3401
@tomswan3401 4 роки тому
I was wondering about cloud computing. Like run my java app in cloud foundry, in aws cloud, azure, ali cloud. How much effort is running a complex rust app in different cloud environments, using the same code base.
@muddyexport5639
@muddyexport5639 Рік тому
Thanks -- revisiting after seeing the Google "go" language vid to compare the differences (many).
@vkexplores
@vkexplores 3 роки тому
Best intro to rust
@guilherme5094
@guilherme5094 Рік тому
Thanks👍
@Meleeman011
@Meleeman011 2 роки тому
@8:07 i tried to replace those with strings and i noticed rust cares about what type of quotes i use, which is kinda wild. cause what if i need to make a template string on the web? i suppose i'll have to store it in those "" quotes as a string. looked more into it, its like bash where you can escape characters you need inside a string so thats good
@camotubi
@camotubi 4 роки тому
I have been programming in rust since 2 years ago and I wasn't aware about the named variables in the println macro 😂.
@pisse3000
@pisse3000 4 роки тому
I'm just thinking of the hundreds of hours of my life I could have back if my work had been done in Rust instead of C++... I try to do as much as I can in C, but sometimes I just have no choice.
@realchrishawkes
@realchrishawkes 3 роки тому
Nice video bro!
@GaryExplains
@GaryExplains 3 роки тому
Glad you liked it
@AbhishekBajpaiHere
@AbhishekBajpaiHere 4 роки тому
Awesome video, please do a video on UTF-8, I am subscribing to this channel for that reason only. Thanks again :)
@poweruser64
@poweruser64 4 роки тому
You should make a video on Go
@akj7
@akj7 4 роки тому
As a programmer that knows more than 10 programming languages including Rust, C and C++, i think Rust is pretty exagerated. You know, when i was learning C, i thought to myself: why does this language not have classes or at least libraries for the basic things like hash tables, or even maybe a way to check for memory violation at compile time. Then i read the libc (c standard libraries) and indeed C has many libraries, just that they are not classified as standard. This really troubled me, but with time, i realized why C is so, why a C compiler exists almost every hardware out there. C knows its place and it is as a mediator between hardware and human, a nice assembler. C11 included generics, but barely anyone uses them, it even added the bound checking option for developper, which people criticised. This leads to my complain about your points at 0:43: C and C++ are very popular and a lot of people use these languages without actually knowing what they are doing. Funny is the fact that the Rust community is filled with good C and C++ developpers. An example is what i keep seeing in C++: People using C style programming in C++ and calling themselves C++ devs. Instead of creating a raw array of raw pointers, rather use C++ std::array or std::vector coupled with std::unique_ptr.
@kiranpreet6932
@kiranpreet6932 4 роки тому
Actually most are not. The reason good c/cpp programmers are looking at rust is precisly because they understand the deficiencies of using those languages to write safe systems. The legacy of cpp is that it was written to allow most of C to be acceptable. This has lead to many people writing c in cpp, like you say. Some places c is good, but in many places rust is just better. As someone who's been programming for 40 years, I used think language X was great, until I realised what language Y was better for.
@H18136
@H18136 3 роки тому
I doubt you know very much about rust at all, as you really have completely missed the point of it as language. it prevents you from making almost all of the bugs which c and c++ programs are riddled with - null pointers, dangling pointers, use after free, data races and so on. As for utter nonsense like barely anyone uses generics.... at this point I strongly suspect you're merely trolling.
@ThePandaGuitar
@ThePandaGuitar 3 роки тому
What’s your point?
@TheMrKeksLp
@TheMrKeksLp 3 роки тому
I'm fairly certain you have at most surface level knowledge in 10 different languages. Someone who's actually been around should know the weak points of C and C++ and should recognize that Rust (succesfully) tries fixing them
@mikicerise6250
@mikicerise6250 Рік тому
Interesting stuff, but I'd like some more information on what is going on under the hood. For example, when you say let (w, x, y, z) = tup, are w, x, y and z references to tup values that become invalidated if tup is deallocated, or are they copies? I'm guessing in a memory-safe-to-point-of-madness language like Rust, they are copies, so the operation is more expensive than just referencing tup.0, tup.1, etc. Also, yes, do that UTF-8 video. :D
@linuxinside6188
@linuxinside6188 4 роки тому
How fast it is ? Any benchmarking test ?
@mi2has
@mi2has 4 роки тому
Seems interesting language and quite powerful, how far it has been adapted ?
@lagseeing8341
@lagseeing8341 4 роки тому
Here is a list of companies that are using it: www.rust-lang.org/production/users
@_sivan6668
@_sivan6668 4 роки тому
hmm .. at 24:05 inside y block x is muted does mut needed as it comes under shadowing ?
@GaryExplains
@GaryExplains 4 роки тому
x is not a shadow variable in the loop because it doesn't use "let"
@opeyemitishe1333
@opeyemitishe1333 2 роки тому
Hello and thank you for the tut it’s really helpful fr, but am a beginner and I wanna learn rust how’s that possible?
@oldBASgold
@oldBASgold 4 роки тому
UTF-8 DO VIDEO PLEASE
@Sharakov15
@Sharakov15 3 роки тому
For the function `is_odd` at 28:17, the logic holds in a single line: (x & 1) != 0.
@cbbcbb6803
@cbbcbb6803 10 місяців тому
Start with something the learner is already familiar with, for example, a simplified order entry system, or a simplified person book inventory system, or a car maintenence scheduler system. A competent teacher can start at any point to accommodate the experiences that the learner brings to the table.
@GaryExplains
@GaryExplains 10 місяців тому
And how do I know the level of experience you have?
@sowiain713
@sowiain713 3 роки тому
Trank you!
@Steve-Richter
@Steve-Richter 3 роки тому
Is tulle the equivalent of JavaScript object? Why does rust not use curly brackets instead of paren?
@4Simmix4
@4Simmix4 4 роки тому
a little guide on UTF-8 would be nice :)
@doriannamjesnik3007
@doriannamjesnik3007 3 роки тому
I would like to learn a timezone language.
@benwilliam1010
@benwilliam1010 4 роки тому
what I also love in Rust is, that Microcontrollers are first class citizens. The Whole Rust Ecosystem supports Cortex-M out of the box
@kiranpreet6932
@kiranpreet6932 4 роки тому
That was the first question on my mind.... what about microcrontrollers?
@Ak4n0
@Ak4n0 4 роки тому
Sólo le veo dos cosas interesantes: las tuplas (que no dejan de ser estructuras) y que los tipos de datos tienen definido el tamaño de bits. Para todo lo demás me gusta más C.
@zXHAcKeRzXz
@zXHAcKeRzXz 4 роки тому
I guessed that it was an ancient video so I can explore the whole tutorial but this video is 0 day old :'(
@1MarkKeller
@1MarkKeller 4 роки тому
*GARY!!!* *Good Morning Professor!* *Good Morning Fellow Classmates!* Stay Safe Out There Everyone!
@GaryExplains
@GaryExplains 4 роки тому
MARK!!!
@priit7777
@priit7777 4 роки тому
Will there be followup to this?
@GaryExplains
@GaryExplains 4 роки тому
Yes
@firosiam7786
@firosiam7786 4 роки тому
Hey sir im 22 and i wana learn coding where should i start by which language and where can we get a good idea about the language on the net
@sentinel9651
@sentinel9651 4 роки тому
2 books, get only one or both: a) The Complete Software Developer's Career Guide, b) The Self-Taught Programmer: The Definitive Guide to Programming Professionally
@pornpori
@pornpori 4 роки тому
If you intend to make a carreer out of it, learn C. Not because you will end being a C developer, but because you will learn how the computer works and how to think like a software engineer.
@antonnym214
@antonnym214 4 роки тому
This is a good video and well-explained, which I appreciate greatly. But Woooo! I'm old school. I started programming in APL, Z-80 and 8080 assembly in 1978. I went on to design two programming languages myself: R-code and LIM. From my perspective, an immutable variable is a CONSTANT. It's RIDICULOUS to default all variables to constants. Additionally, The format for displaying a line of text is needlessly complicated and makes it harder to read and debug. For one thing, it shouldn't need a macro. Jeezy Joe! Trust me on this, as I have read and debugged code in several languages. Rust would have made me get up and walk out. Python is crazy too, with the rigorous white space, but it's not as crazy as Rust, and actually is pretty useful when coding for the Pi. Therefore there is nothing on planet earth that would induce me to code in Rust. Anyone who likes Rust, please reply and tell me why you do. Maybe I'm missing something. All good wishes.
@torspedia
@torspedia 4 роки тому
Can I go straight into Rust or would it be better to learn something like C first?
@Boomber123
@Boomber123 4 роки тому
I learn Rust as my first low-level language and do try learning C from time to time. I'd say I have a much harder time learning C than Rust.
@lagseeing8341
@lagseeing8341 4 роки тому
Rust is easier too learn than c
@TheMrKeksLp
@TheMrKeksLp 3 роки тому
I would learn C first as it's a very easy language that teaches you how the low level world works. Writing efficient code has a lot to do with knowing what's actually happening on the instruction level
@livedreamsg
@livedreamsg 2 роки тому
@@TheMrKeksLp Telling somebody to learn C as a first language because it's "easy". What a mad man.
@venkataravieluri9625
@venkataravieluri9625 3 роки тому
Got news that Linux kernel would support Rust to some extent like for writing modules. Came straight up here out of curiosity to know Rust 😂
@oddolavssn8343
@oddolavssn8343 Рік тому
A variable thet's not mutable? Wouldn't that be a constant??
@oddolavssn8343
@oddolavssn8343 Рік тому
o.k. I was to quick with that one...
@esra_erimez
@esra_erimez 4 роки тому
👍
@bishaldutta548
@bishaldutta548 4 роки тому
hey Gary -have you ever worked in any software firm??
@GaryExplains
@GaryExplains 4 роки тому
Yes, of course, I was a professorial software developer for 10 years. I worked for several companies including Digital Equipment Corp and Reuters.
@bishaldutta548
@bishaldutta548 4 роки тому
@Daniel Johnson 😂😂👍
@autohmae
@autohmae 3 роки тому
9:40 lol, that's amazing. Why would they allow shadow variables ? That seems like not a smart idea. Expressions seems really dumb, for example why not have return ? And then I realized, this forces the return to be at the end of the function. That was not as stupid as it seems at all ! Tip: with loop and while use a < > or instead of equal, so you know it will never end up in an endless loop in case you change some of the other code/calculations.
@0x6e95
@0x6e95 3 роки тому
Shadowing is really more so a convenience but I can imagine situations in which you might accidentally shadow an immutable variable.
@spinLOL533
@spinLOL533 3 роки тому
good video
@GaryExplains
@GaryExplains 3 роки тому
Glad you enjoyed
@9SMTM6
@9SMTM6 4 роки тому
It's a technicality, but Rust DOES have an intermediate language, it's just not usually what gets delivered and it's a part of the compiler. Rust is getting compiled to LLVM (low-level virtual machine) code, and other than the name suggests that is (in this instance at least, and AFAIK) used to compile further to Machine Code. The LLVM layer is what allows Rust to run on multiple platforms without requiring a runtime - like I. E. Java (and other languages with the typical 'intermediate language') or Python (and other interpreted languages) do. The only reason C(++) is able to run on so many platforms is because these platform holders or others put in a lot of work to make the compiler work, because in the end you need a language to Programm systems, and C(++) is what's used for these most of the time to this day. Rust doesn't have that luxory, but by using LLVM they can just port the LLVM Instruction Set and they're good to go. LLVM is also used by the C Compiler Clang and there's other languages that can be compiled to machine code using it btw. Coming back to Rust, they (probably, not an expert) loose a bit performance by using LLVM, but Rust makes up for it with other features that reduce runtime overhead (lots of zero cost abstractions) and you win a lot of other really nice to have things like I. E. The type-managed memory safety etc that improve code quality as well as ease development. I haven't really used Rust yet for lack of a good project to do on it, but what I have heard is quite amazing and right down my lane. Maybe you will give me a good project for it, or I'll get back to the neural network book with code I read and try and port the essentials from Python to Rust. Eventually...
@romannasuti25
@romannasuti25 4 роки тому
Samuel Maier rust often ends up faster than C or C++ code given time and effort constraints. This is because, with C and C++, you may waste performance in pursuit of safety. Rust’s built-in memory guardrails allow a programmer to optimize with reckless abandon without worrying about memory issues. This, combined with Rust’s built-in support of forced simd opcodes via std::arch and crates that wrap this for ease of use like faster (which offers simd-capable versions of map-reduce, iter, and special data types for them), it’s much easier to optimize rust than C or C++.
@romannasuti25
@romannasuti25 4 роки тому
The one last thing I think rust really needs to have a decisive all-around win over C and C++ for most use cases is a more generic logical proof system beyond just the memory stuff. That, using a security-focused RTOS like SEL4 for FOSS or INTEGRITY for compliance, could allow for potentially hack-proof, “mathematically perfect” software.
@9SMTM6
@9SMTM6 4 роки тому
@@romannasuti25 Yeah I was expecting an effect like you describe. And yeah, I think I've read about the SIMD prepared functions but forgot about it, that's a really nice time safer too, though technically you can create them in C++ too if u recall correctly. You just have to implement them yourself/use an implementation by another person. A number of the comfort features of Rust are technically a thing in C++, it's just that because they're an afterthought it's hard to use them, setting up all of them is bound to come with a shitton of experimentation. Rust gives them to you for free.
@TheMrKeksLp
@TheMrKeksLp 3 роки тому
Rust actually uses two intermediate bytecodes. LLVM IR and MIR, and there are plans to maybe even add a more high level HIR aswell
@bakedbeings
@bakedbeings 3 роки тому
If another coder can re-declare your variable without throwing an error, what’s to prevent that accidentally happening? (Expecting the next coder to be careful doesn’t count.)
@TheMrKeksLp
@TheMrKeksLp 3 роки тому
I can tell you from experience that accidental shadowing really doesn't happen. How often do you accidentally overwrite a local variable? Because it's effectively the exact same thing
@liadsagi3
@liadsagi3 4 роки тому
How Rust compare to go (golang) ?
@Myrkvi_
@Myrkvi_ 4 роки тому
i think some of the main differences are that Go is garbage collected and Rust uses a borrow checker instead, Go does not have generics but Rust does, error handling in Rust is different than in Go and many other languages, i.e. a function can return a result that is Ok(value) or an Error, which can be matched, unwrapped, etc. Rust variables are immutable by default
@liadsagi3
@liadsagi3 4 роки тому
@@Myrkvi_ I meant different in purpose not syntax. (And go functions can return an error too , idk rust syntax for that so it might be different)
@sociocritical
@sociocritical 4 роки тому
Liad Sagi Rust is a Systems Language and has (almost) no runtime, while Golang has a runtime for n:m threading and garbage collection. Thats why rust is much more powerful but on the other hand exposes much more low level stuff to you than golang. Compared to C or C++ though the compiler really tries to ensure with stuff like the borrowchecker that the code you write behaves like you expect it to (no undefined behavior, dangling pointers or data races in safe rust). You can develop an operating system in Rust or develop for embedded systems using rust. Theres also a popular crate (library) which contains a runtime for async io and n:m threading like golang does called Tokio, which even exceeds golangs performance for server applications, but its not „baked into the language“ like with go. So to conclude rust is potentially much faster, safer and more versatile than go. whats the downside you may ask? the downside is that rust is a much harder language to get productive with than go. Its similar to writing modern idiomatic C++ with more syntactic sugar, better enums, pattern matching etc. and safety guarantees though, so its easy to get started using it for everyone who knows modern idiomatic C++, but everyone else probably really has to wrap his head around this. this not like learning java or c#.
@vladimirbauer6604
@vladimirbauer6604 4 роки тому
Rust prevents data races at compile time, whereas Go doesn't give such guarantee.
@davidmurphy563
@davidmurphy563 3 роки тому
Can you swishy-wishy? x, y = y, x (a, b, c) = (c, b, a)?
@davidwebster3383
@davidwebster3383 4 роки тому
a Variable that is immutable then it is not a Variable, it is a constant!
@r0tty922
@r0tty922 4 роки тому
If you go back to mathematics, where the term actually comes from, it makes sense again: consider a function of one argument, e.g. f(x) = x * x. The variable `x` is not mutated, but represent different (hence "variable") values, as different argument values can be passed to `f`.
@kevinjad4506
@kevinjad4506 2 роки тому
Hi David, an immutable variable is computed at runtime. Or it is created at runtime. (Eg. You can assign a mutable variable to immutable variable) A constant is prepared/computed at compile time. That is, a constant is just an alias for a literal.
@tmnt9001
@tmnt9001 4 роки тому
I tought .len counted the length of the string not the number of bytes of a utf-8 encoding. :( Is there a method to count the actual string length? edit: 1. Found it. see my comment bellow. 2. I understand now why the default is bytes. String length could still be easier :/
@tmnt9001
@tmnt9001 4 роки тому
Found it. stackoverflow.com/a/46290728/86845 It's actually a bit complicated... println!("{}", "é".graphemes(true).count()); // 1
@bakedbeings
@bakedbeings 3 роки тому
tmnt9001 That’s dreadful.
@31redorange08
@31redorange08 3 роки тому
What is the actual string length?
@tmnt9001
@tmnt9001 3 роки тому
@@31redorange08 that's a bit complicated to explain. The stackoverflow Q&A that I've linked before, probably does a better job, but I'll try. First of all, the easy part: UTF-8 bytes != number of characters. The euro-sign € is 1 character, but is encoded as 3 bytes in UTF-8 (en.wikipedia.org/wiki/UTF-8#Examples) The more complicated part char is sometimes different of characters. Char is usually a unicode scalar value, which usually referes to a single charater (hence the name) but some characters can constructed from multiple unicode scalar values, like ´ and e to form the character é (en.wikipedia.org/wiki/Precomposed_character)
@31redorange08
@31redorange08 3 роки тому
@@tmnt9001 I know that it's complicated. I just wanted to state that it depends on what you want to count. There's bytes, codepoints, graphemes…
@michaeldula462
@michaeldula462 4 роки тому
@4:12. For years I thought it was pronounced as “tooples” not “tuh-ples” 😆
@steffahn
@steffahn 4 роки тому
According to Wiktionary both are used/correct. The etymology of the words however suggest that “tooples” is more correct, since it originates from terms like quadruple, quintuple, sextuple, septuple, octuple, being generalized to 𝑛-tuple in mathematics where 𝑛 is a positive integer, and all those (quadruple, quintuple, etc..) are pronounced like “...toople”.
@octowuss1888
@octowuss1888 4 роки тому
I've lost count over the years of the number of trendy niche languages that were going to replace C or even C++. Anyone remember D? Didn't think so. C and C++ will always remain the standard languages for embedded software. There may be a case for using Rust in place of C as raw pointers and arrays are tricky for programmers to handle. C++ avoids many of these pitfalls by providing deterministic destructors for cleanup (RAII), smart pointers, bounds checked vectors etc. Modern C++(11/../20) also provides move semantics to distinguish between copying and exchanging data, as well as a whole host of other modern language goodies such as type inference, lambda expressions, direct iteration over collections, initializer expressions, etc, etc. If you want to learn a better C, learn modern C++!
@TheMrKeksLp
@TheMrKeksLp 3 роки тому
No, C++ is not the answer. It's horribly broken and probably can't be fixed. Rust is the first successor to C to actually figure out real memory safety without sacrificing performance. It's definitely here to stay
@1MinuteFlipDoc
@1MinuteFlipDoc 4 роки тому
does it have a lot of libraries/imports .. so you get a bunch of stuff for free? I try to write as few lines of code as possible. i don't like to re-invent the wheel. i care more about pre-built libraries (that are available "for free"), versus language syntax. :)
@GaryExplains
@GaryExplains 4 роки тому
Yes it does. As well as the standard libraries there are "crates" which are part of the Cargo build system. See crates.io for details.
@gillianorley
@gillianorley 3 роки тому
But, oh, that NAME. “What should we call our new programming language? How about ‘Rust’? Sounds good. Let’s go to lunch.”
@brunosco
@brunosco 3 роки тому
Gillian Orley 😂
@CyperN077
@CyperN077 2 роки тому
Where's that UTF8 video Gary? 😫
@GaryExplains
@GaryExplains 2 роки тому
Not many people asked for it. I am not sure it would be popular.
@CyperN077
@CyperN077 2 роки тому
@@GaryExplains Well if you get board hook a brother up. 😷
@oluwatomisinbabatunde8426
@oluwatomisinbabatunde8426 3 роки тому
yo gary this is a rust crash course IMO
@zetaconvex1987
@zetaconvex1987 3 роки тому
I'm starting to learn Rust, but I'm wondering if the memory flaws in MODERN C++ are vastly overstated. For most projects it's a non-issue. How is anyone going to do a memory exploit of some silly game I develop, for example? Most systems programming is done in C rather than C++ anyway, So how can anyone say that C++ is vulnerable when it's not used that much in systems programming? It seems that someone has said that C is unsafe, and then thrown the baby out with the bathwater.
@GaryExplains
@GaryExplains 3 роки тому
Because C++ has pointers, just like C, it is just as susceptible to memory bugs. As for you silly game the problem is a) the libraries you link against, b) exploits involving any network activity including web stuff, c) anything that increases the attack surface of a computer... Finally, it depends on how popular your silly game becomes.
@zetaconvex1987
@zetaconvex1987 3 роки тому
@@GaryExplains Well, why don't I just not use pointers in C++; pass references to objects instead, const if necessary? Also, if I don't have the program connect to the web, then I have no network vulnerabilities. Simples. :Like I say, I think Rust oversells the whole memory safety thing.
@GaryExplains
@GaryExplains 3 роки тому
@@zetaconvex1987 You see what you did there was take C++ and change it, now it isn't C++. Many companies have development policies about how a language can be used to minimize the attack surface. Also what you have done is admit that you need to limit what types of programs you can write using C++ for it to be safe.
@zXHAcKeRzXz
@zXHAcKeRzXz 4 роки тому
PUBLISH THE NEXT VIDEO NOW
@nurglerider781
@nurglerider781 3 роки тому
Maybe I'm just old school but a "variable" that is immutable is better known as a constant. I really don't understand the point of this language pattern in rust, it's ridiculous.
Understanding Ownership in Rust
25:31
Let's Get Rusty
Переглядів 231 тис.
Rust Demystified 🪄 Simplifying The Toughest Parts
14:05
Code to the Moon
Переглядів 163 тис.
КАК ГЛОТАЮТ ШПАГУ?😳
00:33
Masomka
Переглядів 2,1 млн
Rust for the impatient
10:43
No Boilerplate
Переглядів 631 тис.
The Talk You've Been Await-ing for
49:58
InfoQ
Переглядів 62 тис.
Big Tech AI Is A Lie
16:56
Tina Huang
Переглядів 40 тис.
How do QR Codes Work? Features, Format, Error Correction, and More!
12:55
Rust Ownership and Borrowing
38:21
Doug Milford
Переглядів 66 тис.
What is the Google Axion Processor? Google's new Arm-based Processor!
5:58
Udio: The Insanely Good FREE AI Music Maker!
8:03
Gary Explains
Переглядів 7 тис.
Rust Programming Techniques
1:32:02
LinuxConfAu 2018 - Sydney, Australia
Переглядів 94 тис.
Rust: A Language for the Next 40 Years - Carol Nichols
55:08
ChariotSolutions
Переглядів 356 тис.
КАК ГЛОТАЮТ ШПАГУ?😳
00:33
Masomka
Переглядів 2,1 млн