As all C programmers say, with great power comes great 'segmentation fault at line 115'
@heroes-of-balkan
Жыл бұрын
It gives line position where segfaults 🤯🤯
@timecubed
Жыл бұрын
@@heroes-of-balkan it's worse when it doesn't. I've had segfaults but it gives me the line.
@heroes-of-balkan
Жыл бұрын
@@timecubed lucky you
@BryanAnderson-o1u
Жыл бұрын
hahaahah
@nogit387
Жыл бұрын
As all JS developers say, with great power comes great '[object Object]'
@TrustifierTubes
2 жыл бұрын
Hi my friend, as a fellow C programmer, who switched to Rust a year ago after 30+ years of C. I would highly recommend dropping the OS packaged rust (i.e. using apt or rpm) and use rustup instead! The packaged versions tend to be several version behind, and Rust is hyper evolving right now (including the stable version. for example there is a major CVE that got addressed in 1.58.1 that plagues all previous versions). Also, with rustup you will get the latest and greatest version of rust-analyzer which in-turn makes integration with IDEs a lot cleaner.
@simonfarre4907
2 жыл бұрын
True. But even so, the OS packaged version is *so much more current* than a lot of other languages, and I think rustup is the reason for that.
@vlya1533
2 жыл бұрын
@@simonfarre4907 usually "current" is "unstable". So, you literally said "rust is _so much more unstable_ than a lot of others languages"
@louiscloete3307
2 жыл бұрын
@@vlya1533 No. Rust ships on the same schedule as Firefox. Every 6 weeks a new beta is branched off. If it survived 6 weeks of beta testing, it's pushed as the next stable release. Once it's been released as stable, it guarantees backwards compatibility. So any code which compiled with a previous stable compiler must still compile with the new compiler, and any code it can compile must compile with all new stable compilers further along. The amount of bugs on stable is almost nonexistent. I know of one serious bug in 2 years and about 10 bugs in total that was fixed with patch releases over that period. Just because it doesn't work as things had always worked doesn't mean it isn't as stable. The one doesn't necessarily imply the other. If you have empirical evidence of rustc's instability compared to MSVC, gcc and clang, that's another matter altogether.
@vlya1533
2 жыл бұрын
@@louiscloete3307 who are you arguing with? I've not commented or asked anything about rust beta release cycle :)
@louiscloete3307
2 жыл бұрын
@@vlya1533 > usually "current" is "unstable". So, you literally said "rust is so much more unstable than a lot of others languages" I wrote that to explain why "current" isn't necessarily "unstable".
@disgruntledtoons
Жыл бұрын
C succeeded because it enabled engineers to get stuff done. Whether Rust overtakes C depends on whether Rust developers can get stuff done more quickly to the point that the advantages are clear. This means the learning curve must not be too steep, and there cannot be chronic situations where the developer has to learn something that won't be used for another sixth months.
@verified_tinker1818
Жыл бұрын
But C++ also has a steep learning curve, yet it's so popular, so that can't be all.
@The_Jesmaybe
Жыл бұрын
@@verified_tinker1818 true, but, you can gradually adopt the more complex parts of c++ and basically just write c to begin with. Which makes it MUCH simpler/easier/quicker to get started with and become productive with than Rust
@nscarlos25
2 жыл бұрын
The binary is huge because this is an unoptimized version. You can get it way smaller if you compile it in release mode. There's no runtime in Rust. All the checks are made at compile time.
@Matt-mn4bw
2 жыл бұрын
Ye I was confused when he said this
@laravelisbullschitt3281
2 жыл бұрын
Ironic that everyone using rust is non binary!
@darkfire2703
2 жыл бұрын
Building in release mode and stripping the binary results in a ~310Kb exectuable. This still includes parts of the rust standard library which is statically linked. When using no_std like you would in embedded, this size is again smaller by an order of magnitude.
@laurenpinschannels
2 жыл бұрын
@@laravelisbullschitt3281 im continuous
@louiscloete3307
2 жыл бұрын
@@dansanger5340 But its runtime is similar in what it does and what it provides to the C runtime (and yes, C also has a runtime which sets up the stack and calls your main()).
@notshbn
2 жыл бұрын
In rust you don’t necessarily need to provide the “return” or the semicolon on the last line as long as it’s what you intend to return from your function
@saadisave
2 жыл бұрын
Using explicit return is actually against the official style. The return keyword is only used for early returns.
@fartzy
2 жыл бұрын
@@saadisave this is the case for Scala as well
@rafagd
2 жыл бұрын
Well, in this case you wouldn't need return even if you had to have returns, as it's a void function
@love9-tied
2 жыл бұрын
it’s like gcc statement expression
@plopph8811
7 ай бұрын
Allowing to be untidy is part of the root issues of modern programming. Idiots are getting les rigorous and that is a major problem
@hugo4it
2 жыл бұрын
5:10 - Just want to add something here, you can *always* dereference a pointer safely, unsafe mode also allows dereferencing *raw* pointers.
@kangalio
2 жыл бұрын
It's better to say reference instead of pointer though, or people will get confused and think you're talking about raw pointers
@ertugrulghazi334
2 жыл бұрын
C is 50 years old but still a top 3 language. It won't be going anywhere anytime soon.
@monsterhunter445
2 жыл бұрын
Maybe anytime soon could mean tommorow. Doesn't hurt to learn rust or an alternative. Don't be conservative with your tooling it's good to explore.
@jonathanmoore5619
2 жыл бұрын
Open your mind.
@ertugrulghazi334
2 жыл бұрын
@@jonathanmoore5619 Okay Morpheus.
@jonathanmoore5619
2 жыл бұрын
@@ertugrulghazi334 nonce
@ertugrulghazi334
2 жыл бұрын
@@jonathanmoore5619 come on, that was a good one.
@nickscurvy8635
2 жыл бұрын
What happens in unsafe stays in un- SEGMENTATION FAULT(core dumped)
@codigodesenior3995
2 жыл бұрын
this is my nightmare
@blackcitadel37
2 жыл бұрын
C++ feels
@nickscurvy8635
2 жыл бұрын
@@codigodesenior3995 sigsev is a blessing, not a curse. What would happen if the OS were not protecting that memory address would be potentially catastrophic, not just slightly frustrating. Imagine learning to program back in the day when you could accidentally brick your device while programming.
@codigodesenior3995
2 жыл бұрын
@@nickscurvy8635 thx, i i didn't think about it...
@tompycz2225
2 жыл бұрын
There are other languages as old as C, even older. But nobody ever hears about them anymore, because they weren't so good or didn't have such uses as to still hold up after so many years, as opposed to C (or are still used in niche cases, not popular ones). So "old" isn't really an argument. It's an excellent language in so many ways.
@Theineluctable_SOME_CANT
2 жыл бұрын
FORTRAN...
@tompycz2225
2 жыл бұрын
@@Theineluctable_SOME_CANT my grandmother coded in that, I'm not even kidding
@tompycz2225
2 жыл бұрын
@@ElSantoLuchador it's going to be interesting to watch whether there will be an uptick in the use of those older languages, as we approach the end of Moore and start going into more optimization.
@zackyezek3760
Жыл бұрын
C is the Latin of computer languages. Still used directly by a powerful but obscurantist elite (for Latin the Catholic Church hierarchy, for C the kernel and assembly level developers), and a direct ancestor of the languages most of the planet now uses. FORTRAN is really the only other language that old that’s still in use. One of C’s often overlooked strengths is that it really IS a basically zero overhead, portable assembly with a good syntax. Yeah you don’t get all this invisible magic code and “safety”, but that’s because C was designed for writing the very bottom of the software stack, the foundations upon which things like that rest. One thing I really wish Rust hadn’t done was import some of Python’s bonehead syntax decisions. “Less ‘unnecessary’ punctuation” sounds nice until you realize that HUMAN languages moved in the exact OPPOSITE direction over the past ~250 years, for very good reasons like clarity and ease of reading.
@felixmoore6781
Жыл бұрын
@@zackyezek3760 You're forgetting the largest part of this powerful elite (maybe on purpose-are you one of them?), embedded programmers. And they secretly control absolutely everything that has electronics in it, which today is everything- your car, assembly line robots, life support equipment in hospitals, traffic lights, smart toilets, phones and computers have chips in them that run their own code completely invisible to the OS, flight control systems, electrical grids, washing machines, etc., etc., even your espresso machine. Their power is immense. If we anger them and they decide to abuse it, then we're all doomed.
@toddmartin7629
2 жыл бұрын
Rust's biggest draw back in embedded is the limitation of architectures it supports due to LLVM. Now this can change, but as of right now, if LLVM doesn't support a chip, neither does Rust. And LLVM is lacking in a few areas. Hope to see this improve though.
@cameroncarter3332
2 жыл бұрын
Rust is the future of computer programming. Expect good things concerning Rust.
@dynfoxx
2 жыл бұрын
Rust does have the WIP gccjit compiler and the GCC official implementation. Both will allow you to compile rust to anything gcc can.
@fumseck
2 жыл бұрын
They are currently planning to remove LLVM from the toolchain
@Connie_cpu
Жыл бұрын
Xtensa is still the main backend I'm waiting on, but at the same time I'm seeing more microcontrollers move to RISC-V like Espressif's new ESP32-C3 and Rust works amazingly out of the box on that platform
@mikeywisniewski
2 жыл бұрын
Seconded, would love to see Rust running with Raspberry Pico.
@peter9477
2 жыл бұрын
I saw a video yesterday where it was...
@historichacker2013
2 жыл бұрын
it aldready does
@KyrychenkoAnton
2 жыл бұрын
What I'm not quite get is why its positioned as a replacement to C and not C++. Its much much more complicated than C with all impl/move/async/smart pointers/generics/lifetimes semantics, whereas C is basically an assembler macroses. So I think rust should in theory replace C++ then, but speaking of C++ - there's already 20'th redaction with move semantics/smart pointers/generics etc and lots of code analysis too. So idk, having nothing against Rust though, but this obsession on "replacing" C....
@LowLevel-TV
2 жыл бұрын
It's definitely a topic I'd like to learn more about. I don't see a world where Rust ever COMPLETELY replaces C, but I think there's room for replacement in small quantities.
@KyrychenkoAnton
2 жыл бұрын
@@LowLevel-TV Sure, I actually love languages that have smth unique in this day of c-like llvm/jvm languages everywhere, rust definitely fun to write with its immutability by default and borrow-checker way of thinking, so kudos for it! xD
@CallousCoder
2 жыл бұрын
I do agree! It’s such a whiny complaining compiler. If you are a C/C++ developer it feels like torture.
@SkyyySi
2 жыл бұрын
Are you sure about that you're not just looking at this wrong? The question isn't whether Rust is more complex than C. The question is whether writing code that is memory safe with absolute certainty is more difficilt in Rust or C.
@CallousCoder
2 жыл бұрын
@@SkyyySi it’s not really that difficult to write memory safe code, once you’ve learned it. And you have brilliant profilers that test this. And size of binaries does matter. Especially in the embedded world. So I don’t see Rust as a C/C++ killer. Just another language that complements the list of nice compiled languages.
@TekCroach
11 ай бұрын
C and C++ never die. The most powerful and the most versatile languages ever made. People just need different experiences and that’s why they are making alternatives.
@saturdaysequalsyouth
2 жыл бұрын
It is easy to make mistakes in C but they're not impossible to avoid if you're aware of a few simple rules. Failing that, there are tools to help you like static analyzers. Adding optional extensions to the C language for safety and reliability would, in many cases, be a better approach than doing a complete rewrite in a different language.
@TCSyndicate
2 жыл бұрын
if it were as easy as u think, microsoft could clear 70% of their security errors with some simple tools and tricks.
@saturdaysequalsyouth
2 жыл бұрын
@@TCSyndicate It's not easy. But in many cases it is different than doing complete application rewrites, which would undoubtedly introduce new problems. My point is, if you're motivated to tackle this problem, you should be looking at it from different angles, not just jumping to an entirely new language straight away.
@TCSyndicate
2 жыл бұрын
@@saturdaysequalsyouth you've just got to be specific. Sure, rewriting a large application in a new language may introduce more problems than it solves, but "jumping to an entirely new language" may be fine for future applications. Restricting memory errors are definitely a vector that encourages the introduction ( and depending on the space, domination ) of new popular languages ( the most pop langs are gc'd ).
@saturdaysequalsyouth
2 жыл бұрын
@@TCSyndicate Yes, in the future there will be space for languages like Rust. For people who can't, or don't want to go that route, there are ways to reduce memory errors with exiting langauges like C. Static analysis, dynamic profilers, language extensions and hardware solutions like CHERI.
@TCSyndicate
2 жыл бұрын
@@saturdaysequalsyouth to be clear, the space already exists ( any app that wants speed & security guarantees ), the "future" part is continuing to make applications in that space.
@PeterSramka
2 жыл бұрын
It's great that you are excited about memory safety. You talked about it a lot in the video, but Java had memory safety back in 1995. That's 27 years ago! To me, one of the most interesting features of Rust is thread safety. This is the first time I ever heard of a language that guaranteed thread safety. IMHO, that's much more important (and more revolutionary) than memory safety.
@PeterSramka
2 жыл бұрын
@Igor Melo Both Java and Rust have a combination of compile-time and run-time memory safety. Nevertheless, some of the compile-time memory safety in Rust is very innovative.
@chadjones4255
Жыл бұрын
That's an interesting point.
@froge4300
Жыл бұрын
doesnt haskell have thread safety too
@huistelefoon5375
5 ай бұрын
Lisp (65+ years old): Am I a joke to you?
@zxuiji
2 жыл бұрын
I still prefer C, much easier to tell it to do what I want, even if what I want brakes things
@ColinMill1
Жыл бұрын
I started programming with City & Guilds mnemonic code (most won't even have heard about it I guess) so C is a fairly recent language as far as I'm concerned. I have seen so many "this will be the death of C" articles written about new languages I've lost count. My guess is that C will still be a major force, especially in the embedded world where it is still dominant, for a long time to come.
@YoelMonsalve
2 жыл бұрын
My personal opinion, is that if you have not programmed in C, you aren't still really a professional. Once you learn C, you can switch, and easily understand, any other more "powerful" language. But learn C first, to know the depths of programming.
@nikolacekov9099
2 жыл бұрын
Instead of learning C, could i learn C++ first to understand the depths of programming? Is C++ for a starter a bad choice?
@myxail0
2 жыл бұрын
@@nikolacekov9099 yes its too complex. I'd start with C, then you can move on to C++
@test40323
2 жыл бұрын
What about the speed? Most people use C on embedded devices instead of python for reason of speed and binary size.
@LowLevel-TV
2 жыл бұрын
I think there's a future where computer speed has outpaced the cost that a language like Rust incurs in overhead.
@test40323
2 жыл бұрын
@Bisweswar Bose , Amen to using C wrongly - I made every possible mistakes. But it is still my favourite language for its simplicity and elegance! Assembly can beat it but I haven't touched it since 32bit processors came out.
@samuelhammersberg5137
2 жыл бұрын
The speed compared to C is pretty much the same in most cases afaik.
@samuelhammersberg5137
2 жыл бұрын
@Bisweswar Bose While I can't deny the part about immaturity and the ecosystem not being as big as other languages, it is slowly becoming an industry staple, with a lot of major companies/groups investing in it as a C/C++ successor. Also calling an actually used language esoteric is flat out wrong.
@TCSyndicate
2 жыл бұрын
Rust has same speed as C. There's some binary size issues with default config that can be worked around for embedded.
@msthalamus2172
Жыл бұрын
One of the best things about Rust is the information the compiler gives you when the build fails. I taught myself Rust mostly just from the suggestions it offered and the occasional web search. Its syntax is superficially like C and Python had a baby, sure, but only on a line-by-line level. That breaks down quickly when you get into macros though.
@bobfarker4001
Жыл бұрын
C# was the baby of visual basic and c++ but came out looking like Java.
@MoeOuan666
2 жыл бұрын
I looked at it (from c, c++, python) from time to time, just grasping the concepts without doing more that 3-liner tests. I like it on some points (match, get rid of exceptions, interfaces/traits instead of inheritance, compiler messages, promise of zero cost resource safety) but the langage feels big, too big to get it whole in my head even as a core subset. I think it's because it's hard to have a small orthogonal subset of it where everything flow from core concept without more and more syntax details and add ons. Once you get pointers, C has this feeling, then act as core for C++. And python has it from the start, thesis to it's pseudo-code feeling (although a little bit less so since decorators). Maybe it's the lack of a real practical use, but Rust don't give me this nice compact orthogonal feeling...
@swapode
2 жыл бұрын
I completely get it. When I started with Rust it felt like this big thing with a lot of magic under the hood and a lot to learn. Now that I've used it for a while I think it's possibly the easiest language to really wrap your head around. While the learning curve is certainly steeper than other languages it's not anywhere near as long. There's actually no magic going on, just a very well thought out rule set that, once you got it, is rather simple.
@rtsa4633
Жыл бұрын
Honestly goes away one you get practical with it. Its like using pointers for the first time confuses a lot of people but it really isn't a complicated thing. Once you get past that curve, its way more fun.
@danfg7215
2 жыл бұрын
Why learn Rust instead of C#? Sorry if dumb question.
@dyslexicsteak897
2 жыл бұрын
You're writing Rust like you're literally translating C, in Rust's style you're not meant to place your curly braces on newlines or add return, all functions will implicitly return () unless you specificy something else. You also mimic C in just installing the compiler, so you're missing the massive featureset of cargo and crates.io which makes managing dependencies ridiculously easy and allows much easier interfacing with the compiler. Side note, your binaries will be big because they get compiled in debug mode by default, the release mode is much more optimised in terms of space and speed.
@DerSolinski
2 жыл бұрын
I think you miss a huge point of Rust, its toolchain. You completely side track that by only installing the compiler, but I think that is one important aspect of it since it was directly developed side by side. Memory management is also something that needs to be addressed, also some minor misconceptions sneaked in there. Up to the point that I think you should do an update/correction video once you are more familiar with it. (Read the book it is good)
@tolkienfan1972
2 жыл бұрын
You should list the misconceptions. It would be interesting to all of us with an interest in Rust
@DerSolinski
2 жыл бұрын
@@tolkienfan1972 Na nit-picking and he corrected most of them in his later videos. (Also I would need to rewatch to do that, and I'm lazy 😉) Still if you are interested in Rust read the official rust book. (Its free and online) It is compared to other "official Programming Books" a really good read. Nothing for complete newbies but anybody who is a bit adapt with any kind of programming should manage just fine.
@baileyharrison1030
2 жыл бұрын
Toolchains are not the same as a programming language. Just as a compiler isn’t the same as a programming language. I can use any rust compiler or build system that I want.
@DerSolinski
2 жыл бұрын
@@baileyharrison1030 course you can, but then you are missing completely the point of rust being an ecosystem not just a language, much like your comment.
2 жыл бұрын
The shortest tutorial in the world going from hello world to unsafe code, plus misnaming the concepts means it's a guaranteed misunderstanding for anyone who'd like a taste of rust.
@danbuffington75
2 жыл бұрын
C is 50 years old. But our numbering system is much older than that. Must mean we should invent a new way to count.
@louiscloete3307
2 жыл бұрын
Our numbering system doesn't make it easy to make counting mistakes though. This is a disingenuous statement, probably meaning something different than you intended. One liners are rarely good if they are on a controversial topic...
@OppaMack
2 жыл бұрын
Great point, they feel so special they want a EASY LANGUAGE BACAUSE I AM A BABYYYY
@louiscloete3307
2 жыл бұрын
@@OppaMack Not sure if you're saying Rust programmers are babies or C programmers are babies, but neither option is true. C is a great historical achievement, but I'd rather not have a situation where programmers have to be perfect to avoid serious security vulnerabilities. No human makes no mistake ever. We should look for tools and languages which are better taking our fallibility into account.
@OppaMack
2 жыл бұрын
@@louiscloete3307 Rust programmers are babies.
@louiscloete3307
2 жыл бұрын
@@OppaMack Ok so that's not true. You're obviously trolling or feel the need to prove your superiority somehow. Consider this the last time I'll respond. This can't be constructive. Enjoy C, but don't look down on other people with disdain based on a lack of knowledge as you're doing here.
@pjf7044
Жыл бұрын
I was really intimidated by rust coming in. It was between rust and go for me. Not sure what it is but the rust syntax and logic just makes more sense to me and is closer to what I would come up with if I had to write my own language. Excited to learn more
@thatonesnowboarde
Жыл бұрын
Learning rust has been a side project, but golang has been my main focus lately due to the speed of development and less learning curve coming from other languages. I hope to see your channel include other languages such as Go...
@alvarohigino
2 жыл бұрын
So what? 50 yo and still rocks.
@matthiasdebernardini3388
2 жыл бұрын
rust is amazing, so far only downside is limited packages (but that is changing) and that it doesn't run on exotic hardware (C always can, in fact if you can't get C to run on the device its considered non-functional)
@MDarkus3
2 жыл бұрын
Replacing C just because its 50 years old does not make any sense. Plus, C is very straight forward compare to Rust. Beginers make mistakes ,yes but mastering the language is part of the learning curve. You dont fix bad programming with a new language. We should instead raise the bar and awarness of critical case that could lead to problem with C, just my opinion
@LowLevel-TV
2 жыл бұрын
I totally get what you're saying.
@FADHsquared
2 жыл бұрын
C is not straightforward. If it was, we wouldn't have segfaults.
@TCSyndicate
2 жыл бұрын
Intermediate-Master C programmers make tons of memory errors when writing thousands of lines of code that interface with complex systems. Statistics done by these companies show the number of errors continues to go up, and 70% are memory errors. This is precisely why Microsoft tried to make their own memory safe lang ( project Verona ) before eventually investing a million with other companies in the Rust foundation. You say we don't fix bad programming ( memory errors ) with a new language, but we did that successfully tons of time. That's what garbage collected languages are, and they're the most popular language. Rust serves the same function as a gc'd language ( gets rid of memory errors ) except u lose no runtime speed for it ( u lose learning and compiling speed ).
@simonfarre4907
2 жыл бұрын
@@TCSyndicate exactly. It's every freshman in the world who reiterates what OP said. Real experts, with decades longer experience, all say the same thing. For instance there is a reason C++ became so successful, its interop with C and its so much stronger type system. The same goes for Rust. Writing good C and writing correct C are two different things. Being correct at all times is so, so, so much more difficult than writing "good code."
@taragnor
2 жыл бұрын
@@TCSyndicate Yeah, it baffles me how so many C diehards have this idea that they're so perfect they can't make mistakes, and therefore don't need any help from the compiler.
@C_J_365
2 жыл бұрын
I started learning Rust a little while ago and I love it so far. I'm looking forward to this series!
@qm3ster
2 жыл бұрын
Is there a particular reason you chose to install rustc from the package manager and not rustup? Also please use the standard formatting as per rustfmt 🙏🏻
@azhagurajaallinall126
2 жыл бұрын
Your last name spells like yahoo while you put google icon as dp,that's a good one bro 😅✌ June 19 2022 4:11 pm ist
@torarinvik4920
Жыл бұрын
I love these humble "Im learning ..." videos. Just reminds us we are all students but never masters :) Openness is the key!
@random6033
2 жыл бұрын
0:32 the most widely used operating system is ITRON
@TMS5100
2 жыл бұрын
Interesting to know that rust was bootstrapped using OCaml.
@Dygear
2 жыл бұрын
I love that you're heading in the rust direction. Can't wait to learn along with you.
@fatfurry
2 жыл бұрын
among us
@wertigon
Жыл бұрын
While C is old, the memory model and simplicity of C makes it extremely powerful still. It's awesome that you can do things like allocate 8 bytes of memory as a string and then treat that string as a 64 bit integer for fast comparisons. Mindblowing stuff on how to speed up string comparisons, for instance. :)
@glennmiller394
2 жыл бұрын
I've spent the last month learning Rust. I've been programming C since 1987 and C++ since it first hit the scene. I find it to be delightful, controllable, and predictable. The learning curve isn't that steep coming from C/C++.
@georgeousthegorgeous
2 жыл бұрын
I wasnt even alive at 1987, lol
@VndNvwYvvSvv
Жыл бұрын
Delightful? 🤮 🏳️🌈
@freedom_aint_free
2 жыл бұрын
The wheel is thousands of years old, so...
@robertmoore119
2 жыл бұрын
I just saw some information somewhere about C/C++ being replaced by Rust. I am very new to programming, I have not mastered any language so far, but I have some understanding of basic high level languages. I may possibly learn C/C++ at some point, and the reason for my intrigue is the level of granularity. Which seems to be the main issue with the language. I can understand the benefit of Rust creating what appears to be rules that prevent memory issues. My critique of your explanation, C or C++ is probably tedious to write, and you mentioned most operating systems rely on C/C++ in one way or another. Linux being entirely written in C. You then opened the rust compiler using Linux. You then downloaded the Rust Runtime environment that is written in Linux. What appears to be evident to me, is that someone took the time to provide a safe method of memory allocation and control written in C. I'm not trying to start some kind of serious debate about the languages, and I'm sure rust is a decent language to write in, but I thought that was kind of funny.
@zactron1997
Жыл бұрын
In C/++ you can basically write anything (they're both Turing complete after all). And yes, the Linux kernel running your Rust binary is written in C/++, so it's possible it has memory issues. The reason Rust can claim the safety badge where C/++ cannot is that the subset of memory operations allowed in Rust has been mathematically proven to be safe at a compiler level. In C/++, it's the developer's job to write that proof. The problem is that no normal developer ever will write that proof, so they rely on gut instinct, experience, and testing to determine what is/isn't safe. Rust let's a normal developer tap into the performance and safety of an experienced developer called "Mr Compiler"
@cryptobitez6090
2 жыл бұрын
Alot of C people on the comments who don't want to learn something new lol.
@kyrylmelekhin2667
2 жыл бұрын
Because usually the new stuff is crap, or long forgotten old ideas taking a surface. Generally software gets worse with time, rust is only accelerating that trend. Well educated people know this, so they would not waste their time on yet another piece of crap.
@fotnite_
Жыл бұрын
Very important that they still let you do "unsafe" blocks. Rust is a pretty opinionated language after all, but rather than making its opinions required, it just makes them the default. Not only does it mean you can get up to the same bit magic hijinks that you can in C when the time calls for it, but it makes it much easier to debug down the line because you can easily search for all of the "unsafe" blocks in your code first. Rust has guardrails, but they neither compromise performance nor are mandatory.
@annguyenhoangphu451
2 жыл бұрын
Thank you for your video. I'm learning Rust. Hope to see more video about Rust from you.
@LowLevel-TV
2 жыл бұрын
More to come!
@rarebrockstark6219
Жыл бұрын
Ya, im takeing C# (most likely) and HTML5 (only if another class is full) next year in high school
@AlessioSangalli
2 жыл бұрын
Wow nice video. I put some time to learn Rust last summer but didn't love it. Recently a friend told me again about it and I promised I'd have a look at it again. Then your video pops up 🤣
@AlessioSangalli
2 жыл бұрын
What I'm in a little disagreement is the "unfortunately" you used when saying modern OSes are written in C. Also, I believe we should mention Rust and C produce assembly that is very different and there is a tradeoff between safety and performance. 👍
@wumwum42
2 жыл бұрын
You really shouldn't install rustc from the repos and compile it directly like its done with C. You should install rustup instead (From the repos if possible or website otherwise) and use cargo. Cargo manages projects, which allow you to easily add third party libraries (all of them open source) and lets you compile you package way easier. Important commands: cargo new NAME: create projekt cargo run : compile (Unoptimised) and run cargo build: compile (Unoptimised) file is in target/debug/NAME cargo build/run --release: Compile optimised (and run)
@mastershooter64
2 жыл бұрын
virgins: rust OR c/c++ chads: rust AND c/c++
@CyReVolt
2 жыл бұрын
Write in C, write in C, write in C, write in C... malloc, free and segfault - write in C!
@matthewrease2376
2 жыл бұрын
Just learn assembly like a Chad.
@DaDa-gr7cy
2 жыл бұрын
This is actually a very interesting series. Looking forward for the next episode. Keep it up!
@EmbeddedSorcery
2 жыл бұрын
I help maintain an embedded C++ kernel, and would love to eventually get to the point where I can rewrite it in rust (meaning similar design and api), so I look forward to seeing your "from scratch" videos. I've been digging into the Rust Embedonomicon, but definitely need some more experience with Rust first.
@yahyaj4845
Жыл бұрын
If you're here to start learning Rust, just read the official book. Somehow even in a hello world program in this video, a couple of conventions have been broken. Opening curly bracket should be on same line as function name and the return is unnecessary.
@yahyaj4845
Жыл бұрын
@@BobAg_ That's why I said convention not rule...
@suhaskv
2 жыл бұрын
Feels good seeing you cover Rust! Looking forward to more Rust videos, good job!
@LowLevel-TV
2 жыл бұрын
Glad you enjoyed!
@joelmontesdeoca6572
2 жыл бұрын
You should redo this video to show how to install rust correctly to avoid frustrating new users, also the binary size bit is not the whole story.
@LowLevel-TV
2 жыл бұрын
Check the next video ;)
@snipzmattio5887
2 жыл бұрын
C has its flaws but I still prefer it to rust
@_Ello
Жыл бұрын
“And that was a big mistake, it was my mistake and I’m very sorry”
@jakemandoshkin7065
2 жыл бұрын
So, if my program is memory safe and low level efficient then I don't need Rust.
@louiscloete3307
2 жыл бұрын
If you can be sure you'll never make a mistake which introduces a memory bug in the future and leak all your users' data or clobber important sensor readings ever, yes. If no, Rust should be something you watch and consider for new projects at some stage.
@-..-_-..-
2 жыл бұрын
yes just stick with hello world and you'll be fine
@msthalamus2172
Жыл бұрын
I really like Rust. I could have done without its pedantry around naming conventions, but I learned to live with it. Its learning curve was admittedly steep, even with my level of experience, but then again I was deliberately trying to make it do something it wasn't designed to do at the same time I was learning the language from scratch. I'm the kind of dev who has to learn by doing. Following tutorials just puts me to sleep.
@nabilalhusail4731
2 жыл бұрын
Rust is the future of iron, as Being an old man is the future of a young boy
@1290Zack
2 жыл бұрын
Why do you think it's unfortunate that C is still a major part of operating systems?
@Raleighthrbub123
2 жыл бұрын
According to microsoft, the memory unsafety of C is the result of at least 71% of security vulnerabilities. That's pretty unfortunate. If some of the best programmers in the world can't keep from making mistakes then no one can.
@lucass8119
2 жыл бұрын
@@Raleighthrbub123 This point is largely not applicable to operating systems programming. The Operating System MUST perform unsafe memory access, as it is the one who manages memory. It must literally implement its own malloc() to allocate memory, along with the paging system and virtual memory translation. In addition, it interfaces DIRECTLY with hardware, so it must perform unsafe memory accesses, often using constant shifts and addresses. Operating System programming would be unsafe even if done in Rust or C++, although you might get better markup (i.e. unsafe{}) in your code.
@deadbugengineering3330
2 жыл бұрын
A tutorial about debugging stm32s with probe-rs instead of GDB would be sweet as I couldn't find a good learning resource for embedded-rust-newbs for this. Anyways, keep up the good work!
@rpxdytx
2 жыл бұрын
1:30 isn't installing rustup better?
@Dygear
2 жыл бұрын
Yes -- Ideally always install rustup so you get Cargo as well.
@googleisbad
Жыл бұрын
I thought rust was sponsored by mozilla not written by them
@10gamer64
2 жыл бұрын
I doubt Rust would replace C anytime soon, just as COBOL or FORTRAN, there is simply too much to reprogram.
@42war_pig31
2 жыл бұрын
True. But that doesn't mean that we can't write new programs in Rust which might otherwise would've been written in C++ or C. For example, Linux kernel, where C++ does not even exist, will have Rust as its second language.
@jordanlapointe4690
Жыл бұрын
Really cool. Looking forward to more videos on this!
@victormikecharlie1596
2 жыл бұрын
I don't think so. C is right now the universal language for embedded systems because it's very simple, fast and it have a small footprint
@louiscloete3307
2 жыл бұрын
It's fast, but Rust can be as fast. Rust with #[no_std] (not linking standard library) is about as small too. C is faster and smaller only when there's not enough runtime checks to make the code actually robust IME.
@KookoCraft
2 жыл бұрын
@@louiscloete3307 "just as good" complete bullshit. dont post stuff like this
@KookoCraft
2 жыл бұрын
@Jamie Walkerdine entirely false! and spoken like a true windows user!
@yac7571
2 жыл бұрын
using unsafe safely. I'm intrigued
@meercat1880
2 жыл бұрын
i found this while trying to find a C course
@JonBaldie
2 жыл бұрын
You seem to argue that C’s age alone is a bad thing. I think that’s a weak foundation for an argument. Rust is great. But is it better for a application in production to rely on a language that has stood the test of time or shiny new one with a short history?
@BosonCollider
2 жыл бұрын
For a very wide range of applications, I would definitely trust a Rust codebase over a C codebase at this point. Plenty of things that used to be done in C are now done in other languages, and Rust while not the end of C is yet another option that eliminates more of the niches where C used to make sense, though it has more overlap with C++ usecases than with C's usecases.
@deusexaethera
Жыл бұрын
Why in god's name would they keep the semicolons at the ends of lines? Carriage returns work just as well and you can't possibly forget them. It's better to have a line-wrap character for the rare times that you want to have a line of code wrap to the next line of text, rather than requiring every single line to be explicitly ended with a specific character.
@tarquin1111
2 жыл бұрын
Programming languages don't have an expiry date. If it compiles down into good efficient machine code then it's a viable language. Some developers seem to change language every 2 weeks. They should spend more time learning to program well instead of engaging in an eternal search for a language that will do the work for them. Rant over. Have a lovely weekend everybody.
@louiscloete3307
2 жыл бұрын
The issue with C isn't if it's compiling to efficient code. The very real issue is that C can very easily let memory bugs slip in unnoticed, and for the latter 25 years of its life, that has caused multiple billions of dollars in damages due to somebody exploiting some bug to hack some system connected to the internet. That's the issue with C and C++. And that's the issue Rust tries to solve. Learning to program well won't solve the issue. Humans aren't perfect. It takes one slip-up to make your code vulnerable. If the language can be formally proven to not allow bugs that can make your code vulnerable it's objectively better.
@tarquin1111
2 жыл бұрын
@@louiscloete3307 Good point Louis but by that logic we should scrap developers altogether because AI can already generate systems with smaller margins of error tgan humans. Introducing more and more languages to reduce human error is just prolonging the inevitable take over of the human race by our robot overlords.
@tarquin1111
2 жыл бұрын
*than How ironic
@louiscloete3307
2 жыл бұрын
@@tarquin1111 No, because machine generated code is still worse than human code. Maybe with less microscopic level mistakes, but still with no idea of the overall top level structure and idea of the code.
@tarquin1111
2 жыл бұрын
@@louiscloete3307 I think we'll have to agree to disagree on this one. Nice chatting with you though.
@codigodesenior3995
2 жыл бұрын
4:09 ... good this works it literally the best phrase you can hear when executing a code
@kyleeames8229
2 жыл бұрын
Ok, since we're talking about a programming language, it only makes sense that the candles on the birthday cake at 0:40 binary encode the age of C with lit candles representing 1.
@DMPLAYER1000
Жыл бұрын
Hopefully google c can bring it up to speed. I love working on c++ despite its flaws
@VndNvwYvvSvv
Жыл бұрын
What flaws? The only flaw is your own mistake.
@wassimulator
2 жыл бұрын
So basically instead of learning how to correctly work with memory we want knee pads
@dynfoxx
2 жыл бұрын
No, instead of unknowingly breaking memory rules rust warns you at compile time. It tells you what you are doing wrong and why with the option to use unsafe if you truly need it.
@werren894
2 жыл бұрын
rust would never replace C probably C++ but not C, it's like saying C would replace ASM, but assembly is still like art for a hobbyist, climate issue, government and military stuff, scientific stuff, or security design to make it not writeable, no internet connection, supersmall, etc. and C is never intended for application programming so expecting it to bug. unsafe is a feature of assembly macro language but depends on the programmers tho.
@andrewbeef8758
Жыл бұрын
sir , i beg you to make a full series on RUST please
@kevinyonan9666
2 жыл бұрын
GCC has a builtin static analyzer, in active development, for C. So why switch to Rust when I can continue using C with using analysis tools to have safe code?
@parallel4344
2 жыл бұрын
Metaprogramming alone should be a reason.
@kevinyonan9666
2 жыл бұрын
@@parallel4344 if C gets type annotations, void pointers could work as good as templates
@kevinyonan9666
2 жыл бұрын
@UCU3SuQ4YhUIdqg2CyTtcXQw ehhh don't get me wrong, they're convenient but they're also a crutch if you think about it. C++ also has metaprogramming but look at the insanity of its standard library because of it. Rust & C++ have to use metaprogramming because of their own constraints to achieve the same thing C can achieve in a "dangerous" way. Realistically, perhaps C will have a sane and more simplified way of doing metaprogramming in the future but gotta wait for a maintainable implementation. For the moment, metaprogramming in C and Golang is simply generating code to be compiled later on.
@parallel4344
2 жыл бұрын
@@kevinyonan9666 It's not about restraints, it's about doing work at compile time and in an abstracted way. Rust does it especially well, you can implement meta languages for compiler grammar rules as an example! It also has compiletime filesystem inclusion, etc. Trust me, I know how much of a mess the STL is - I myself am a Microsoft STL contributor, but Rust does it much better with a model which is older than C!
@kevinyonan9666
2 жыл бұрын
@@parallel4344 Microsoft? That explains everything. Windows has the shittiest C support out of the major OSs. MSVC is still missing alot of C99 and C17 features. Yea GCC and Clang aren't 100% C99 compliant but they support alot more of it compared to MSVC. Ofc instead of finishing the job, Microsoft opts to yet again switch to another language with this time being Rust, because apparently the C++, C# hybridization didn't work out too well... Here's a good question, C also has the potential to have metaprogramming (outside the preprocessor) but the thing with C and what makes it special is that whenever you come across a problem, the solution is typically writing more C as opposed to "we need a new feature" I've been writing C for 7 years, so far all I'd like for C is the defer statement from Golang, function literals so that I don't need to always define a static function, and type annotation so that compilers can have the potential to optimize void pointers as good as type parameterized generics.
@epolpier
2 жыл бұрын
Instead of saying Rust can substitute C you should just basically do it eg. start writing kernel drivers in Rust and contribute. I don't see that happening so I am really wondering why...
@louiscloete3307
2 жыл бұрын
You're not looking then. There's Redox-os, an implementation of a desktop OS in Rust. Linux has allowed Rust as the second language to write drivers in. Etc...
@epolpier
2 жыл бұрын
@@louiscloete3307 I know all that but where are those real drivers written in Rust ? I know there is a kernel crate, I've seen some examples but I've never seen any serious driver or even heard anyone using one.
@aqua3418
2 жыл бұрын
@@epolpier Rust in the kernel is still a new edition, but if you're looking for more "profitable and successful proof", Discord and other companies are already using Rust in their production services right now. (In Discord's case, it replaced Go). Also, Microsoft, Huawei, Google, Amazon, Facebook, Mozilla (obviously) are on Rust's board of directors. Amazon is also using Rust in their backend and even hiring experienced devs that know Rust. Windows started replacing some of their components with Rust. Google has some of its next gen OS being written in Rust.
@alireda640
2 жыл бұрын
Linux will have drivers in rust, on version 6.0
@xfcisco
2 жыл бұрын
if you strip the rust binary it gets down to kilobytes
@rpxdytx
2 жыл бұрын
2:15 The brace in a newline is kind of considered useless by the rustaceans, and since i am coding in rust for some time, i feel agony seeing the curly brace in a newline
@louiscloete3307
2 жыл бұрын
That's not the (very opinionated) default rustfmt style, so yes, I'd +1 you with this comment. Stick to the community's agreed-upon style and write your opening brace at the end of the control flow expression or function header.
@louiscloete3307
Жыл бұрын
@@BobAg_ I find that I get up to speed with code quicker if all code in the language looks the same. If you're clever/whatever enough to not be bothered by that, good for you. It does help some people though, so I restrict myself to a specific style for the sake of those people (including myself) whenever there is a de facto standard.
@donaldmickunas8552
2 жыл бұрын
Rust is yet another new shiny thing. Techies love new shiny tech. It is exciting. It has possibilities. It is something new to explore. It is like Christmas morning. Yet, most of the new, shiny tech of just a few years ago has been replaced by yet another new and shiny thing. Rust has yet to stand the test of time. I’ll sit back and watch rather than run after every new and shiny thing. New is not necessarily better. Enjoy playing with your new toy. Have fun!
@atlantic_love
2 жыл бұрын
Totally agree! I'm trying to learn C++ using Stroustrup's latest book, and am frustrated by some things: #1 not able to find ANY reasonable explanation on line as to why I MUST learn pointers and passing by reference, especially in OOP, and #2 I wanted to make 2D games and can't seem to find a gui library anywhere that's easy to install and set up on Windows 10 to work with Visual Studio 2022 Community Edition. So I'm tempted to run for the hills, an area known as "come over here and try THIS shiny, new toy where you MIGHT stay for awhile until something ELSE gets in your way" :D
@rashidz97100
2 жыл бұрын
Just the video I wanted to see today! 😊
@LowLevel-TV
2 жыл бұрын
Perfect!
@ElPikacupacabra
2 жыл бұрын
What C programmers don't need: Another complex language that forces you to adopt abstractions, instead of not getting in your way when you try to code close to the metal. Personally, I find it tiresome every time I have to write half a screen of code to parse a &[u8] from stdin.
@donjindra
2 жыл бұрын
Exactly. Rust just gets in the way.
@Raleighthrbub123
2 жыл бұрын
It's 2 units of coding and 1 unit of debugging vs 1 unit of coding and 4 units of debugging. Dunno what you're doing wrong, but despite programming in C for far longer than I've used Rust, I can code more things far faster in Rust than I could ever hope to in C just because of the reduced debugging time.
@donjindra
2 жыл бұрын
@@Raleighthrbub123 I don't know what you're doing wrong but debugging C is easy for me.
@Raleighthrbub123
2 жыл бұрын
@@donjindra Dunno then. What do you use for parallel debugging ?
@donjindra
2 жыл бұрын
@@Raleighthrbub123 I usually setup some way of logging events in real time. It depends on the project. I rarely use an actual debugger.
@CProgrammingLanguageCodes
Жыл бұрын
After 50 years, the C language is still viable and with some augmentations (see @C - augmented version of C programming language) it can also celebrate the centenary.
@davymachinegun5130
2 жыл бұрын
"Thing old therefore bad" "in 2022" "My favorite thing being popular isn't enough, it has to replace everything" Hit every mark of brain-dead, update crazed, consumer speak.
@Manny73211
2 жыл бұрын
in unsafe mode, can you divide by zero to crash the code?
@digama0
2 жыл бұрын
You can divide by zero in safe code. It will cause a panic (roughly similar to C++ exceptions except it is conventionally used for unrecoverable errors), which is classified as "safe" so the unsafe keyword is not needed. (Unsafe division by zero would be relying on the processor's behavior which would cause a SIGFPE or something.) Alternatively, you can use x.checked_div(y) and handle the error case yourself.
@jumeldipancaputra87
2 жыл бұрын
I'm on the way learning Rust. But I still work with C/C++
@keastie6671
2 жыл бұрын
This is absolute heracy. Good video though
@LowLevel-TV
2 жыл бұрын
Teehee, thank you!
@HelicopterRidesForCommunists
2 жыл бұрын
Use that “unsafe safely”
@rpxdytx
2 жыл бұрын
7:40 classes don't exist in rust, just like inheritance is not a thing in rust
@mawu4511
2 жыл бұрын
Let me interject for a minute : 1) Linux is not an operating system, it's a kernel 2) What you are referring to as Linux is in fact GNU/Linux Subscribed.
@mawu4511
2 жыл бұрын
@@dansanger5340 😂😂😭
@Ishaan_Garud
8 ай бұрын
I once wrote 6 lines of code in C++ It had errors on 10 lines
@TheBrainDunne
2 жыл бұрын
What about zig?
@exobodyfoundation4472
2 жыл бұрын
There are a lot of c programmers that think "oh I know how to be memory safe! let's all keep using c forever!" but there's a lot of programmers that aren't as skilled and, unlike you, tend to be imperfect. These programmers will never learn memory safety and they will still contribute to open source libraries and several softwares across the board. Inevitably, you will rely on software that somebody else builds. Memory safety by default ensures this lower common denominator of programmers that compose the vast majority of programmers are going to write code that will be memory safe at least. rust is a paradigm shift that fundamentally agrees with the older c programmers that understand memory safety. rust defaults acknowledge that memory unsafety is a skill that you have to learn. please consider learning and supporting Rust, despite C being your preference.
@taragnor
2 жыл бұрын
Honestly I find it hard to believe that even veteran C programmers don't run into memory bugs. At some point you're going to forget to free the memory or run into double free problems.
@toddmartin7629
2 жыл бұрын
@@taragnor Which a lot of this can be avoided when using address sanitizers, but they get no love or attention. Not saying that they can fix all the problems, but most of the memory issues in C programs can be solved today using address sanitizers built into most compilers.
@KookoCraft
2 жыл бұрын
lot of words to say that you have a skill issue lol
@exobodyfoundation4472
2 жыл бұрын
@@KookoCraft I do not understand what you are referring to
@aqua3418
2 жыл бұрын
Even with the best and brightest programmers at Microsoft, 70% of the discovered vulnerabilities are memory safety bugs (Microsoft released this statistic themselves). Sure, they may get it right a lot of the time, but no one's perfect, and it will happen (we're all human). So, that just goes to show that no matter how "skilled" you are, Rust brings value to all. It also reduces the code base you have to look through for memory safety bugs (you only need to be looking at your unsafe interfaces). Rust is for all
@saricubra2867
2 жыл бұрын
Imagine dropping C/C++ and using Assembly in 2022 and beyond.
@ducodarling
2 жыл бұрын
I really feel like this is the wrong direction for computers to take. So much cruft, so little optimization. We're supposed to be encapsulating low level components and perfecting them. We have to ask ourselves: what is the purpose of a program? To be written, or to be run?
@jon00200
2 жыл бұрын
Totally agree
@saumyacow4435
Жыл бұрын
Whip me! Beat me! Force me to use C++!
@XeonProductions
7 ай бұрын
I really hate Rust, for the simple fact that it's not fun to program in and so far removed from other languages. I have to rethink how I code everything, which if you have to swap between languages is not a good thing. It's the main reason I never picked up Clojure or Haskell. I really tried to like Rust and coded a bunch of coding challenges with it over several weeks, but was infuriated by the constant compiler errors and having to do things a special Rust way. I'll stick with C based languages.
Пікірлер: 929