How Open Source helped me learn Rust

· Harshil Jani

#open-source #rust

Hey there, This blog is a reflection of my journey towards contributing to open source projects in general and more focused on the Rust Programming language which I have been using since two years to work on amazing projects out there.

Moving further the blog has two main sections. The first section has novice advice for the open source and basic skillset required if you are comfortable already contributing to one language or the other then you may consider reading the second part where things gets interesting in which I discuss my years with Rust Language.

# Part 1 : About Open Source

Have you ever wondered what open source is in true sense ? It's not any random project that is on github. Open source is way more spreaded than being on github. I would insist to read a bit about foundation of GNU and Richard Stallman to get an idea of why it is important to build softwares with their source code made freely available to avoid malpracticies that are abstracted in corporation.

There are countless projects listed on the repository hosting tools like Github, Gitlab, BitBucket etc. Also, Some organizations don't use any of them and have their own hosted version of repository hosting service. Good example of such organizations is the Linux source code or the Google Open Source (Eg: Android Source Code) which are not directly on Github (If you find it on github then you'd see the word "mirror" which means those are the copies from their hosting). My most loved interactions have been with KDE and ToR Gitlab hostings which are separate from the normal Gitlab account.

Another edge of story is a version control tool called git. It may seem intimidating at first but it's a very basic tool to be used for version history keeping. If you struggle a lot with git, Blindly take a two day off from coding/programming and learn linux filesystem as a concept first. In fact , If you can manage to install and run a linux operating system (In terminal) it would be great but if you decide to stick to windows then I would still recommend to do any filesystem course available online to get an idea of very basic terminal commands and the way things are stored in linux. Going ahead, Learn two data structures : Linked Lists and Trees. Get a very basic grasp of these and then google up and learn 4 pipelines of git. Do a very basic less than an hour tutorial on git. That's all you need to do in order to understand the basics. Git is an advanced stuff and learning never goes obselete. Next time your old windows machine don't find the git bash for MSYS2 remember me and my deeds that lead to stripe the support from git for windows. That actually was my official contribution to git project itself. Doing all of it, takes hardly 2 days max for a kid who just gets into programming.

Coming to another point of open source, Which language is the best to learn to start contributing ? This is a choice. Language is not a defination of contributing. In real world no project is in single language. The programming languages are made of compilers or interpreters. They have their features that makes them different from one another. Let's understand python and javascript. Python is fast and blazing to write. But when it comes to hardware interaction, Python doesn't have the grip on it so you will find core languages like C , C++, Java etc. Python is all virtual. But if you need a language that just does the right thing for you and has great library support, Python is quick enough to get your job done. It's a trade off which cannot be judged. So never worry much about the new languages you'd need to learn and just jump right into the project ideas you'd love.

Let's divide the open source projects into catagories.

Historically, The projects have been from made from bottom to top. The reason you should be aware of these is because assume a scenario where you are a software engineer for dominoz website and the site is in React. Now, You were writing code for a new feature of a search bar and found that user needs to press a button each time they writes a character in the search bar. That's annoying right ? How to make it work automatically without pressing the button with typing in every character , which is in technical terms called as debouncing (You can google it up and learn this micro-concept just now if you are hearing this out for the first time. This is the skill that is only required in Open Source and nothing else is more important). Now, What if that feature is not available in react ? You get frustrated. This is a golden opportunity where you can go ahead into the react source code find your way out and add a feature for writing a debouncer where you'd find things to use easily. This is how you make a contribution. I will discuss some of my contributions later in part 2 of this blog below.

The genuine problems faced to contribute are that codebase is insanely large and not finding good-first-issues enough to contribute to a project. The solution is very simple. Firstly understand that github is a developer's community and comprises of human. An issue that is marked as good first issue can be really easy for the person who marked it but not for somebody else. For large scale projects what good first issue actually means is that when you come to the project for the very first time, You have no idea what's going on in the codebase and it requires very minimum efforts to understand the code in entireity and you can simply contribute by focussing on a very small part. If you find good-first-issue easily and can solve it that's so good. But if not, Don't be afraid to look for other issues.

