Categories
Rust

Rust rules for complex projects.

I had the luck to try Rust because when I started developing FakeSFTP I needed a language which could provide me with type safety and speed to made my own implementation of a sftp server thought to interact with Nextcloud.

I really got pleased by the way Rust helped me to resolve my problem giving me what I asked and many more.

The struct syntax when making a class means if you need a struct on a moment you have that, but if this struct grows to need methods to treat with the structure you have not to rewrite so much the approach.

I love the way you can redefine a variable with let multiple times changing the type from that point in a safe way, many times I found myself working with a variable that is also the id which builds other and has only that use, for example the typical variable named username and contains the username that is the attribute you use to retrieve the User object from a DAO, in Rust you could do:

let user = get_argument('username');
let user = user_dao.get(user);

Redefining the user variable and avoiding to repeat yourself.

I love also the way Rust handles mutability because not only helps you avoiding modifying something where you should not, but also to know better what the code is going to do if you are reading code.

Cargo is great since allows you to manage compilation process of Rust projects in a really easy way, usually you add dependencies on Cargo.toml and Cargo does all the work, forget the Automake nightmare with the m4 language nobody understands.

In FakeSFTP I did not follow a strict OOP, I made objects when needed or when some struct had to much static functions to work with but thanks to the type system and the compiled nature of Rust refactoring was pretty fast and error-prone.

Maybe what I did for FakeSFTP does not sound like the better practices, but I needed a program mainly for personal use, but the advantages I described may apply on many more cases.

In my experience Rust has prove being a very useful and solid language and I can wait the moment to work with it again.

If this post gave you curiosity about Rust you may read this official book which is the main resource I used while learning the language. https://doc.rust-lang.org/book/

By sergiotarxz

I am a software developer with high interest on free software.

Leave a Reply

Your email address will not be published. Required fields are marked *