Function Search Engine / How To Search Engine

I had an idea recently that has sparked a lot of excitement in my mind... not infrequently, I find myself needing a function that I know has probably been implemented 10,000 different times by other software developers over the ages, and I groan that here I am, about to do it again. Other times the function might be more unique, but I'm still convinced that its something that other people have already implemented at least a few times.

What if there was a really compelling way for developers to share functions/classes? There already exist places like GitHub for sharing projects, and that's great, but so often what I want isn't an existing project, it's an existing function. Imagine this search engine was more than a search engine, it was a combination of a search engine and a source code repository like GitHub. People could upload functions, associate unit tests with them, and the site would allow others to view those functions and even run them interactively on the website to play with them. Users could file bugs against those functions, resolve those bugs / commit fixes, etc. Users could comment on functions or make requests for improvements, etc.

The second ingredient would be to make these functions very findable through clever use of NLP, etc. So, you're coding in Java and want code to download a webpage? No problem -- search for "download webpage", and see functions that do exactly that.

This could be expanded to also encompass the idea of "how to's" / "example code". Search for "Java convert string to integer" and a function would be found that demonstrates how to do that. You might not want to use the function in the end, but at least to be able to examine the function to learn how to do what you were asking for.

Next: The ability to write functions that call other functions on the site. Technically you'd be calling a certain REVISION of that function, since future revisions of the function you were calling might cause breakage, but automated tools could be used figure out if it was safe to call a newer version of that function. It would also be interesting, upon modifying your function, to see if any of the tests for things that call your function break. (A kind of canary in the coal mine that might suggest you broke something in your function)

I think this idea combines (can combine) some powerful things:

Open source
Crowd sourcing
Wiki
NLP
Exponential nature of technology (building up more powerful pieces)
Ratings: People could rate functions to make them higher in the search results
Status: As people contribute more, they gain status. Useful for resumes, feeling good about one's contributions, etc.

Also imagine people defining "interfaces" + tests that define useful bundles of functionality, and being able to associate functions with interfaces. The system might even try to automatically detect when a new function matches an existing interface. Lots of interesting possibilities there.

The system could automatically sort functions by their runtime to show you which implementations were fastest, etc.

Yet another way to search for a function could be to define the arguments of a function you're about to write, the description, and a few sample input/output value pairs, and then have your IDE connect to the service to see if there are any existing matches or close matches. If so, it could essentially fill in the body of the function you were about to write automatically, or download the function and simply refer to its implementation.

Then imagine associating implementations in one language with implementations in another so that if you're learning a new language, you can simply click on a link to see how some particular thing is implemented in another language. It could also then generate metrics to show how many relative lines of code you need to implement something in one language VS another, the speed of execution, etc. That could then be used as a semi-automated tool for converting code from one language to another -- just use the properly mapped function.

And the final idea I'll propose is to provide a way to map what a function does onto a semantic model with the goal of making it even more possible to simply write a specification of what you want done, and have the site be able to cobble together the appropriate functions to do what you want, and spit out the required code.

Lots of really exciting possibilities in this space...