Also, Don't let your computer be shy of installing random softwares or projects. Just put the setup of any project you'd like to learn or know because that's the place where you'd find the most problems with and can contribute in a lots of good first kind of issues. Coming to large codebases, Never be afraid to stare the code. Any problem you'd like to solve has some keywords. Searching the code through files is the best thing you could do. Sometimes google things up and learn anything you'd not know in fraction of seconds.

It's very easy to get an idea of what is the expectation of an issue especially in the AI era. There are times when you spend enough hours on it and still cannot understand things than that could be the best point to approach a person who writes such codes on that project. To learn about such good things and best practices I would say read a lot. Read README, Contribution Guide, Issue description, Open PR comments and etc etc. Long story short Read this https://www.catb.org/~esr/faqs/smart-questions.html . I was forced by my tech-guru to read this piece of article and I have never looked back in my life after this. I can rightfully say if you want to understand open source all you need is some time, attention to whatever you are reading, reading and interpreting things. Coding is way too easy if you find the correct function/file to make change to or responsible for a bug.

Never fly over fundamentals. I feel lucky enough to get into the programming/coding before AI revolution or crypto revolution. For me, It was all about learning how a computer starts, electric currents flows in, chips switches their 0/1, Operating systems, Database, Computer Networks, Data Structures etc. I am/was/will be a slow thinker always. My mind is very slow in processing and for me personally learning things takes time. Due to that, I ended up being a fundamental learner. If you ask me an algorithm, I bet your future kid would solve faster than I can. But when it comes to information dumping, I am best at it because I have explored things more in width than average individuals exploring. Always break any problem into very layman fundamentals without complicating things. Take time and go slow. Copy code from Stackoverflow, AI, Quora etc. doesn't matter. Applciation of the code in correct place is all you'd need to do to make a progress. If you take a glimse , The job of computer scientists or mathematician is to come up with fast algorithms and stuffs. And as engineers, We need to implement it. Compare scientists and mathematicians with a chemist from a brick industry who decides to put in the right proportion of chemical to build durable brick and Compare the engineer with a builder whose job is to design the house and use the most durable brick without getting deeper into the chemical composition of it. Delegate the work, Do what is meant to be done and don't be shy to explore what you'd love to do. Afterall knowing what chemicals are used helps you build more robust infrastructure and someday the builder would end up learning good practices and can confront somebody who'd try to make mistake into their composition based on his past experiences. In simpler terms, Take some time, Learn algorithms but don't be much afraid if you cannot create your own algorithms every now and then. Open Source has multiple things and the most important reason I said to learn linux is because I have seen a common problem that people who are exceptionally well with algorithms often make mistake with filesystem. It's very basic skills which once learned will leave an added impact to your understanding about softwares.

With very such basics, I was fortunate to work for softwares in Google Summer of Code twice, Summer of Bitcoin, XR Open Source Fellowship, C4GT and my personal contributions to projects either under any event or randomly. I have separate articles for each program you can check those out from my Github Profile. For the scope of this article I would like to take you along with me on my journey of how I learned rust and did what it takes to be done.

# Part 2 : Journey to learn Rust

# Learning Phase (2022)

The 50% of my time in open source has been spent with Rust projects and another 50% with combination of Javascript, Python, C, C++, Markdown and Scripts. It was in 2022, In one of the FOSS (Free and Open Soure Softwares) group, I sent a message that was about seeking advice on how to rice my linux distro. I met a linux chad (Flying Cakes) who introduced me to i3wm and I am using it on each OS I use till today and also my very first mentor in life has been using the same window manager since last 13 years. So, We had good amount of exchange of talks on Ricing and then he invited me to his session which on that day was 11 person in total including me and he was teaching to clone a compiler of zola SSG site in rust programming. It was a toy project which he started just for learning and I ended up joining that discord server. Rust was completely a new thing to me but the syntax was friendly and I can understand a lot of it because it was similar to C and Javascript/Typescript. But there were few features like unwrap() then Option<> match etc. which were looking weird to understand. At the end of call, I asked what I can do to understand these things and he replied - start learning from Rust Book which is the official documentation of Rust.

