Skip to main content

Wear out or Rust out ?

“We must all either wear out or Rust out, every one of us. My choice is to wear out.” — Theodore Roosevelt.

I've wanted to do this for a long time. I have watched online courses, read books, but somehow I couldn't get down to anything concrete. I had no idea, and writing another hello world is not as fun as it used to be. Fortunately, there was a problem to solve. I have a large collection of photos. It comes up to 1TB and still contains a lot of duplicates. I remove them "on the fly", which means in practice that if you remind me, I look for them and remove them until I get bored, which is quite fast. I even have an automated script in python that catalogues them and also (at least in theory) removes duplicates. But I dreamed of something else. I would like to have a program that will read all the files, count their cryptographic hashes, save them in the database, and every time a new file is added there, it will immediately check if it was not already there. My network drive on which I keep my photos is attached to a computer with an arm7 processor, which is not very powerful, so it would be good if the program itself was maximally efficient to make the most of the modest possibilities of the processor.

I finally have something where I can use Rust!

I have some pretty interesting emotions related to Rust. When I first read about the philosophy of language and the problems it's supposed to solve, I thought the idea was brilliant and they should have come up with it 20 years ago (not 10 ;) ), it looks like the developers thought of everything right away: the package downloading and publication system, easy documentation to extract content from the comments, including the fact that the example of use in the comment-documentation is also compiled to ensure that we don't forget to update the description of how the interface will change. Even the catchy name itself. They really thought of everything. So when I was on summer vacation to take a break from programmer's work, I read some books (who would guess?!) about this language. Everything looked bright, clear and meaningful, but as you know, to learn a language you have to write something in it and not just read. Despite this, reading about the Rust on holiday also had another unexpected consequence. In autumn, after the holidays, I was bored and wanted to read something. For lack of other books, I returned to the book about rust programming. And I immediately felt like I was on vacation. No kidding, if I knew that my brain could evoke that mood if only I read what I'd read during the holidays, I would record it for years and read the same book over and over again during the holidays. I recommend to try it (not necessarily a book about programming, I think that any book you have to focus on will do) because I had no idea that I would cause such an effect. Anyway, I read more of it in autumn because it worked well to improve my mood. As a result, I have a lot of theoretical knowledge and little practical knowledge. Until now.

But, let's go back to the beginning. Rust is a language that promises to eliminate certain problems that programs have. Especially the memory problems and racing (dangling pointers? use after free?, modifying a collection while another thread is enumerating it?) and it does that at the compilation stage. You can say that it's nothing as .net and java also manage the memory and make sure that it is released only when nobody needs it. Only that they need a garbage collector for it which reviews what's in use and what's not, and does mass cleaning every now and then. Not as efficient as when you know exactly when the value is no longer useful. And even if someone likes garbage collector, neither java nor .net will protect you from adding an item to the list when another thread is iterating. It will throw an exception, you will look through the logs, add a lock and the problem disappears.

Cool, but in rust code, which allows for such modification will not even compile and this fact shows the power of the language. We do not wait for errors in runtime, such situations are caught by the compiler. Except for logical errors which can't be solved because no compiler knows what the programmer wanted to say, memory management is supported. No need for virtual machines, full hardware performance. We have the best of both worlds (native and java/.net-style virtual machines) - fast and with memory under control. I predict beautiful future for this language. That's why I wanted to do something about it. That's why I'm so happy that I finally have an opportunity.

Opinions about the language often contain something that looks like an internal contradiction: An easy language but with steep learning curve. Like what? Is it easy or not? From my little experience, it is indeed easy, but after overcoming the first problems. The photo cataloguing program I started to write is my project where I will learn the basics. I thought that maybe someone could use a little help in solving simple problems related to starting programming in this language. That's why I also started recording my screen while working. I hope somebody will find this useful. As for me this is totally new experience, I realized how difficult it is at the same time to think about what you want to do and to comment on what you want to do, so that the viewer will know too. As a result, some sentences are stretched for several minutes with each word spoken separately :). I will work on it. (Anyway, I recorded it in Polish so comments might have no use for you)

By the way, the program already works. It still doesn't have all the functionality, it's still being developed, but it's already useful. If you want to try it (or even better - join and develop it with me), it is here:

And if you want to see what the work on the program has been like so far, maybe also get interested in the new programming language... I invite you here:

Lastly, referring to the quote from the beginning of the article, in full knowledge of the fact that it is not on the subject, if not counting one word,... remember that between "wear out" and "rust out" there is also "wear out with a little Rust" ;)