Top shelf web developer training.

Guided Paths

Follow our crafted routes to reach your goals.

Video Courses

Premium videos to build real apps.

Written Tutorials

Code to follow and learn from.

Find Your
Opportunity HIRED

How To Find Code by Functionality with Cocycles

Related Course

Get Started with JavaScript for Web Development

JavaScript is the language on fire. Build an app for any platform you want including website, server, mobile, and desktop.

Cocycles is a free online code search engine for open source code. For the first time, open source code ie being organized in code pieces, not only repos, by what each piece of code actually does. This, combined with an online search engine which can translate natural language into code, will allow developers to actually search and find independent open source code units. In this article we’ll show you how to use this new technology to find those useful open source code pieces, as well as other valuable information such as:

  • Searching the right way; by functionality
  • see full source code implementation for the code you need
  • Documentations for that code
  • Usage examples for that code
  • Useful metadata to help choose the best code from the right repos
  • Using the code you find and learning from it

Background: the problem with finding code

Searching for code online may take up to 50% of a developer's working time on any given day (most researchers suggest between 25%-65%). Most of this time will naturally be spent roaming the web, throwing queries against the wall and praying to dear god that someone asked this before and someone else provided a useful answer, one which you might benefit from.

That's a whole lot of praying, considering that chances are someone did right the exact code you need before. And you can find, if you know where to look. Open source code contains dozens of trillions of lines, and multiplies every 14 months. The code you are looking for, by all accounts, is probably somewhere in there.

In fact, this is only a symptom of the real problem. The real problem is a much greater one, and of a much more destructive nature. First, let's take a look at some numbers. GitHub recently reported hosting over 35 million repostiories, formed by dozens of trillions of line of code. The amount of open source code in existence actually doubles in size roughly every 14 months over the past several years. However, official reports also indicate that the number of active repositories includes less than 10% of all repositories. In a quick calculation we learn that tens of millions of repositories, containing trillions of precious code lines written by millions of brilliant developers, are thrown away and are never to be used again.

Sounds dramatic? It is. But, this does mean that there is nothing to do about it. This is the very mission we at Cocycles took upon ourselves and the worthy cause we chose to fight for: make all open source code organized and accessible. Not only by repositories, but by code. Or, by code functionality, to be accurate. So, we built Cocycles. This is an ongoing work in progress, and major improvements and new capabilities are being added almost on weekly basis.

What is Cocycles

Cocycles is a new technology able to do two great things for developers looking for code. The first, is going throughout the open source and identifying different functional units of open source code. Functions, Classes or even entire libraries may hold a unique functionality. Cocycles, unlike general search engines, is able to understand code, and is thus able to point out what is the unique functionality of every code piece throughout the open source.

The second is understanding natural language, or just plain English. When a developer submits a query like "Parse http headers" or "create random string", Cocycles is able to understand what the desired code is actually supposed to do. Cocycles also understands most common "slang" words used by developers, so searching for "create random string" or "gen rnd str" should produce the same results in terms of functionality (give it a try).

After being able to do those two things, Cocycles is able to match an English typed query with the right code functionality, and presents the developer with a variety of results which should prove useful to him/her.

How it works

When choosing a result, Cocycles will open a result screen with some rather unique layout. The primary part of the result screen will include the full source code implementation for the selected result. For example, when a developer chose to search for a function to check if a given value is a number by typing "is number" and pressing "search", and chose the first result taken from the AngularJS project, the result screen will include the full implementation of that function within the core of Angularjs:

Cocycles utilizes a unique technology to understand code functionality, and matching that against a query described in natural language. Taking a simple query such as "create random string", "shuffle array" or even "hash map" and providing with the right code functionality to match the described behaviour, requires that cocycles will be able not only to harness natural lanugae processing algorithms which are vital to correct analysis of the submitted query, but also to be able to understand which code lines from all across the open source are the ones which will actually help generate a random string or perform any other functionality described by the developer.

Cocycles will also present the original documentation for the selected code, and some real world usage examples as to how people actually used this code throughout the open source. Those two information units might prove vital in the process of understanding wheather or not this code is what you are looking for, as they may provide a clear explanation on what it does or a demonstration of it being put to use in real world conditions.

How can Cocycles help you use the code you find

Finally, a "Generate Snippet" button will allow a user to perform a small "miracle". It will instantly generate a fully functional snippet, including all sub-functions, code dependencies and everything the code needs to work, within the generated snippet. For example, if a function named "Copy fish" will use another function called "shrink fish" which is defined elsewhere, the snippet generation process will include both in the snippet generated.

Additional useful features include an immediate view when Cocycles identifies exactly what you are looking for (try "angular is number" for example) providing key information and usage example in an immediate view.


Cocycles is a new technology able to search for open source code by describing code functionality in natural language. In other words, you can tell Cocycles what is it you need the code to do, and Cocycles will try and find the best code pieces to do it. It will also provide with much necessary information, so you can better understand if this is what you are looking for.

Cocycles is a first and necessary step towards making open source what it really should be: open and accessible for everyone, organized by functionality. The issue of making use of existing code treasures is a hot topic, as recently Bing released their own attempt to make code more accessible by showing code snippets from different site already within search results:

However, we believe that the open source is and will will be the largest, most diverce and most powerful code resource yet to be made fully accessible and organized. This is a mission we took upon ourselves, and we intend to see it through. Cocycles is free and open online to help all developers, under the philosophy of "we built this to help people so that's what we are going to do". Hopefully, this is first step in organizing all of world's code, making it truly accessible for everyone. We are welcoming any ideas and help from the community, and you are welcome to hope on.


joni sar

Jonathan is a part of the Cocycles team. He and his friends believe that brilliant people write great code wand want to share it, and that this is the key for a better technology. For a better world. Jonathan and his friends eat, sleep and work to make sure all code in the world is organized and made accessible to everyone, and that Cocycles will help the developer community preserve knowledge, code better and built great stuff.