The Rust Programming Language

  Рет қаралды 97,083

Google TechTalks

9 жыл бұрын

Google Tech Talk
June 6, 2015
(click "show more" for more information)
Presented by Alex Crichton
ABSTRACT
Rust is an exciting new programming language that combines fine-grained control over memory layout and allocation patterns with memory and thread safety. It reached 1.0 in May and is rapidly gaining acceptance in projects including Servo (Mozilla's next generation parallel layout engine), a block store being developed by Dropbox, and numerous startups. Its features include zero-cost abstractions, move semantics, guaranteed memory safety, threads without data races, trait-based generics, pattern matching, type inference, minimal runtime, and efficient C bindings. ‚Alex Crichton will present an introduction to the Rust programming language, explain how it can be used to build performant, reliable systems, and answer your questions.
Speaker Info:
Alex Crichton ‚About the speaker: Alex Crichton is a member of the Rust core team working at Mozilla Research. He focuses on the standard library, Cargo, crates.io, and Rust's tooling and infrastructure experience. He's been at Mozilla for almost two years and graduated from Carnegie Mellon in 2013 with a BS in both Computer Science and Electrical and Computer Engineering.

Пікірлер: 101
@nandoflorestan
@nandoflorestan 6 жыл бұрын
Summing up this lesson: The problem in memory management is - *aliasing* (2 references to the same variable), and - *mutation* ...happening at the same time. To solve that, in Rust a variable can be passed in 3 ways: 1. "var": *Ownership*. Ownership of var is immediately passed to the called function, and the caller cannot use var anymore, it is completely forgotten. Trying to use var in the caller results in "var has been moved" compiler error. 2. "&var": *Shared borrow*. The caller can send the variable to multiple consumers, but mutation is forbidden, the callee can only read var but not mutate it. (But mutation is allowed in certain controlled circumstances.) 3. "&mut var": *Mutable borrow*. The callee, alone, can mutate the variable. The variable is returned through the stack and the caller gets control over the variable again.
@Evan490BC
@Evan490BC 5 жыл бұрын
The problem with memory management is memory management itself! We are in 2019 and we _still_ play human compilers! Where are the "sufficiently clever compilers" we keep hearing about since the 1980s?
@moha6859
@moha6859 5 жыл бұрын
@@Evan490BC you should try writing one you will get a lot of money if you succeeded
@Evan490BC
@Evan490BC 5 жыл бұрын
@@moha6859 It's not my job to write compilers. My job is to use compilers to write other programs (and getting paid), and I'm quite successful at that, I assure you.
@moha6859
@moha6859 5 жыл бұрын
@@Evan490BC if you are not up to the task, you should stop b****ing about people who can't do it
@Evan490BC
@Evan490BC 5 жыл бұрын
@@moha6859 That's why it's called _specialisation_ you idiot! They are paid to write compilers with proper type inference and they haven't done it yet!
@kennethmarete5329
@kennethmarete5329 6 жыл бұрын
I have never listened to a great tutorial, precise, simple, articulate, summarized and fully descriptive as well as comprehensively detailed like this one. I have loved the programming language since then. Thanks for the awesome video.
@LooJulian
@LooJulian 9 жыл бұрын
Thanks very much for the great and neat presentation followed Alex Crichton.Your presentation is much appreciated.
@nadeems2320
@nadeems2320 7 жыл бұрын
Nice Talk He answered the questions very effectively
@ShaunPatterson
@ShaunPatterson 7 жыл бұрын
Seems like Ada covers some of the safety / control issues
@TheAmos1989
@TheAmos1989 8 жыл бұрын
Nice talk. Where can I find those slides?
@PedroPiquero
@PedroPiquero 9 жыл бұрын
Ok, it seems to be pretty cool. I will start to learn it.
@hagbardceline9866
@hagbardceline9866 9 жыл бұрын
Go Rust! :)
@walter0bz
@walter0bz 9 жыл бұрын
Hagbard Celine not 'Go' surely
@squiresuzuki
@squiresuzuki 8 жыл бұрын
+walter0bz Go should rust, and Rust should go!
@f0c1s
@f0c1s 7 жыл бұрын
Rust can Go Dart itself.
@knucklesamidge
@knucklesamidge 8 жыл бұрын
I understood some of this video
@user-co5uf3qn8p
@user-co5uf3qn8p 9 жыл бұрын
pretty nc speaker! thks!
@1waveOrg
@1waveOrg 6 жыл бұрын
16 mins in and it is soooooooo FAKKIN CLEAR to me that I was right; we have ZEROOO idea how to use pointers >.>
@zyansheep
@zyansheep 3 жыл бұрын
Data is represented with bytes. Memory contains bytes. Each byte in memory can be uniquely identified with a number. That number is what a pointer is. How is my explanation?
@jasondoe2596
@jasondoe2596 8 жыл бұрын
Rust is a very, very promising language, and, after some reading, it seems to me that it lacks any glaring deficiencies - unlike let's say Golang (with its horrible type system and non-extensible nature). There's certainly space for sane C++ replacements. Great presentation of Rust's distinguishing characteristic (ownership/borrowing), although I'd also love an overview of the object system and the very interesting functional features of the language.
@geordonworley5618
@geordonworley5618 8 жыл бұрын
+Jason “cyberspace entity” Doe Absolutely, I think the amazing thing is that it covers all bases perfectly and remains a systems programming language! I tried Golang and was disappointed with the GC, performance (without using gcc, and even then...), and the lack of generics, but Rust took generics to a whole new level, and we get the performance of C++ and the safety of a GC without the memory leaks (unless we explicitly create those). There are a small list of things we will eventually get but currently don't, such as generic args and numeric generics, but we can definitely get away with not having those for now. I really think Rust is the first sane replacement for C++, and it is so much better for maintaining projects that I think we will naturally start moving towards it over time.
@jasondoe2596
@jasondoe2596 8 жыл бұрын
Vadix Vadexi There's a huge amount of inertia when it comes to languages (programming or otherwise), but that's also my hope!
@xnoreq
@xnoreq 8 жыл бұрын
It's ugly as fuck and a lot of algorithms require more code with Rust. Also, binaries are huge (due to the static linking by default) and it's still slower than C. They really should have created a safe C dialect/extension instead of a completely new language.
@geordonworley5618
@geordonworley5618 8 жыл бұрын
John Doe It can often be faster than C, as most C programmers aren't taking advantage of copying the closure model by rewriting functions, and Rust takes full advantage of closures and other situations where things can be statically inferred and inlined at compile time. As for code size, I believe Rust is more compact than C++ when writing binaries, and far more compact than C. When writing libraries it is about on-par, but it has the high level features of some scripting languages with no cost, so it can have a lot of really compact code. I think Rust's model is necessary for proper compile-time safety. C couldn't have handled, for instance, the encapsulation of objects for the Sync trait, or many other high level features. Honestly though, I am biased. I hate having to go back to C or C++ whenever I am forced to. I don't see how one would not want the compile time safety or features Rust brings, while then also gaining all the issues C and C++ have.
@xnoreq
@xnoreq 8 жыл бұрын
vadix Well, you're wrong on pretty much everything you've said. The mere fact that a lot of the features in rust are implemented in C ... They could have just written a safe dialect/extension to C. Instead we got NIH syndrome.
@llothar68
@llothar68 7 жыл бұрын
I will give it a try in a new project. I will rewrite Lucene (the java, then c++ full text search engine) and add it to a special database for a new AI enabled webscrapper. I think this is a good project that can need lots of multithreading help and thats where i expect the most help from the code. Most important is that i can integrate it with C easily.
@f0c1s
@f0c1s 7 жыл бұрын
What are your hobbies man?
@smithaitufe6984
@smithaitufe6984 6 жыл бұрын
Lothar Scholz hi, how far have you gone with your project? I am interested.
@kiddkai
@kiddkai 7 жыл бұрын
best ownerdhip and borrowing explaination.
@MrPisster
@MrPisster 7 жыл бұрын
I have had an interest in programming for a while and I really like what I'm seeing here in terms of control and structure. My question is if RUST is a good first programing language for a beginner like myself to learn.
@TheMasterpikaReturn
@TheMasterpikaReturn 7 жыл бұрын
It might be good, cause it's "close to the machine" much in the way that C might be. BUT be careful. It's a really complex programming language. you have to be careful about pointer lifetimes for example. Even as an expert programming, in the start you basically fight against the compiler, that enforces safety above everything else. So i wouldn't say it's the best beginner language, but you could do it.
@MrPisster
@MrPisster 7 жыл бұрын
Thanks for the advice. What do you think might be a better one to learn programming concepts and practices with?
@TheMasterpikaReturn
@TheMasterpikaReturn 7 жыл бұрын
It depends on the field and the paradigm you want to learn. If you want to learn functional programming, I would suggest haskell. If you want to learn object oriented programming, I would suggest smalltalk. If you just want to learn the basics, and stay close to the metal, I would suggest learning a bit of C and/or assembly to understand how a computer works, before moving to a higher level language. If you want something easy that you can write things quickly in, I'd suggest python. While if you like the Web, you could go with javascript. There isn't a best first language, it just depends on what you want to do. On a side note, try learning about proper algorithm and data structures before diving in: the most important thing is knowing programming, not knowing a programming language.
@amosbatto3051
@amosbatto3051 7 жыл бұрын
I have been programming for 20 years (principally in PHP and JavaScript today, but I have used C and Python in the past) and Rust is the hardest language I have ever tried to learn. It uses high-level concepts like closures, generics and traits which are pretty tough to understand, plus it uses low-level concepts like pointers, dereferencing and distinguishing between the stack and the heap. Then it adds in ownership, borrowing and lifetimes, which are not found in any other language. The learning curve for Rust is pretty steep and the books that are available aren't designed for beginners. If you look at doc.rust-lang.org/book, you will see that it is a book designed for people who already know C/C++. It assumes that you already know pointers and dereferencing and dives into examples with little explanation. I recommend that you start with a much easier language. If you really want to understand low-level programming, start with Stephen Prata's C++ Primer Plus, which goes through all the basic concepts and make sure that you thoroughly understand them.
@airthang
@airthang 6 жыл бұрын
Python
@ejyjawa352
@ejyjawa352 3 жыл бұрын
C++ doesn't give you safety .....YOU provide it !
@abhinavadepu
@abhinavadepu 5 жыл бұрын
Can anyone say how can I join in such calls...
@RogerBarraud
@RogerBarraud 5 жыл бұрын
Get a j0rb at Google.
@panzeralienofficial
@panzeralienofficial 6 жыл бұрын
Great. Now i have to lean yet another language.. XD Looks great!
@binxu5553
@binxu5553 8 жыл бұрын
I like Rustlang~
@lin2jack2
@lin2jack2 6 жыл бұрын
Rust is design to be implement in machine code, and from what I gather Red runs on JIT or VM. Not saying which one is better, just that their purpose is slightly different.
@johnleimon8854
@johnleimon8854 7 жыл бұрын
Where is Ada?
@raymondhill7837
@raymondhill7837 7 жыл бұрын
In our hearts
@retropaganda8442
@retropaganda8442 6 жыл бұрын
Thank you for the video, which I probably watched in 4 minutes by pressing the right key every second. That's about the time I have.
@TremereTT
@TremereTT 6 жыл бұрын
Hm, isn't LLVM kind of "a runtime" ?
@Tony_Goat
@Tony_Goat 5 жыл бұрын
No, it's a compile time "virtual machine." It describes a fake computer with fake memory and CPU that can easily be translated out to any processor, whether it's x86, ARM, or other. You just have to describe (in the compiler) how to translate from the LLVM to the native architecture.
@jaywayserf
@jaywayserf 9 жыл бұрын
Inquiring minds want to know: is Rust fast ?
@TheStiepen
@TheStiepen 8 жыл бұрын
+Doruk Turak I heard that depending on the task rust is actually faster than c++
@ignacioduart6747
@ignacioduart6747 8 жыл бұрын
+Chi Hiro Well, unsafe Rust is as fast as C. Safe Rust is, most of the time, as fast as C. And in practice, Rust is as fast as C and safer, plus the amount of compile optimization that can be done (this is also important, the language itself is very young and a lot can be done on the compiler side probably to get even faster code), it means you get better maintainable code as fast as C. So yes, is fast enough, and as fast as you want to make it. Rust is more of a modern C than a modern C++ IMO (as it includes object orientation concepts but is basically procedural with some influence from functional programming and has a powerful trait and type system).
@disk0__
@disk0__ 7 жыл бұрын
Chi Hiro one might say Rust allows you to drive the C car very fast, usually very close to parity even, but not as fast as the normal C car in some situations where it has a tendency to explode very easily due to driver error
@Nightwind0
@Nightwind0 9 жыл бұрын
Thanks, Kermit!
@lewispeel
@lewispeel 8 жыл бұрын
+Danny Palm I looked for a comment like this!
@mrcoder2035
@mrcoder2035 7 жыл бұрын
Lets beat GoTeam, RustTeam :)
@SuperToughnut
@SuperToughnut 6 жыл бұрын
Looks a little like Scala, but easier to understand than Scala.
@leonid998
@leonid998 3 жыл бұрын
The language, and not another garbage collecting garbage collector!
@jaromanda
@jaromanda 7 жыл бұрын
This guy could do a good Christopher Walken impersonation
@callmecalvin7297
@callmecalvin7297 6 жыл бұрын
I thought this was for the game
@GegoXaren
@GegoXaren 9 жыл бұрын
"A GC requires a runtime" N..no... Look into Vala.
@anothercrappypianist
@anothercrappypianist 9 жыл бұрын
***** Doesn't Vala use reference counting? The docs suggest so. In which case this isn't what is meant here by GC (a la Java or Go's GC). And in any case Rust supports reference counting (Rc and Arc).
@blenderpanzi
@blenderpanzi 9 жыл бұрын
***** Vala uses ref counting. That suffers from memory leaks in the case of reference cycles and it still has runtime overhead. For some cases it might even have more overhead than other forms of GC, because you need to do work (atomically changing the reference count) even when you only pass references for reading (and not passing ownership). Also isn't Vala depending on glib? That's a runtime.
@dfozsp
@dfozsp 7 жыл бұрын
Js is very safe language? LOL. I will prefer C++ for safety rather than js
@harryrigg5815
@harryrigg5815 7 жыл бұрын
Javascript is very safe.... mainly because its very high level.
@HermanWillems
@HermanWillems 6 жыл бұрын
So it's not the mistake of Javascript but because the interpreter is written in some language that isn't safe. ;) A javascript interpreter written in Rust will be very safe, which automatically makes Javascript safe.
@Evan490BC
@Evan490BC 5 жыл бұрын
@@rohan_devarc Are you talking about Javascript-the-language or Javascript's *implementation* ?
@AndiRadyKurniawan
@AndiRadyKurniawan 8 жыл бұрын
The hardest language to learn.
@llothar68
@llothar68 8 жыл бұрын
+Andi Rady Kurniawan Just look at C++ templates. If you can't write a professional "std::pair" you know what i mean.
@ignacioduart6747
@ignacioduart6747 8 жыл бұрын
+FichDichInDemArsch Fortunately I think that the compiler (which can be a bitch, but the right type of bitch, if you know what i mean) helps you learning. This and having some of the online resources open in a browser. Is a matter of getting comfortable with the concepts, I don't think lifetimes (which you implicitly have to learn about anyway in languages like C or C++) and ownerships are more difficult to learn than other concepts (like closures, recursion, etc.).
@122mlb
@122mlb 9 жыл бұрын
MAN! Why so many windows at the bottom? So damn distracting! Get rid of this shit
@jorge28624
@jorge28624 9 жыл бұрын
Marcelo Lima So, you are new to Google Hangouts?
@122mlb
@122mlb 9 жыл бұрын
That android app that allows malicious remote code execution via SMS? I've heard of
@GegoXaren
@GegoXaren 9 жыл бұрын
Too bad Rust has too many C++ ugliness like "::".
@Nightwind0
@Nightwind0 9 жыл бұрын
***** I find "::" pretty.
@GegoXaren
@GegoXaren 9 жыл бұрын
***** I find it ugly as hell out of a typographical point of view.
@GegoXaren
@GegoXaren 8 жыл бұрын
FichDichInDemArsch Look for the video named "[2016-01-30] Bashing Rust Lang [Insane Rant]"
@codingwithsprite235
@codingwithsprite235 8 жыл бұрын
C++ is beautiful
@lin2jack2
@lin2jack2 6 жыл бұрын
Beauty is in the eye of the beholder
@bigmofo1122
@bigmofo1122 7 жыл бұрын
Rust is load of crap. It doesn't solve anything. We will still be writing everything in C 50 years from now.