Personally i grasped pointers in C/C++ much faster than I grasped the borrow/owner thing. I never understood why pointers were hard to grasp as a concept for other people, it felt very intuitive for me.
@ea_naseer Жыл бұрын
stores address simple. address is where value is stored. pointers were where I first learned you can pass functions as values.
@mbunkus Жыл бұрын
Curious question: did you learn about both concepts roughly at the same time, or did you learn about one (which one?) a lot sooner than the other?
@VojtěchJavora Жыл бұрын
I had some problem with pointers until I programmed some assembly where it finally hit me that you can just store an address of a cell in a cell (this was 8051, addresses have 8 bits, so by cell I mean RAM byte).
@anonymousalexander6005 Жыл бұрын
Because most people start their programming journey in really high level languages from some sort of block language like for high-school robotics to stuff like Python and JavaScript, and then when they decide to learn C++ they try to go at it without help because they are overconfident even though it arguable has the best learning resources at this point, finally after learning basic C++ and getting overconfident with that, because it’s the “hard” language, you learn a language like Rust, which has relatively obscure learning resources, and they get confused at simple things like references or useful iterators. Moral of the story is that being self-taught programmer is rarely being a well-rounded software engineer, usually skipping all theory and never touching assembly or C99 EDIT: some ppl are butt hurt so changed the phrasing just in case they aren't English-fluent.
@lmnts556 Жыл бұрын
It's all in the way it's explained. If the teacher can't explain it simply so that the students can understand he does not understand it himself... Simplicity is key.
@captainfordo1 Жыл бұрын
I have zero interest in writing Rust but still watch these videos.
@frittex Жыл бұрын
your interests are wrong then
@TheDanVail Жыл бұрын
Drink the kool aid. Join the cult. Give up your ownership of your life.
@RenderingUser Жыл бұрын
But have you considered rewriting your interests in Rust?!?!
@itsjustboarsley Жыл бұрын
Lmao same
@smthngsmthngsmthngdarkside Жыл бұрын
You should write in rust
@villuna_ Жыл бұрын
4:57 actually 🤓 RefCell doesn't store values on the heap. RefCell contains an UnsafeCell which is just a wrapper around T.
@ThePrimeTimeagen Жыл бұрын
Okay, good to know In general I still like my if it's boxed it's probably on the heap approach
@Andrew-jh2bn Жыл бұрын
You could be forgiven for that misconception since in my experience it almost always is used with an rc pointer, which is heap allocated.
@SimonBuchanNz Жыл бұрын
Box/Rc/Arc: smart pointers/boxes. *Cell: single threaded Mutexes. Honestly though, it's so rare that you want to use Cell (or UnsafeCell!) I feel they should just add a MutRc and MutArc wrapping Rc and Arc, just to make them a bit less scary looking.
@thekwoka4707 Жыл бұрын
Isn't the T there on the heap, but the cell is on the stack?
@SimonBuchanNz Жыл бұрын
@@thekwoka4707 who are you talking to? If it's me, then no, Rc is an Rc storing a RefCell on the heap (and a ref count), and a RefCell directly contains a T (and bookkeeping on if it's borrowed), so the T is on the heap in that case.
@NphiniT Жыл бұрын
I think the reason Rust is not easy for beginners is because most resources teach it by comparing with other languages instead of just teaching Rust
@RenderingUser Жыл бұрын
The book is pretty decent tho I haven't quite come across stuff from other languages much. Or at all if my memory serves me correctly.
@NphiniT Жыл бұрын
@@RenderingUser I follow the book too. But Rust courses made by people, whether on Udemy or KZbin. Ironically, I'm thinking of making videos now comparing C and Rust lol. But that will clearly not be for beginners. I mainly want to focus on what it takes to make C as safe as Rust.
@coderaiders-yt Жыл бұрын
I think it depends on whether you’re coming from a language like Python or JavaScript vs something like C perhaps. I started rust from higher level languages and never had to think about managing memory before that.
@grawss Жыл бұрын
@@coderaiders-yt Interesting. I came from Python and a little Autohotkey. In AHK you could empty a variable by assigning to nothing (var :=). You didn't need to, but I liked knowing what resources I was using at all times. Python was annoying because I didn't need to do that for the most part, so it felt like I didn't have control.
@RenderingUser Жыл бұрын
@@grawss :o. I also sort of came from python and auto hot key Though i used auto hotkey very little. Didn't have much use for it. Also some gamedev with gdscript Currently learning rust
@ShkumbinMaksuti Жыл бұрын
"I think I can beat Ruby in a foot race" 😂
@mathijsfrank9268 Жыл бұрын
I think what the article meant is that rust has a lot of ways of writing code in an elegant way, which makes it easy to read. Like iterator chaining, question mark errors, and match statements. Where it often gets very complicated (in my opinion) is when generics/macros are involved. I love them macros, just look at the generic VecX types of a crate like nalgebra-glm...
@grawss Жыл бұрын
Everything looks complicated when you don't know how it works. I got into this field late, but I agree with the chat you quoted, scope was harder for me than borrowing. Mostly because of OOP and abstraction getting in the way of what is otherwise a very simple concept, but that's why Rust is easy to learn for true* beginners. *by "true" beginners, I mean people who are learning for themselves. The hungry type of person. I often see people getting their hand held through the process, and they act very differently than the ones who would voluntarily start up conversations about work/programming because they're excited to learn the concepts and ideas.
@sirhenrystalwart8303 Жыл бұрын
I actually think that the syntax of pointers in c is one of the most difficult parts, especially with how they conflate array syntax and pointer syntax.
@Leonhart_937 ай бұрын
Does it conflate it? I am not a C expert, but I know that an array variable is the memory address of the first element, and then you offset the element index by adding to it with [i]. So an array is a pointer address.
@avnishjha7876 Жыл бұрын
Its always the half baked knowledge folks writing medium articles smh
@MrJdsteinhauser Жыл бұрын
When I was weighing languages to use on a project several years ago, I ended up ruling out Rust and Go because of their executable size (> 1 MB). I needed the smallest binary I could get, and I just couldn't get it small enough from Rust or Go. I ended up using C++ to get the smallest binary I could (~40 kB). I'd like to run that experiment again though.
@dynfoxx Жыл бұрын
Make sure you have Rust Debug data stripped if you want a small binary. If you didn't know there is a guide to shrinking Rust Binaries.
@MrJdsteinhauser Жыл бұрын
@@dynfoxx I actually didn't know that! I'll go searching for it. Thanks!
@dynfoxx Жыл бұрын
@@MrJdsteinhauser look up "How to minimize Rust binary size". While Rust is normally larger then C and C++ most of the size is due to Debug info and strings. Though due to how generics work it can also cause code bloat. Though it should not be substantially larger for similar programs.
@connorskudlarek8598 Жыл бұрын
There is a reason Rust and C/C++ are not for beginners... JavaScript, Python, C#, etc: "Grab bread, peanut butter, and jelly. Spread peanut butter on slice of bread. Spread jelly on another slice of bread. Put bread together with peanut butter touching jelly. Eat sandwich." Rust, C/C++, etc: "Go to cupboard. Grab peanut butter jar. Go to fridge. Grab jelly. Go to counter. Grab bread. Deposit all items to cutting board. Realize you forgot to grab a cutting board. Grab cutting board. Place cutting board in workspace. Deposit all items to cutting board. Grab 2 slices of bread. Realize you have the wrong kind of bread. Go to counter. Grab the right kind of bread. Go to cutting board. Deposit bread. Grab 2 slices of bread. Name the first slice bread0, name the second slice bread1. Hold the knife and spread the peanut butter on bread0. Realize you didn't get a knife to spread the peanut butter. Go to the drawer. Grab a knife. Deposit the knife to the cutting board. Grab the knife and spread the peanut butter on bread0. Use the same knife to spread jelly on bread1. Realize you didn't wipe the knife off first, so you're adding peanut butter into the jelly. Realize you don't have anything to wipe the knife off with. Go to the counter. Grab the paper towel. Deposit the paper towel to the cutting board. Wipe the peanut butter off the knife with the paper towel (stackoverflow: "use the bread's built-in function next time, you inefficient wasteful heathen! also, this was closed because it was tangentially asked 6 years ago"). Use the knife to spread the jelly. Put the knife down. Realize you don't have hands to put the bread together with. Invent hands. Put bread together. Grab the peanut butter. Grab the jelly. Grab the bread. Grab the paper towels. Grab the knife. Grab the cutting board. Put each thing away. Realize you put the cutting board and knife away without cleaning them. Clean them. Put them away. Realize the sandwich was on the cutting board when you cleaned it. Make new sandwich. Grab the sandwich, deposit it to the counter. Re-do the cleaning. Grab the sandwich from the counter. Open the jaw and bite the sandwich. After every bite, chew and swallow, until there is no more sandwich." Assembly: "First, gather yeast which will be used to make bread with..."
@tourdesource Жыл бұрын
Yet somebody has to code it all up in C/C++ before you can squeeze that sweet sweet Python one-liner.
@connorskudlarek8598 Жыл бұрын
@@tourdesource exactly right. A bunch of giants, on their shoulders we stand. One day, when you're ready-become the giant.
@FJL4215 Жыл бұрын
3:16 - "There's definitely an Arc..."
@CamembertDave Жыл бұрын
9:00 - I recently was wrestling with this and ended up having to use unsafe blocks with mutable static variables to do what I wanted. It felt wrong, but I was able to accept it when I realized the reason Rust has those features is to accommodate things like what I was trying to do.
@quelchx Жыл бұрын
When I hear programmers say they program in Rust it reminds me of all linux distro hoppers saying I use Arch btw. Unno why -- but I wanted to share my input.
@tyrellnelson Жыл бұрын
I find rust quite easy to refactor... I can fearlessly move multiple files around and separate a whole bunch of functions and types out into different modules.. Then just hit compile and the compiler and rust-analyser will walk me through fixing everything... Library code can be hard to read but a lot of application code with the expressive type system can be quite easy to read or at least understand an overview of how things work
@RuslanKovtun Жыл бұрын
When talking about whether or not Rust is for beginners we have to state what level of expertise we are looking for as a result. If we want to be able to use some libraries and make some simple job done is one thing. If we are willing to cross boundaries of unsafe Rust where strong knowledge of UB is required, there where the fun begins.
@grim.reaper Жыл бұрын
8:30 I believe CSP model is better for concurrency. Communicating sequential processes is a well thought out model imo
@AndrewErwin73 Жыл бұрын
As far as speed.. I DID make Rust faster than Go... don't get me wrong, Go is faster than shit! But here is the thing, Rust is actually faster in many cases; BUT!!! The compiler is not optimized for speed, it is optimized for safety. So, if you tell the Rust compiler that you prefer speed, it WILL deliver. I have done so many tests between the three (Rust, Go, C++) - from something simple like just iterating to 1 BILLION, to some more advanced stuff like prime sieves... with Rust, the trick is not optimizing the code, the trick is learning the compiler.
@regbot4432 Жыл бұрын
Coming from C++ through rust to zig and C, I realized that if you need to constantly debug your knowledge about the language, there is something wrong with the language. Sure If you already spent so many hours writing in such language that you are a chad then ok, but when I came from C++ and then started learning rust, I just said after sometime 'fuck it i don't want to go through such deep rabbit hole again'. However sometimes I get drawn into rust, because I see all those people around bathing in rustelitism and I envy...
@coderaiders-yt Жыл бұрын
Do you mainly write C and Zig now?
@pesterenan Жыл бұрын
My god, I was watching this and missed the "I'm VSCode" part, and now I'm dying here HAHHAHAHHA
@dealloc Жыл бұрын
The only "hard" thing in Rust for me is data structures with circular references, like for LinkedList. It requires a bit more indirection in Rust in order to make the compiler happy (even though what you are trying to do would be perfectly safe, the compiler can't guarantee some of this). The easiest solution is to Box those values, but not always the best approach and doesn't work in all cases. Then you could use Rc and RefCell but those also comes with great responsibility as they could leak memory if not handled correctly. Oh and now you want synchronization across threads and handle deadlocks on mutable data structures; and because the built-in std library doesn't provide the most intuitive APIs for this (or lacking some features), you end up with using something like parking_lot to deal with that. I find that these things are a bit easier to grok in languages like Zig, even though it's more likely that I'd make a mistake for more complex cases.
@maticz3923 Жыл бұрын
For circular stuff you want to use Weak
@jchevertonwynne Жыл бұрын
@@maticz3923 you could, but there's reasons why the stdlib linked list doesn't do that and chose to use raw pointers
@diadetediotedio6918 Жыл бұрын
Linked lists are not a circular references structure
@phoenix-tt Жыл бұрын
@@diadetediotedio6918 Double Linked Lists kind of are
@tourdesource Жыл бұрын
Linked lists are only performant in theory, cache misses make it slower than dynamic arrays for pretty much anything.
@riccardoshrives5881 Жыл бұрын
2023 is the year of the linux desktop
@lmnts556 Жыл бұрын
Probably not lol
@isodoubIet Жыл бұрын
Idk call me when linux figures out us international keyboards
@alexandersemionov5790 Жыл бұрын
The way you pronounce Rust analyzer makes me smile a bit
@제인-y9u Жыл бұрын
Gives me butterflies
@ImranSheikh-kg4qd Жыл бұрын
Let me share my experience with rust readability, I am working with js/ts last 3 years and still struggle with library code, but on rust its not more than 6 months, i am not even that much fluent in rust , but man o man i love reading library code. I don't know why but it feels good to me...your turn
@ThePrimeTimeagen Жыл бұрын
Everyone loves writing code
@Muaahaa Жыл бұрын
I felt borrowing was harder for me because I was used to doing things in other languages that were not allowed in Rust. I needed to change my mental model of memory (which was a big plus).
@unhackablew00t Жыл бұрын
I did less than a week of python before switching to learning Rust. Rust is nice. I did bang my head against the brick wall of the borrow checker and figure out how to get things to work how I wanted too, and realised it was because I was trying to code like "things" are objects like OOP i guess, or how i thought of OOP, but it took me just thinking about it nice and hard on a road trip in the passenger seat before i finally "got" it and then it was much easier.
@timedebtor Жыл бұрын
The first language that I took seriously in school was Ada. I think that languages with rich type systems require a different style of learning than interpretive through it at the walls languages. It's harder to learn on your own languages that leverage a lot of computer science contextual knowledge.
@FaZekiller-qe3uf Жыл бұрын
I read The C Programming Language before reading "The Rust Programming Language". My first programs were written in C, but I'm most confident in Rust. I do understand Rust's ownership and borrowing rules. The first thing I tried to write in Rust was a Unix shell. I have now written more complex things jn Rust and am currently writing a Discord bot and a library for interacting with KZbin's "youtubei" API.
@FaZekiller-qe3uf Жыл бұрын
Rust was perfectly fine for me as a newer programer.
@alexpyattaev Жыл бұрын
writing properly fast c++ is pretty difficult. a lot of smart pointer things in c++ are not zero-cost. c++ makes it really easy to accidentally make copies of objects, wherein c++ will automagically make copy constructors for stuff, especially where you do not want them. threading in c++ is just pure nightmare fuel if you want to go properly fast. so, c++ is theoretically faster, but reacing its speed ceiling is very hard.
@TythosEternal Жыл бұрын
"Rust is not for beginners" => eh? I do think it's a lot easier to understand the *why* of Rust's quirks if you've already shot yourself in the foot with C/C++ first
@jeezusjr Жыл бұрын
When I figured rust was not for me is when I went and looked at the ripgrep code base. I use that tool everyday. The code looks a lot better now then it did five years ago though.
@Yupppi11 ай бұрын
Rather offtopic but I think the biggest issue with learning C today is the part where everything teaches you to use scanf to get input and by now you know it's not a good thing to do, and then you find yourself struggling as a beginner to make user input work smoothly in other ways. And when you mark a string, or more like char[] as const and C just lets anything to mutate it freely and you're in a shock and question what const means. But I really agree about borrow and ownership. It felt really intuitive to me after trying to get rid of unnecessary copying in C++ to write a bit better code. And I guess after hearing a lot of C++ people talk about how the mutability and copying and ownership _should_ work, it seemed like Rust was that. But I agree hard on Rust's strings being just stupid. And all the methods that return different string types. And the whole syntax on creating and defining strings.
@ymi_yugy3133 Жыл бұрын
For new coders a smooth learning curve is crucial. This makes Python and JavaScript such compelling choices. It's easy to get started and get impressive results quickly, that motivate people to keep going and the languages and their ecosystems provide the depth that allow people to keep going. Making anything that isn't completely trivial in Rust is a lot harder. I don't think people can appreciate the pain the borrow checker inflicts on you if you haven't felt the pain of memory leaks.
@dmitry.shpakov Жыл бұрын
2:44 "... crash my hand ..." For this case you have MISRA, btw
@froggy3496 Жыл бұрын
I swear this guy is about to convince me to learn rust and I was like 100% settled on focusing on go for years
@SoMadCoffee Жыл бұрын
Learn Go first, it will take 15 days max to learn most of the language. Then go for Rust, if you really want the benefits of Rust. I am still struggling to make a working rust program. Maybe, because I give up easily.
@josemonge4604 Жыл бұрын
@@SoMadCoffee You probably need to go for C++ first. Until I had a good grasp of C++ and its smart pointers, then I started making good progress with Rust. Plus it's a good idea to learn something like haskell as well to learn the functional programming part. The thing is Rust is like a Frankenstein made up from several different paradigms and concepts from different programming languages. And learning those makes it easier to learn Rust.
@irlshrek Жыл бұрын
Don't listen to these guys. Rust is it's own thing and you don't need to know anything else in order to read The Book
@SoMadCoffee Жыл бұрын
@@irlshrek I am not saying learning Go will make learning Rust easy. I'm just saying that Go will probably take less time to learn. So, learn that first. It won't take much time.
@RenderingUser Жыл бұрын
@@SoMadCoffee start out with small projects then. I stated with a simple terminal program Now I'm currently working on a full tui application. After that imma go use wgpu
@12MrRetro Жыл бұрын
Main problem of rust for beginners - is no jobs for beginners. And all what you have, is Java, Python or JS
@dankmersi4282 Жыл бұрын
Not me thinking that Prime played Rust ...
@PS3PCDJ Жыл бұрын
3:35 Better term would be "explicit" as in "one you know what each token means then it becomes painfully obvious"
@minandychoi8597 Жыл бұрын
ocaml is like python 2 and 3 in the same language with the whole jane street thing. it divides the already tiny ecosystem into two even tinier incompatible ecosystems with barely anything documented. NOT for anything remotely serious unless you just write ocaml 24/7 so you know the ins and outs and your way around it and all. practically a DSL for jane street though not technically (JDSL fr). i dabbled in ocaml before getting on the rust train and have NOT looked back. you’re really not missing out on much tbh
@aoeu256 Жыл бұрын
What are the problems you got in OCAML? The problems this guy has with the types in RUST sound like the problems I had with types in Haskell... Its easy to build the wrong type for your program, you don't really know if you need a -> b, or a -> SomeMonad b, or whatever until its too late and I haven't seen refactoring tools that help me change code when I want to change the types of my program. I wonder what kind of problems I would get in Julia or Mojo or CloureTyped hmm...
@isodoubIet Жыл бұрын
" practically a DSL for jane street thought not technically." I mean that's probably very true if uncharitable, ocaml would be just another dead language if not for them
@fish1r1 Жыл бұрын
I've found harder to learn, but not because of the borrow checker and ownership, but by simply the lack of knowledge how to piece things together and have a decent architecture. Like what's idiomatic? How to pass a damn sqlx transaction to several functions (&mut PgTransaction)? etc I usually ask chatgpt if a bit of code is idiomatic.
@monkev1199 Жыл бұрын
Yeah this is partially why I say Rust punishes bad architecture. Architecture is very important to consider.
@fish1r1 Жыл бұрын
@@monkev1199 exactly but it doesn't show you the way. If you want to use a rust library, it's documentation include a basic example or a very complex one, or nothing. You have to understand all the Rust concepts with like Send and 'static and other things and as a newcomer, even if I walked the Rust book and docs, coming from a dynamic language is hart to actually put those concepts into practice. I guess the learning curve is a bit steep in the begining.
@botondhetyey159 Жыл бұрын
I started with C/C++ at university, but at work, I only do JavaScript. Rust is not particularly hard for me, definitely simpler for a big project then C or C++. But I do have plenty of functional programming experience from uni, I think that helps a lot.
@cherubin7th Жыл бұрын
I move to Rust, because I can understand it much better than Python. Python is like pseudo understanding, but everything is so hidden that when I try to use it, it never makes sense. C++ is impossible to comprehend to me and everything is ripped apart with the .h files. Java and Go were fine to read. IMHO
@user-ge2vc3rl1n Жыл бұрын
The reason why python is undesirable to me is that you can write code in Python and not know which parts are efficient because of the C api and which parts are slow because its just python. This is something that you can know with experience but its a deal breaker for me. For instance, C# doesn't have this issue at all. You can write C# in any way you like and the only thing you have to care is how you solved your problem, not how the another API is dealing with it.
@sledgex9 Жыл бұрын
It depends on where you started. You started with Python. If you had started with C or C++ you would have grokked header files. Personally, I can't grok how other languages can cope without headers. Aka having a split between interface/declarations and actual implementation. Especially for bigger projects. (for the programmer's reading comprehension. Not for compiler speed).
@aoeu256 Жыл бұрын
Python devs think in data and/or behavior not really in types maybe, and Python code can be more dense (although not as dense as Haskell). You can introspect code with type inference too.
@aoeu256 Жыл бұрын
@@sledgex9 You can have your IDE build an outline without the need of header files, also dynamic languages with introspection features you can loop over all functions in a certain module and print out their call definition using inspect, and you can store metadata like logged inputs/outputs inside a associative array to each function ask chatGPT for that.
@isodoubIet Жыл бұрын
@@sledgex9 header files are a really crummy way to make that separation though. That said, if you're having trouble understanding C++ code because of that separation that to me just speaks to lack of experience with the language.
@NotherPleb Жыл бұрын
If Rust it's not your first language, it might be confusing why some simple things can't be done in Rust. However, a new programmer doesn't know how it's usually done and the paradigm can click easier.
@principleshipcoleoid8095 Жыл бұрын
5:09 well you can use Arc instead of Vec to speed it up somewhat. When tge data is not going to grow and isn't goint to mutate and you just need a bunch of things to know about it
@riccardoshrives5881 Жыл бұрын
I'm, VsCode.. I, am, VsCode! I, am - I AM VSCODE! I AM VSCODE, Dr. Han! I AM VSCODE!
@hughmanwho Жыл бұрын
I find ownership and borrowing simple idea BUT it's a lot of overhead to constantly have to think about
@playea123 Жыл бұрын
12:20 imho, it depends on why you want to learn programming. I think if you want to learn programming in an academic sense and want to really understand what’s going on under the hood, Rust is great because it is safer than C or C++. If you want to just build something and getting into programming as a path to achieve the goal, Rust is hard since it is low level and doesn’t have as big a community as languages like Python or JS where someone has probably already run into an issue you are facing.
@Robert-ht5kd Жыл бұрын
Apart from long compile time, the article doesn't contain real flaws of Rust, like very unreadable syntax. For example pub fn execute(&self, f: F) where F: FnOnce() + Send + 'static, { let job = Box::new(f); self.sender.as_ref().unwrap().send(job).unwrap(); }
@kurt7020 Жыл бұрын
Amateur. You can stuff at least 2 more generic types, another explicit lifetime, at least 3 question mark operators, and a closure in there. lol.
@Robert-ht5kd Жыл бұрын
@@kurt7020 Say this to Steve Klabnik and Carol Nichols authors of "The Rust Programming Language", because that code is from their book, genius. By any chance, are you Tom?
@AlexanderHyll Жыл бұрын
Am I damaged or is this kinda readable? Think its way worse when you run into convoluted trait objects in multiple levels with higher order trait bounds making it feel like chasing inheritance. Broke my brain twice figuring out Actix extractors (although I love them).
@Robert-ht5kd Жыл бұрын
@@AlexanderHyll OK, for you it is readable, for me it is waste of time to try figure out Rust code. I can use easier languages.
@kurt7020 Жыл бұрын
@@Robert-ht5kd XD
@careymcmanus Жыл бұрын
Rust is great and I love it but there's a reason I program C# and python at my company and that is because rust is hard. Its easy when you understand it but there is a steep learning curve. I work at a company where the majority of people are not software folk but engineers of other descriptions. We choose python as language because thats what people know. Personally I love programming in rust and I think that if you learnt C for say embedded than rust is not hard. I learnt rust for embedded because c++ is insane on tiny microprocessors as dynamic memory is not a thing. If you are a beginner programmer (not in a job) than you should use the language that fits yours goals. Are you trying to get something up and running? use JS, TS, java, python. Are you trying to learn how computers work? use C, Rust, C++. There are great reasons and negatives for all languages and it depends what you care about. C is great if you care about predictable performance (as in gaurentees that something will execute in at most a certain amount of time, but you have manage dynamic memory) C++ is great if you care about optimal performance (Allows automated memory allocation and often has a garbage collector which has a cost) but mistakes are easy (mistakes are also easy in C, probably moreso) Rust is great if you want the benefits of C++ without the negatives (Theree's no garbage collector because the language has compile time memory safety checks). THe downside being there is a steep learning curve to rust. JS is bad don't use it Typescript is better because types are great and if you are doing web stuff then its the way to go, find a framework that supports typescript out of the box and go ham. python is also great! It needs enforced typing and I hate the significant white space but it is accessible. Python is great but to fully utilise its power make sure you use its packages, particularly numpy and pandas. Python is a low performance interpreted language but those libraries are written in compiled languages, I believe numpy is written in fortran.
@tourdesource Жыл бұрын
Garbage collection is very rarely used in C++ and certainly not standard.
@rallokkcaz Жыл бұрын
The memory allocation part is a lot more prevalent in async/multithreaded rust.
@rallokkcaz Жыл бұрын
The footprint is not that small compared to C and C++ in terms of binary size.
@rallokkcaz Жыл бұрын
The go part about concurrency is really true too.
@ccgarciab Жыл бұрын
@@rallokkcaz binary size can go down by tweaking, but it definitely is less of a priority than other aspects like performance.
@TheBlackClockOfTime Жыл бұрын
Okay ngl I thought this was going to be about the PC game Rust. And I had some really dark expectations for some reason. Carry on.
@principleshipcoleoid8095 Жыл бұрын
7:28 sadly Bevy on MacOS has a memory gobbling problem. It does free the memory when you turn it off, and isn't happening on WASM builds, but it's still annoying
@skrundz Жыл бұрын
I built a super simple rocket server that just renders a tera template; it takes 13 minutes to cross compile to x86 linux from my M1 MBP lol
@andythedishwasher1117 Жыл бұрын
That was a pretty sick NPM/leftpad dual burn.
@vids4mee Жыл бұрын
"hold on new asmongold cooking video just dropped" i feel like i'm in the right place lmao
@d0rban Жыл бұрын
At the moment, my biggest block on Rust at the moment is lifetimes.
@eaglethebot135410 ай бұрын
Ownership and borrowing is pretty simple. You define a variable in one place, and next time it appears in the code its consumed. If you use it multiple times in the file after definition then try throwing an & before the variable's uses to use a reference, if that doesn't work then clone. Then if you remember you can't immutably borrow a mut variable you're in business!
@jjones503 Жыл бұрын
"I Don't See My Nipples" - Professional Programmer
@genericdeveloper3966 Жыл бұрын
Yeah I'm with you. Rust code can get hard to understand especially when traits + generics get involved. Not to mention to implement or extend a library.
@SmplySilver Жыл бұрын
rust binary sizes are absolutely not small compared to any other compiled language, given they statically link everything and don't do LTO to strip out unused functions by default
@NieLL1 Жыл бұрын
Speaking as a 31 year old dumbass with a social sciences background, learning Rust has been pretty manageable so far. I've recently finished reading The Book, and I watched the first 5 CS50 lectures and believe I understand enough of memory usage and the workings of the borrow checker. People that hype up the difficulty of learning Rust are actually doing a disservice because I've been postponing this endeavour for about a year just because people claim it's so hard, and in fact it's not been 'hard' at all. Of course I sometimes get confused about how to massage the code so the borrow checker is happy but that's simply due to inexperience with the language, not because it's hard to understand. Again, I picked up Rust without *any* maths or programming experience, after only 2 weeks of tinkering with Python, and am now doing Medium level Exercism exercises after about 6/7 weeks. If anything trait bounds and concurrency have been much more complex to grasp than ownership and borrowing
@evergreen- Жыл бұрын
Just curious, why does someone with social sciences background learn Rust? What use cases does it have for you?
@greglocker2124 Жыл бұрын
Rust is hard. It's cringe when people try to humble brag that it isn't. "I don't know why people say it's hard! I'm smart XDXD" 6-7 weeks is a long time to learn a language. It sounds like you are nowhere near done. Spending 2 weeks on a language is a long time - unless it's Python - which should take less than a day. It's so irritating to constantly read about someone doing some baby project going "iTz NoT tHaT HaRD gUysE!" And then they proceed to out themselves as a noob. It is so obnoxious to claim something is easy when you clearly don't even know what you don't know yet.
@NieLL1 Жыл бұрын
@@evergreen- I'm very interested in OSS. Hope to be able to contribute at least with basic things in 12/18 months :)
@NieLL1 Жыл бұрын
@@greglocker2124 I'm obnoxious, noob and cringe? sounds a lot like someone is struggling emotionally and lashing out online for no reason :) and on top of ugly disagreeable traits that person also struggles with reading comprehension. If you reread my message you'll see I said "it's been pretty manageable" and "not 'hard'". I also qualified myself as a dumbass with no technical background at all. But it seems you are not much brighter than I am because you're naively confusing the difficulty of a task with the time it takes to complete it (you don't know how long I can dedicate to the task a day or how busy I am everyday with family and other tasks etc). My suggestion would be to completely reassess your life choices as you are clearly not in a good place mentally right now. Have a good one!
@tourdesource Жыл бұрын
@@greglocker2124 I've been learning C++ for a couple years and I'm not even close to done. Must be great to be able to learn a language in a matter of weeks!
@EthanBradley1231 Жыл бұрын
I think ownership and borrowing can be tough for beginners who don't know what kinds of mistakes those systems prevent you from making. If it isn't motivated by the pain of programming in an unsafe language then it might be easy to wrap your head around but hard to understand why it's needed at all.
@Yiyang_Kang Жыл бұрын
16:07 "Dereference and call the function that 'foo' points to after it has been typecast to a pointer to a function taking no arguments and returning void." (translated by ChatGPT)
@Robert-ht5kd Жыл бұрын
When I read Rust code every 2 minutes I have WTF moment, WTF this code does? I've never had such problems with C#, C or even Scala which is functional language.
@MrSofazocker Жыл бұрын
I still find it hard to believe you cant infer types across a program, without types at all. Like why is an compiler not doing the "hard-work" of running each code each subsequentily for it to know if any infered type was used incorrectly and yell at you... Most of the time, you still have to find out the hard way at runtime if something breaks.
@heater5979 Жыл бұрын
Ownership and borrowing are concepts you have to learn in C and C++. Get it wrong and you will be debugging problems with dangling pointers, memory leaks, race conditions etc. It's ustthat the compiler does nothing to help you. Rust deals with the issues of ownership of ownership and borrowing at compile time and supports the concepts with its lifetime annotation. So no, ownership and borrowing are no harder to learn in Rust that C or C++.
@JackDespero Жыл бұрын
I think that Rust is hard for programmers because they need to unlearn C and then learn Rust. For beginners, I would say that Rust is easier than C. Not having to worry about pointers puts it already miles ahead of C. A normal person can easily understand borrowing intuitively: This is my book, I can lend it to y'all, but you are not allowed to write/highlight on it; or I gift you my book and you can do whatever you want with it. Super simple. People starting do not have the C structures and patterns ordering their heads, and thus they do not have a hard time trying to fit Rust, because they will find themselves in the situation of "I have been solving this problem with C in this way for decades, and goddamn Rust does not allow me to do it!", they will simply say "oh, it is super easy to solve with Rust in this way". It is hard to use a technology for decades and retain the degree of plasticity required to learn a new paradigm.
@yevgeniygrechka6431 Жыл бұрын
One of the worst decisions that Rust made in its docs was to call references, "immutable" and "mutable", since these descriptors are basically false due to interior mutability. The correct descriptors are "shared" and "exclusive", but for some reason they are not used as much.
@dynfoxx Жыл бұрын
I think shared and exclusive are better terms as well. Though immutable is not wrong. You cannot mutate through a non mut reference. You must always get a mutable reference before changing a memory address.
@wesleyoliveira6570 Жыл бұрын
I don't agree with the blog poster's argument about not being for beginners, Rust is my first real programming language and I didn't find any of the memory concepts difficult to learn. What I found confusing is the structure of rust projects, as a few days ago I tried to make a project by compiling a binary and a dynamic library, it was a pain to know how to do this.
@anders3460 Жыл бұрын
The problem with ML style type inference is that it's fairly easy to make a type checker which works, but hard to make it return meaningful error messages.
@ccgarciab Жыл бұрын
IMO keeping the inference boundary at the function declaration level keeps the error fairly contained and therefore easy to grasp.
@Danielo515 Жыл бұрын
Absolutely. In practice you anotate the return values of functions or you will have weird type errors very far away from the actual problem source
@aoeu256 Жыл бұрын
You can just turn off the type system and edit your program in the REPL with lots of tests that way you dynamic error messages like in Python & LISP which can be easier to understand at first until you understand the advanced type inference compiler algorithm.
@tourdesource Жыл бұрын
@@aoeu256 Interesting strategy. Is there a Rust REPL, though?
@afterschool2594 Жыл бұрын
C is like simplicity in process, Rust in the other way is simplicity in result
@tacticalassaultanteater967818 күн бұрын
I think it's a huge mistake that Rust simultaneously pushes lambdas and doesn't support specifying the binding modes of individual variables explicitly like C++ does. Every day I write 5 lambdas that have to take ownership of one value and immutably borrow another.
@bigtymer4862 Жыл бұрын
Rust codebases are very involved no doubt
@bluewatermelon219 Жыл бұрын
Dude, Rust easily outperformes Java, Go and C. There are many benchmarks where Rust performs faster than C++. Good luck.
@ThePrimeTimeagen Жыл бұрын
Rust and C and C++ should have very similar performance. It is easier to make C or C++ faster often, but the real problem is getting it correct
@wyatt8770 Жыл бұрын
Somone in the chat said "What about all the string types in C", and I'm trying to figure out what version of C has an actual string type
@atiedebee1020 Жыл бұрын
I think they mean the difference between char[] and char*
@dynfoxx Жыл бұрын
The Real difference between Rust strings and C strings is that Rust is explicit about what kind of string it is. Both have owned strings and non owning strings, C just doesn't mark them. They both have null terminated and sized strings. They both have different encoding ANSI, utf8 and more. OSstr is dependent on compile target for both languages Rust just encodes this in a type.
@monkev1199 Жыл бұрын
wchar_16 and wchar_32?
@isodoubIet Жыл бұрын
@@atiedebee1020 that's like the difference between 0.9999.... and 1
@atiedebee1020 Жыл бұрын
@@isodoubIet absolutely not, when creating a string as char* s = "hello" this string will be put in read only memory, whereas char s[] = "hello" will be put on the stack
@emjizone Жыл бұрын
3:28 _Rust_ is *verbose.* Reading Rust force you to read all the *details* about types, etc… it's a lot of signs and words compared to languages that do more under the hood based on implicit rules. *Reading a detailed implementation is always more difficult than reading a structure.* And there are too many pre-defined types in Rust.
@embedded_software Жыл бұрын
This article is so poorly written I can't even finish the video
@electron6825 Жыл бұрын
If it weren't for the spelling errors I'd have assumed this was chatGPT written 😂
@maticz3923 Жыл бұрын
Whoever wrote this doesn't know shit about programming
@isodoubIet Жыл бұрын
Maybe you just think that because you're not vscode
@peterromfeld4091 Жыл бұрын
i never got over the compile time of rust, seems like 6 years later it still sucks... im more of a TDD guy, do tiny change and get immediate feedback
@jboss1073 Жыл бұрын
5:50 "it's not faster than C++" - Yes it is, the source is "Ranking Programming Languages by Energy Efficiency" which measures also time in a normalized way, and in that ranking Rust outperforms C++. In the most up-to-date measurements on the authors' website, Rust continues to outperform C++. So yes, Rust is faster than C++. However, C++ is the next fastest language, out of the 35 most popular as used by the paper. I have no dog in this fight, as I do not use either C++ nor Rust.
@NoX-512 Жыл бұрын
Did the paper also rank Rust as faster than C? Because you can write C++ programs that is essentially C code. You can always write a C program that outperforms everything else except hand optimized assembly. Provided you have the skills, of course. The compiler and compiler options used are also important factors.
@jboss1073 Жыл бұрын
@@NoX-512 The paper, when it was published, ranked Rust second place right behind C and ahead of C++ (top few languages in the Time measurement, in order and with multiplier for how-many-times-slower-than-C (rather, how many times slower than the first language, which happens to be C): C = 1.00, Rust = 1.04, C++ = 1.56, Ada = 1.85, Java = 1.89, Chapel = 2.14, Go = 2.83). However, the website has measurements that have been updated to 2021, I believe, from the 2017 date of publication of the paper. As it stands by those more recent measurements, Rust is now = 1.00, meaning it is just as fast as C. Indeed the Programming Language Shootout uses 10 algorithms to measure the speed difference between C and Rust, and each of those languages wins on 5 algorithms, making it a perfect tie for fastest language between C and Rust. C++ has not closed the gap (it kept being 1.56 times slower than C). Hence the old myth that "Because you can write C++ programs that is essentially C code" does not seem true. Also, a reminder that C++ is not a superset of C.
@NoX-512 Жыл бұрын
@@jboss1073 I'll bet the C++ samples weren't written in C style, because that wouldn't make much sense in such benchmarks. Although C++ is no longer a superset of C, the features that C has that C++ doesn't, is not something you notice in day to day use. Take such benchmark with a huge grain of salt. The coding style and skill level can also have a big impact on performance.
@jboss1073 Жыл бұрын
@@NoX-512 As of now it's (1) the most trusted website in measuring language performance and (2) the most recent and most quoted paper measuring language performance both agreeing that Rust is as fast as C ans that both are noticeably faster than C++. I do not advise too big a grain of salt.
@NoX-512 Жыл бұрын
@@jboss1073 It's syntetic bencmarks. They often don't translate well to real life performance. I have no doubt that Rust is fast, but which language is fastest, will be different for different use cases, and heavily dependent on the compiler used, and the programming techniques applied. Writing C style code in C++ produces the same machine code as writing in pure C.
@codingtranquility Жыл бұрын
The Book and Rustlings are fucking amazing together ... sure it'll only take you so far, but it's been a much better experience than any other language I've worked with.
@irlshrek Жыл бұрын
Couldn't agree more!
@chrisdaman4179 Жыл бұрын
Wasm is not taking over. It's so cumbersome to work with. And the binaries are NOT small
@rotteegher39 Жыл бұрын
2028 Linux Desktop 6:50 1 pack singular item. 14:54
@br3nto Жыл бұрын
7:08 web assembly is like Java applets… where did they go?
@diadetediotedio6918 Жыл бұрын
3:16 I think this has more to do with your coding practices. Even a C# program can be very ugly and hard to read depending on how you do it
@sofiaknyazeva Жыл бұрын
That blog seems somewhat wrong on some points.
@PurpleLibRight Жыл бұрын
Traits ,lifecycles & impls are a pain in the ass to read.
@irlshrek Жыл бұрын
If by "life cycles" you mean "lifetimes" then what I would say to that is that lifetimes aren't for humans to read. It's just for the compiler to understand what it needs to enforce rusts memory safety guarantees. When trying to understand what the code is intended to do you can almost always tune lifetimes out entirely.
@thalissonvieira7008 Жыл бұрын
tech events just broke me LOL
@mannycalavera121 Жыл бұрын
Your videos keep me sane
@isodoubIet Жыл бұрын
I had to check out when the dude started making matter-of-fact performance comparisons between languages that for all intents and purposes let you code exactly the same thing with performance within the margin of error of one another. "Rust is faster than C++ but not faster than C" I guess his brain would implode if he compared std::sort against qsort
@cubbucca Жыл бұрын
Rust is the first language that even with a working example I have to read the book. dyn and impl make me pause to think every time.
@redhawk3385 Жыл бұрын
For me I just started only driving Linux, so it really is the year of the Linux desktop.
@banatibor83 Жыл бұрын
I like to learn about programming languages but at the end of the day I always end up with Java. Java is simple and easy, it has excellent tooling and wast amount of libraries. And the best, no magic!
@Mitch_Crane Жыл бұрын
Respect
@NoX-512 Жыл бұрын
The few times I’ve had to write Java code, I found it to be an enjoyable experience. As long as you know it’s limitations. Compute heavy and low level stuff is better left to C/C++/Rust/Zig etc.
@KnightMirkoYo Жыл бұрын
Cstr is stuck, what can I do?
@Julianacan Жыл бұрын
Love the energy, RAAA~
@fish1r1 Жыл бұрын
18:00 happened more than once
@0marble8 Жыл бұрын
I think Rust isnt great for beginners because you cant really build the standard data structures like a linked list yourself without using unsafe
@rickdg Жыл бұрын
It’d be really cool if you talked to someone handling a large Rust project, like Zach Lloyd from the Warp terminal. He recently had an interview in the Syntax podcast and was pretty interesting.
@max_ishere Жыл бұрын
0:00 There's no dark side :wq
@ThePrimeTimeagen Жыл бұрын
There is great power on the dark side
@seyofori Жыл бұрын
Reminds me of Demeter's law
@sortof3337 Жыл бұрын
simple does not equal easy. It is fking simple to see and say that you understand world, world is freaking simple. But its not easy thing to comprehend. I think programming is the same.
@ThePrimeTimeagen Жыл бұрын
Agreed
@fredoverflow Жыл бұрын
Have you seen Rich Hickey's talk "Simple Made Easy"?
@sortof3337 Жыл бұрын
@@fredoverflow yes yes i have. Where'd you think I got my opinons? LOL I recommend how to scam american programmer. THat is a good talk as well.