Discussion:
How do i make sense of large codebase of cmus.
Mohd Maqbool Alam
2015-12-03 10:10:00 UTC
Permalink
Hello,

I want to learn how the program cmus works and I want to contribute.

I have no experience in open source development and I'm a student learning
about computer science in college.

So i tried to learn by reading code by following ways.

I compile the program and run gdb on it so i found out that program starts
from ui_curses.c from line 2547.
inside main function it calling dozens of other functions and making
decision but my problem is how do i make sense of large codebase how do i
find which pieces of code does what.

I need help How do i read the large code and make sense of it.
what tools should i learn so that it can help me to understand codebase.

any advice and help will mean a lot to me.

In short i want to know what tools you use to understand cmus how do you
read source code and able to understand what each piece code does what.
what tools do i have learn apart from C.

I'm running Ubuntu 14.04.

Thanks

Maqbool
Gregory Petrosyan
2015-12-03 17:35:39 UTC
Permalink
Hi Maqbool,

OK, I'll try to offer some (very) limited guidance.

First, it is great that you decided to study a relatively large and
real-world codebase. While studying it can be initially different, I
believe it will quickly make you much better at programming.

The only tools you need to study the codebase are editor/IDE, compiler,
curiosity and patience. I don't think debugger like gdb is helpful for
program understanding.

Every large codebase have some "core" parts, and "everything else".
Understanding the core is most important. If we are talking about cmus, I'd
consider everything except input (mp3, flac, etc.) and output (pulseaudio,
alsa, etc.) plugins as "core". So — exclude files responsible for the
plugins, and start reading everything else. If your editor has a "jump to
definition" function, that would be very helpful.

If something is unclear, just modify the source code, recompile the program
and run it! A couple of well-placed "printf"s will help you understand what
(and when) is happening a lot.

Let me restate this once again: there is no quick and easy way for reading
and understanding the source code. You have to spend a lot of time and
effort initially. But this is an excellent investment that will pay
dividends during all your future career.

P.S. And of course, you have to learn C first.

Regards, Gregory
Post by Mohd Maqbool Alam
Hello,
I want to learn how the program cmus works and I want to contribute.
I have no experience in open source development and I'm a student learning
about computer science in college.
So i tried to learn by reading code by following ways.
I compile the program and run gdb on it so i found out that program starts
from ui_curses.c from line 2547.
inside main function it calling dozens of other functions and making
decision but my problem is how do i make sense of large codebase how do i
find which pieces of code does what.
I need help How do i read the large code and make sense of it.
what tools should i learn so that it can help me to understand codebase.
any advice and help will mean a lot to me.
In short i want to know what tools you use to understand cmus how do you
read source code and able to understand what each piece code does what.
what tools do i have learn apart from C.
I'm running Ubuntu 14.04.
Thanks
Maqbool
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple
OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
Jason Woofenden
2015-12-03 21:52:04 UTC
Permalink
I certainly agree with everything that Gregory said, I hope you
take that to heart.

I just wanted to add that my personal preference is to dive deep
into one aspect of the software instead of trying to get a broad
understanding first. Usually I want to track down a quirk or bug,
and see if I can change/improve it, but it works just as well if
I'm just curious about some detail.

Usually, as I try to figure out what's going on in that specific
part of the code, I end up learning a bit about the bigger picture
too, but I like the structure of trying to understand one part, and
how it feels like I understand something well much sooner, even if
it's just a small part.

If you don't already have an idea for a deep-dive, you could try to
figure out how the i key works. This key is supposed to scroll the
display to the song that's currently playing (although it only
works if the song was triggered from the current window, and not eg
by the queue).

I don't have anything particularly exciting that I use to find
stuff in the code-base. I read filenames, jump to definitions (with
ctags and vim's ctrl-]) and use ``git grep``.
--
Jason
Loading...