Open source code is a term that refers to any computer software program in which the source code, or the programming instructions used in the development of the application are made freely available to the public.
Open-source code is set of program instructions published for use or modification as users or other developers see fit. Open source code may be developed in a collaborative public manner, but when the source code is made publicly available, it can be redistributed and modified by anyone. In some cases, an open-source license will create legal obligations that require anything based on the original material to also share the same terms.
How to View the Source Code
Once you’ve found the GitHub repository that hosts the software’s source code, you’ll find that everything is organized in a basic directory tree. For files, GitHub makes viewing code very easy.
As a development platform, GitHub neatly formats source code through its web interface. Almost all reputable projects will include a README.md, which is a markdown file that displays helpful information about the repository and its structure. When you navigate to a repository, scroll down and you’ll see the contents of this file.
The repository’s README.md is important to check out because it often points users in the direction of the source code that they may be interested in. A repository can be filled with all sorts of code and other data, some of it completely useless to you, so this file is your roadmap.
Once you figure out where in the repository the code that you’re interested in is located, all you have to do is click through the repository’s directory tree to get where you want to go.
Clicking on a file will display it with the proper syntax highlighting.
For quick inspecting, GitHub’s web interface is great. However, for more complicated source code, you may want to view multiple files at the same time or over a long period of time. In this case, we recommend downloading and viewing the source code through a text editor, such as Sublime Text.
Organization of source code
Many different programs exist to create source code. Here is an example of the source code for a Hello World program in C language:
/* Hello World program */
Even a person with no background in programming can read the C programming source code above and understand that the goal of the program is to print the words “Hello World.” In order to carry out the instructions, however, this source code must first be translated into a machine language that the computer’s processor can understand; that is the job of a special interpreter program called a compiler — in this case, a C compiler.
After programmers compile source code, the file that contains the resulting output is referred to as object code.
Object code consists mainly of the numbers one and zero and cannot be easily read or understood by humans. Object code can then be “linked” to create an executable file that runs to perform the specific program functions.
Source code management systems can help programmers better collaborate on source code development; for example, preventing one coder from inadvertently overwriting the work of another.
Downloading The Source Code
Downloading a repository from GitHub takes just two clicks.
At the top of each repository, beneath the row displaying the total number of commits, branches, packages, releases, and contributors, you’ll see a green button labeled Clone or download. Click on it and select Download ZIP.
By default, this will begin downloading the current repository’s master branch as a ZIP file. When complete, all you need to do is extract the archive to a local folder on your computer. Then, using a text editor, you can open any of the repository’s files in a much quicker way that doesn’t require a browser.
If you aren’t an experienced coder, GitHub can be a little confusing at first. If you just think of it as an open directory of source code, with a readme at the top level, it’s not too intimidating. Viewing source code using GitHub is simple, both locally and through its web interface.
History of source code
Determining the historical start of source code is a subjective — and elusive — exercise. The first software was written in binary code in the 1940s, so depending on one’s viewpoint, such programs may be the initial samples of source code.
One of the earliest examples of source code as we recognize it today was written by Tom Kilburn, an early pioneer in computer science. Kilburn created the first successful digital program held electronically in a computer’s memory in 1948 (the software solved a mathematical equation).
In the 1950s and ’60s, source code was often provided for free with software by the companies that created the programs. As growing computer companies expanded software’s use, source code became more prolific and sought after. Computing magazines prior to the internet age would often print source code in their pages, with readers needing to retype the code character for character for their own use. Later, floppy disks decreased the price for electronically sharing source code, and then the internet further deleted these obstacles.
A simple policy for using open source code
The usage policy is an essential component of any compliance program. This set of rules is included in your open source strategy document (you have one, right?) and made available to everyone for easy reference.
The usage policy ensures that any software (proprietary, third-party, or open source) that makes its way into the product base has been audited, reviewed, and approved. It also ensures that your company has a plan to fulfill the license obligations resulting from using the various software components, before your products make it to customers.
There is no need to make a lengthy or complicated document. A good open source usage policy includes six simple rules:
- Engineers must receive approval from the OSRB before integrating any open source code in a product.
- Software received from third parties must be audited to identify any open source code included, which ensures license obligations can be fulfilled before a product ships.
- All software must be audited and reviewed, including all proprietary software components.
- Products must fulfill open source licensing obligations prior to customer receipt.
- Approval for using a given open source component in one product is not approval for another deployment, even if the open source component is the same.
- All changed components must go through the approval process.
Checking Out a Project
Once you have an account you can dive straight into an open source application found on GitHub. Here you can see the application’s project page, including folders and files pertaining to the application, a network graph, a list of pull requests, open issues, a wiki, and other graphs. Obviously, if you want to see the code within the files, you should click on them and you’ll be presented with the full source code. As far as interpreting the code goes, you’ll need to have some background in the programming language that the application is written in, whether it be Java, C++, Python, or something else. For those wondering, the screenshot shows Caleb Evan’s jcanvas project.
In the legal review phase, the legal counsel (typically a member of the open source review board, or OSRB) reviews reports generated by the scanning tool, the license information of the software component, and any comments left in the compliance ticket by engineers and members of the auditing team.
When a compliance ticket reaches the legal review phase, it already contains:
- A source code scan report and confirmation that all the issues identified in the scanning phase have been resolved.
- Copies of the license information attached to the ticket: typically, the compliance officer attaches the README, COPYING, and AUTHORS files available in the source code packages to the compliance ticket. Other than the license information, which for OSS components is usually available in a COPYING or a LICENSE file, you need to also capture copyright and attribution notices as well. This information will provide appropriate attributions in your product documentation.
- Feedback from the compliance officer regarding the compliance ticket (concerns, additional questions, etc.).
- Feedback from the engineering representative on the auditing team or from the engineer (package owner) who follows/maintains this package internally.
The goal of this phase is to produce a legal opinion of compliance, and a decision on the incoming and outgoing license(s) for the software component in question. The incoming and outgoing licenses are in the plural form because in some cases, a software component can include source code available under different licenses.
Forking a Project
Editing the code requires some additional steps. If you wish to copy the code without officially forking it on GitHub, you’ll need to download the project’s files and then edit them locally on your computer. However, if you’re truly looking at using the currently available source and creating your own project with it and going in your own direction, you’ll want to fork it. Forking can be accomplished with an account, and by clicking on “Fork” on the project’s page as shown in the screenshot. The next few instructions are for Linux users who should install the G
package for their respective distribution.
If you wish to retrieve the repository’s files to your computer, you’ll need to run the command
git clone https://github.com/username/project_name.git
, replacing username with your GitHub username and project_name with the name of the application project that you just forked. Run this command within a folder that should contain all of your GitHub projects, as each git clone command will create a new folder within the one you’re currently residing. This is another way of downloading a project’s file as it doesn’t require login credentials. Now you can change the files as you please using any text editor or IDE. For Linux users, I’d recommend Eclipse or Geany as they’re great programming editors — Eclipse being more full-featured and Geany being leaner. Windows users can also use the native GitHub client.
Use our open source code file for your visualizations. Source code files are a language-specific text file that contains a set of instructions that the computer follows to perform specific operations.