| Advice : Read First 7 Chapters of RustBook

It was at that time I found out about Rust Language. After that, I had started exploring random things and went up to github to search good-first-issues but things went overhead initially which was quite normal. I did some basic tutorial projects copying from internet. One of them was a web application with Actix-Web. Most of the time, I would end up reading articles on the Rust language without understand them fully. My efforts were not under any particular direction. They were flexible and open to anything.

# Rust in Action (2023)

Around the start of January, I got enough traction of learning rust as a language and by now I was able to port codes from any single language to another. Or if you'd give me some task to do, I can implement it. There was a program on Bitcoin and I had learnt very fresh concepts of cryptography like ciphering, assymetric or symmetric encoding, decoding etc. And the fact, I come from Electronics background, We have communication theory in blood. Bitcoin as a project was completely built around the concepts of network and advanced economics. Starting from January, I have been a core contributor of Rust-Bitcoin (Serialization and Deserialization library)and Rust-Miniscript (compiler for descriptors). With initial few months, It took me good time to learn new concepts on blockchain, cryptography and networks to understand things and write code. The level of contribution just increases gradually and was heavily reviewed by chads of the projects.

Meanwhile, when I was learning about bitcoin, I found a project called Qaul which was a peer-to-peer chat application that runs on a network mesh without any traces collected by ISP or Goverments. The project was on similar lines where your profile was created with keys and was verified by peers and could potentially run on bluetooth as well. It was part of my exploration on anonymity stack where you could live non-existential in the world. The maintainer of the project was already working on a concept where we can integrate the application as a bridge to matrix service which is again another decentralized service and can be used in any third party apps like discord, wsap, telegram, signal etc. Initial idea was to use GoLang to build a bridge but we ended up writing the bridge in rust that was suggested by a friend who works in Element which is a matrix client(UI). This was one of the early utilization of RuMa and the Matrix-SDK in rust and we were the one of the earliest project to integrate a bridge in rust language. We ended up giving a presentation about the bridge in Matrix conference and had done wonders for it. Parallely, With due respect to my contributions in Rust-Miniscript, I was selected as a Summer of Bitcoin fellow where I was expected to write some example code first and then interact with the developers of BDK (Bitcoin Developement Kit) to integrate the must needed feature of wallets which was about asset planning.

In layman terms asset planning was all about reducing fee rate by lowering the number of people required for doing a transaction for multisig. You can read whole project idea here https://medium.com/@harshiljani2002/rust-miniscripts-planning-module-efficient-bitcoin-transactions-sob-internship-report-ae653c456494 .

Earlier, I was affiliated with an organization as an Intern and was assigned task to explore Tauri Desktop Application and a Actix based project to sign using ecdsa signatures. Both had minor inputs to be given and were a short span to explore the rust language. Around the end of year, I was wandering on other projects and what caught my attention was a TUI engine that was used to write different TUI application. Imagine that as being a lightweight framework that helps you write TUI Applcations. Later on the maintainer of the project went on to become my first sponser on Github and we enjoyed building clipboard features together and building a cache system for the editor engine.

# Current Phase 2024

Early in 2024, I did a very short tenured internship of max 10 days at a firm where I converted migration service from rustsql to sqlx for async nature of the migrator. That was only task I did and was looking after a crate called ndArray to port the python based machine learning models to rust but now I have left programming/coding as a primary task. Economics is my new friend but I keep landing my PRs ocasionally on TUI Engine. The maintainer is also having his personal time off which will end very soon this week and potentially I can claim back being a contributor to TUI Engine yet. Another thing which I am looking forward is to write a personal toy project of maintaining an orderbook system in rust and also try contributing to one of the SDK project real soon which will move me up the stack from a compiler to SDK.

What I earned doing all these ?

Follow me on my

Github : https://github.com/Harshil-Jani

Linkedin : https://linkedin.com/harshil1

Nostr : npub1cgwchhlzy455anf9p6l39c37nfac9vdefntnt7r5gycv6tfnrjyqc7ug2t

Matrix : @harshil1:matrix.org

email : harshiljani2002@gmail.com

Twitter (X) : https://twitter.com/harshil_jani28