What is Rust?
Rust is a programming language that focuses on three essential things: safety, speed, and concurrency. This language was sponsored by Mozilla research, and started in 2006 by a Mozilla employee named Graydon Hoare.
Rust uses LLVM, a library that is used to construct, optimize and produce intermediate and/or machine code on its back end. Rust first appears in 2010.
Syntactically Rust is very similar to C++ with blocks of code like using if, else while and for. I should also mention that instead of using switch like in C, programmer uses match keyword.
Advantages of using Rust
Rust prevents segmentation faults and guarantees thread safety. Additionally, Rust gives programmer memory safety without needing a garbage collector. Instead of using it, Rust uses borrow checker to ensure checking pointers and verify them at compile time. In other word, the error message that pops out when using C by the garbage collector will not shows up in Rust, the program will simply compile. This will prevent dangling pointers and other forms of undefined behavior.
When I say dangling pointers, I mean pointers that do not point on at a valid object of the appropriate type. This type of pointers shows up when deleting an object (using destructor); in this case the object will be deleted without changing the value of the pointer that points on it. In this case (in C++) the pointer will still point on the location where the object was (deallocated memory).
Undefined behavior example: indexing an array out of bound, a value other than 0, 1, true, false in bool, etc.
In addition, Rust will guarantee concurrent code is free of data races catching any misuse of mutexes or other synchronization primitives at compile time.
Disadvantages of using Rust
Compared to C language, Rust often produces larger binaries and less efficient code. Furthermore, rust doesn't have a standard way to access database (as JDBC for java), so reusing project created for MySQL with sqlite isn't an easy task. stdlib is really minimal in Rust, two different rust applications will vary more then lets say two java applications. To end with, Rust is leaky; Rust's scope-based memory management makes recursion leak memory.
Conclusion
Each language has its pros and cons. Rust is developing so fast, especially that it's a modern language so writing all the headers file that you find inside other language is almost impossible. Below a video about how rust developed from 2010 till 2015.
No comments:
Post a Comment