Rust vs Go - Which is Better and Why?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] hello everyone as you may have already noticed from the intro this video is all about rust versus go in particular we are going to talk about the differences between the two languages as well as the specific areas in which each of them shines so without further ado let's get started with the video one of the main differences between rust and go is definitely simplicity in fact it is one of the most popular go selling points becoming productive in go usually takes a few hours or days whereas in rust it could take a few weeks that has a direct effect on collaborations because go programs being easy to read and easy to write are easy to manage in large teams also because it's more difficult to get your colleagues to learn a complex language like rust whereas with go in a few hours or days they start to become productive but that simplicity comes at a cost in particular go strives to have the simplest possible programs and therefore some very nice features that most modern languages have such as generics and functional programming are lacking in go to see how convenient those features can be i'm going to show you an example let's say you have a list of elements and you want to extract a sub-list of those elements that satisfy a given criteria which is a very common task in programming so in this example we have a list of integers and we want to extract a sub-list with the even elements in languages that enable functional programming you can use the filter function to solve this challenge in a single line of code by just supplying an anonymous function or lambda to the filter function on the other hand with go you are stuck with a good old for-loop which of course works but it's definitely not elegant so rasta is a very powerful language very flexible language but it has a steep learning curve so getting started with it can take a few weeks and not everybody is willing to make that effort another very big difference is memory management you surely know that go has a garbage collector in the same way java python or javascript do on the other hand rasta has a manual memory management system which is based on the concept of ownership and borrowing so in that case rust gives you a lot of flexibility and freedom making it possible to write very performant code but of course that comes at price following the peter parker principle with great power comes great responsibility so you'll definitely have to be careful when using rust even though the rust compiler is very good at catching memory bugs at compile time so another important topic is concurrency goa is great support for concurrency in fact core routines and channels are my favorite feature of language that said most of these features such as core routines and channels are available also in rust directly using the standard library or true third-party libraries such as tokyo what's more is that rust concurrency model is provably correct which means the compiler can catch a whole class of tread safety bugs at compile time before your program even runs which makes it pretty hard to do basic concurrency mistakes such as writing it to the same shared variable without any synchronization then we need to talk about the ecosystem so goaling simplicity combined with the fact that it's been around for more makes it more popular than rust at least by the time of this video which means that generally libraries and frameworks are more mature on go compared to rust especially those related to web development but i'm going to be more specific about this topic later another interesting difference is compilation time go compiler is much faster than the rust one and that's mostly due to the number of optimization and checks the rust compiler does which means that in large rust projects you can expect to wait for a while while compiling one thing they have in common though is deployment because both of them produce a static binary as an output which means that in order to run it you don't need an interpreter such as for python or a virtual machine just for java you just need to deploy this executable so when to use go go is very well suited to build services and simple applications it was built to replace java and c-sharp so if you want to build for example a web rest api then go can be a very good choice when to use rust well rasta is a system programming language so it's a very good fit if you need efficiency and performance moreover when you grasp the fundamentals working with ras becomes a very nice experience rust is very well suited for performance critical applications such as web browsers databases operating systems or for example libraries that do heavy mathematical computation in all those cases rust is a great fit on the other hand there is a more controversial topic which is web development and while at the moment there is a lot of movement in the rust community about web development the libraries are not yet as mature as the go counterparts then of course you need to think about the trade-offs rust is a very efficient and performant launch but in most web services the bottleneck is not in the cpu and the computation but instead is in the input output for example waiting for a database reply or a file read on disk in those cases having raster won't help much because writing ras programs is more complex and time consuming than writing go or python programs in most cases rust should not be used then of course there are exceptions let's imagine a service on the web that takes a real-time stream of data and do some sort of cpu intensive computation on that in those cases rust can be a very good choice but as always use the right tool for the job right so that was all for this video i really hope you liked it if you did please consider subscribing and liking the video because it really helps if you have any questions or comment please don't hesitate to write them below i hope to see you in the next video
Info
Channel: Federico Terzi
Views: 124,674
Rating: 4.8271918 out of 5
Keywords: rust, rustlang, go, golang, lang, programming, language, best, which, is, for, web, development, rest, api, trending, jobs, deployment, ecosystem, developers, developer, coding, coder, why, top, rated, ratings, memory, management, garbage, collector, concurrency, compilers
Id: ZJ6dVVobjaI
Channel Id: undefined
Length: 6min 28sec (388 seconds)
Published: Fri Sep 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.