Rust Programming for beginners: Unmatched power for building fast and secure apps
Название: Rust Programming for beginners: Unmatched power for building fast and secure apps
Автор: Claudia Alves
Издательство: mEm Inc.
Формат: pdf, azw3, epub
Размер: 10.1 MB
After reading this book, you’ll be ready to build Rust applications.
Why learn a new Programming Language?
As Einstein might have said, «As gentle as possible, but no gentler.». There is a lot of new stuff to learn here, and it’s different enough to require some rearrangement of your mental furniture. By ‘gentle’ I mean that the features are presented practically with examples; as we encounter difficulties, I hope to show how Rust solves these problems. It is important to understand the problems before the solutions make sense. To put it in flowery language, we are going for a hike in hilly country and I will point out some interesting rock formations on the way, with only a few geology lectures. There will be some uphill but the view will be inspiring; the community is unusually pleasant and happy to help. There is the Rust Users Forum and an active subreddit which is unusually well-moderated. The FAQ is a good resource if you have specific questions.
First, why learn a new programming language? It is an investment of time and energy and that needs some justification. Even if you do not immediately land a cool job using that language, it stretches the mental muscles and makes you a better programmer. That seems a poor kind of return-on-investment but if you’re not learning something genuinely new all the time then you will stagnate and be like the person who has ten years of experience in doing the same thing over and over.
Where Rust Shines:
Rust is a statically and strongly typed systems programming language. statically means that all types are known at compile-time, strongly means that these types are designed to make it harder to write incorrect programs. A successful compilation means you have a much better guarantee of correctness than with a cowboy language like C. systems means generating the best possible machine code with full control of memory use. So the uses are pretty hardcore: operating systems, device drivers and embedded systems that might not even have an operating system. However, it’s actually a very pleasant language to write normal application code in as well.
The big difference from C and C++ is that Rust is safe by default; all memory accesses are checked. It is not possible to corrupt memory by accident.
The unifying principles behind Rust are:
— strictly enforcing safe borrowing of data
— functions, methods and closures to operate on data
— tuples, structs and enums to aggregate data
— pattern matching to select and destructure data
— traits to define behaviour on data