5 Ways to find code online
In 2015 google and the university of Nebraska published a research titled “How developers search for code: A case study”. This research was conducted on real google developers, while they were working on their everyday tasks.
The results points out a pain well known to every developer. The average developer sets out on 6 different code searching sessions every single day. Those sessions, which on average consists of no less than 12 different queries submitted, include a variety of search goals. The most common search is embarking on a quest for a specific API, library information or a functional example, representing over a third (33.5%) of the cases.
So, how do developers search for code? They go online.
Chances are people wrote the code you are looking for, or perhaps they built something which resembles what you are looking for. Much of this knowledge exists online as a part of the Open-Source initiative, and is located in open source projects hosts such as GitHub.
The problem is, 98% of that code becomes obsolete and is never being used within 12 months of the day it was written. Instead, developers often wonder to online forums such as Stack Overflow in hope that someone asked the question the are facing before, and that someone provided a good answer.
However, chances are the answer or example they need already exists within the open source. For several reasons, most developers fail to use the full potential of the open source code which could be tapped online, if only they had the tools to do it.
We listed 5 free and useful tools to boost coding ability by finding quality open source code online, and putting it to work.
GitHub is a Web-based Git repository hosting service. It offers all of the distributed revision control and source code management needed to collaborate and build projects together. Valuated at over 2 Billion $, GitHub has become the host of the largest data pool of open source projects known to man, holding over 2 Million active repositories.
However, finding code on GitHub itself is significantly restricting since the built-in search is lacking the ability to effectively find small pieces of code, and in mosts cases even finding an entire project requires preliminary knowledge as to the project’s name, owners or environment. Even after a relevant library is located, it may only be consumed as an entire library. This restriction renders searching for code within GitHub somewhat cumbersome and therefor is often used as a last result.
General search engines such as Google and Bing are perhaps the most common platform used by developers to search for code. Google or Bing is where people search for songs, purchasing items and services, restaurants and information and their algorithms can be trusted to come up with useful results.
We trust Google with everything else in our life, why not with our work? Well, because Google, Bing and every other search engine simply does not understand code. Google understands natural languages in an incomparable manner, and is able to understand with an impressive degree of certainty what it is you are looking for. Although code is a natural language just like any other, Google and Bing simply can not understand code. What they can understand is what people say about this code. The result is that Google or Bing are useful for finding relevant discussions and articles regarding the words you type in, and will often lead to people who encountered similar problem and hopefully found a way to solve them. However, this is anything but a precise and effective pin-point solution to the problem. More than anything, Google and Bing will not tap into the billions of lines of open source code hanging around GitHub and similar code sharing platforms. Not an optimal solution, although often useful to find commonly discussed issues.
Stack Overflow is a well known and widely used forum populated with millions of developers worldwide. Being the host of many online inquiries and discussions about code, SOF is a popular destination to end up in when submitting a code search in Google or Bing. SOF allows every developer to write down what he is looking for in plain english, and hopefully being answered by a developer dedicating the time to help. According to the 2014 Stack Overflow survey released recently, developers spend an average of 7 hours a week writing open source code. Answering questions in the forum often consumes additional time in order to make this knowledge accessible, in case someone is explicitly looking for it. Although an impressive amount of FAQ’s have been accumulated, providing answers for many common code searching sessions, the concept of direct interaction between developers in a simple online forum still reiles on a human mediation between a piece of code being written and another person being able to find it. Simply put, someone in the forum will have to give it to you. This solution is not a bad one, and allows more complex topics like “why is my code failing?” to be properly answered. However, this solution does not provide the ability to directly find and use pieces of open source code which might be useful for the person looking for them.
Package management systems like NPM are an efficient way to find and consume whole open source projects. The main advantage is the ability to not only find and use a specific library, but also to apply a sophisticated system to manage and maintain it. The main appeal of this option is the ability to manage and maintain libraries a person decided to use, while being able to complete the process of locating, implementing and managing entire code packages. The major downside for this service is inevitably the fact that it only enables the implementation and management of entire libraries, often consisting of hundreds or thousands of lines of code. While useful for small projects or well known and widely used libraries, such management systems do not provide a solution for a developer searching for a piece of code or a library to do something specific without being aware of a specific project and what it’s called.
CoCycles is a functional code search engine. The reality in which billions of useful and helpful lines of open source code are practically inaccessible as autonomous units had generated some early prior attempts to create a search engine for code. Those attempts included sited like OpenHub, GrepCode and similar others, which are known to few and are rarely ever used. The main reason for the scarce use of those sites was that they performed a textual search on code bases, and indicating different places within the code or it’s documentation where the flat text being typed by the user. This often results in useless results of little value, if any.
CoCycles is an entirely different breed altogether, since it treats code as a natural language.