Practicing Data Structures and Algorithms in Rust: My Experience, and a Text Editor Built in just 6 hours

Dhiman Seal
4 min readMay 10, 2023

--

Practicing DSA in Rust: My Experience, and a Vim-Like Rust Text Editor Built in just 6 Hours for a Hackathon

Introduction

Practicing data structures and algorithms (DSA) is a common requirement for tech professionals, but it can become tedious after a while. However, trying out different languages can make the learning process more exciting.

This was my experience when I tried practicing DSA in Rust, and it made the learning process fun and engaging again. In this article, I will share my experience of practicing DSA in Rust and how it led me to build a Vim-like text editor in just six hours during a Rust Hackathon.

Why Rust for DSA?

I was bored of practicing DSA and Rust brought the fun back.

  • 😤 I hated practising DSA: It felt like I was replicating things that have already been done before and done better. Rust made it feel fresh again.
  • 🏔 The Challenge: It was far more challenging to implement things like trees and algorithms in Rust, and it made me feel like I was learning things I actually was interested in, like how things move in memory.
  • ⚙️ It was far harder to find solutions to common problems in Rust: Not many people use Rust, hence it incentivised me to think of solutions on my own a lot more
  • 🚀🚀🚀 THE SHEER OVERPOWEREDNESS OF RUST SOLUTIONS: The same solutions written in Rust completely outclass the solutions in most other languages. Although you are only supposed to compare your solution with other solutions in the same language, it was still wild to see.

Anyway, you all just got click-baited. This post is not about Data Structures and Algorithms. I recently participated in a talk about Open Source and Rust, and participated in a Rust Hackathon after that.

Building a Vim-like Text Editor in Rust

With my only previous experience in Rust being solving Leetcode problems, I decided to take on the challenge of building a Vim-like text editor in Rust.

In just around six hours, and with my only previous experience in Rust being solving Leetcode problems with it, I completed building the thing, and won the Hackathon.

Features of the Text Editor

  1. 📝 Text Writing, Scrolling, Word Wrap, Clipboard reading and other typical features you would expect from a Text Editor.
  2. 📺 A Complete Text User Interface with Logs, User-Friendly Help Menu with Keyboard Shortcuts.
  3. 📚 Creating, Opening, Saving and Managing Multiple files just like any modern text editor.
Hackathon-winning Vim-like Rust Text Editor created in just 6 Hours with logs and Monitoring, scrolling, text wrapping, managing multiple files, and other features | https://github.com/Dhi13man/rust_text_editor
Hackathon-winning Vim-like Rust Text Editor created in just 6 Hours

Limitations

At the time of writing this, it is still a product of a hackathon and contains flaws like:

  1. It has virtually no optimisation and has potential bugs.
  2. It can only open files when you copy the path to the files in your clipboard and hit the relevant shortcut. There is no intuitive File Opener system.
  3. It is full of code that works, but is not organised too well.
  4. The UI could probably be improved

I am happy to announce that this project fully Open Source now, so feel free to contribute to it yourself and fix these, if you want to practically learn Rust yourself

Result of the Experience:

Regardless of the flaws of the project, I still won the Hackathon. The experience got me:

  1. A free Mug, a book and a T-Shirt.
  2. 🎊🎉🎊🎉 🎊 ANOTHER JOB OFFER
  3. All the learning and confidence that I could need to solve any problem, any time.
T-Shirt won from the Rust Hackathon Event
T-Shirt won from the Rust Hackathon Event

The experience showed me that Rust is a powerful language, and building real-world applications in Rust can be both fun and rewarding. Rust is not just a language for DSA or systems programming; it has a vibrant and growing community that is excited about building new things in Rust.

Conclusion

  1. Practicing DSA in Rust can be a fun and engaging experience. It challenges you to think in new ways and offers the potential for overpowered solutions.
  2. Building a Vim-like text editor in Rust during a Hackathon was a great way to learn more about the language and its capabilities.
  3. While my text editor still has flaws, the experience of building it gave me a job offer and showed me that Rust has the potential to be a game-changer in the tech industry.
Buy me a coffee at: https://www.buymeacoffee.com/dhi13man
dhi13man is developing Software, Apps, Libraries, Open Source Contributions etc. (buymeacoffee.com)

Source Code on GitHub

#opensource #rust #rustlang #hackathon #vim #software

--

--

Dhiman Seal

Head Empty. Just Vibes. Attempting to write articles about tech, on my journey to be THE KING OF SOFTWARE ENGINEERING and make people's lives easier (I guess)