albertoefg

Blog About Contact

How I wrote my first Open Source Patch

For the last few months, I've been learning to code, but up until recently, I was terrifed of making a contribution to a Free SoftwareI prefer to say Free Software or Software Libre. Open Sources misses the point about helping the community project; reading big codebases was challenging, I did not know where to start or what to do, and asking for help was hard, because I felt a little stupid for not knowing this things.

This was specially hard because I was learning alone in my house, and I didn't personally know anyone who could point me in the right direction.

Chances are, that if you are reading this, is because you probably are in a similar situation, worry not, I am here to help, from noob to noob. :)

Don't be afraid to ask for help (in the right project)

Some projects will require you to have a lot of knowledge to contribute, others have a lower level of entry. In my case, I started asking for help in #krita. The community is great, friendly, and they helped me to get started on the right track. So you can start as me, trying to contribute to krita or you can find a different project, I higly recommend KDE because it is the community that helped me the most.

When you ask for help, don't expect your doubts to be answered immedeatly, wait a little, which leads me to my next advice.

Be patient

I know it might seem exciting to write your first patch, and a little frustrating asking for help and not getting it right away, but if you are patient and keep hanging in there, the aid will come. Although sometimes you might need to ask what is the best hour to ask for help, because developers might be in a very different time zone. In the mean time, you can try to look at the code and figure it out what it does. This might also require a little help, so the next advice is:

Use an IDE

I know that you might know Emacs or Vim, and everyone probably told you that any text editor is sufficient to write code, and that is true, in fact, I am an Emacs user myself, im writing this post with org-mode.

However, the first time that you look at a big codebase can be very hard, and having an IDE that aids you with reading code and finding the proper definition of every function can get you very far, I used qtcreator to read the code, and it was way easier to read thanks to it.

You can select any function, press F2, and it will jump to the definition of that function! Pretty neat, right?.

Read the Code!

Yeah I know that might sound kind of silly or obvious, but I made the mistake of not really reading the code, I saw all this big functions and files, and I felt intimidated: I don't know any of this functions.

But I kept coming back at the same files for a few days, and after watching them, I started to read them, and the functions made sense!

Code is there to be read by humans! Yes like you and me! (I hope), not by computers, that is why we don't code in brainfuck Brainfuck is an actual programming language.even if we can, because that is hard to be read by humans, so just try to read it! You might learn more than you think, and if you find something that you don't understand, well that is why you are using an IDE in the first place! Find the definition.

Keep in mind, that you won't be able to read it and understand it all, you gotta focus on what you are trying to fix or implement.

Focus on one thing

The project that you want to contribute probably has thousands of lines of code, of course you won't understand it all, heck, I don't know all of the details of the patch that I wrote, but it works! You can always ask for help from the more experienced developers, and if you focus on one thing, and learn to not pay attention to all the other stuff that you don't need, you will soon finish your first patch!

You will make mistakes, but that is ok

If this is your first patch you will absolutely make mistakes, I made a lot actually! But that is ok, we learn by making mistakes, so it is just a way to learn, don't be afraid of learning. Of course my first patch wasn't perfect, it got reviewed and I was told to change it a little bit. But that is expected, you can't be a begginer and an expert at the same time.

Have fun and play!

Even if your patch doesn't get accepted, just playing with the code is both very fun and very challenging, I started to understand the code, by putting a lot of debug functions, so just trying to see if they will come up when I was expecting them and seeing them come up was very fun and illuminating. So just remember to read and poke the code, try to play with it and in time you will figure it out.

I hope that this little post encourages you to write your first patch to your favorite project, and if you need a little helping hand, you can always contact me, and I will try to aid you. :)