Read the Source

By Eric Lathrop on

In today's modern web development, much of a programmer's productivity comes from code that they did not write themselves. Much of that code is hosted on GitHub, and less and less of it has any amount of documentation. The most prominent form of documentation is now the file in the project's root.

At first, when I came across omissions in a project's documentation, I would google for how to complete my task. For the big libraries this would usually work, but for the long tail of libraries this would not. Even when you could find answers on google, it's still difficult to sort through them to find the solution that works on the version of the library that you're using.

More and more, I'm reading the source code of the project before turning to google. Some programming language cultures, like Node.js, value tiny single-purpose libraries that make it super easy to read their source code.

The source code cannot lie about what the code is doing. The source code will have all the APIs for you to discover. If the source code has tests, those are the most up-to-date and valid examples of how to use the library. If the source code doesn't have tests, you can consider wether you should even be using the library.

Reading a project's source code can also teach you new programming tricks or ways of thinking. The source code can show you how to be idiomatic in your language. Sometimes, the source code can show you what not to do, and you can help the world by fixing the problem. Libraries change from these magic black-boxes, to an extension of your own project that you have the power to improve.

Reading the source code is a super-power. Use it!