
Ask HN: RapGenius for code? - fizwhiz
I think RapGenius (i.e. Genius) is a really powerful way to arrive at a crowdsourced understanding of what content is. This works well for static content like lyrics of a song, text in some literature etc. I got curious what something like this might look like for code and after a cursory google, I stumbled upon Omniref, which looks like they&#x27;re targeting this exact problem. Of course, they&#x27;re aiming to provide a very comprehensive solution that scours and indexes the web to surface code that can be annotated. AFAIK, their solution works for Ruby and more recently Javascript.<p>I&#x27;m curious if this could be packaged as some github plugin that is language agnostic. Think of it as a persistent Q&amp;A that holds a &quot;conversation&#x2F;discussion&quot; on specific lines of code. Naturally, this feature is available when you send a PR to start a discussion, but once the PR is closed that&#x27;s the end of the discussion. One problem code presents that other literature doesn&#x27;t is the fact that it tends to be less static (i.e. code keeps changing over time whereas lyrics to a song may not.) If there were an elegant workaround to this problem (where prior versions of a line of code and its Q&amp;A is cached so that an interested user could view what the past conversations were) I&#x27;m tempted to say that this could really streamline the learning and collaboration process when it comes to using&#x2F;writing code.<p>Anyone here play around with this idea in the past? If so, I&#x27;d love to hear your stories. If not, anybody interested in joining me on hacking some POC up to see what this could end up looking like?
======
tomlemon
You can annotate code with the new Genius beta!

For example:
[http://genius.com/5077469/gist.github.com/RogerPodacter/3e8a...](http://genius.com/5077469/gist.github.com/RogerPodacter/3e8adbfa9cfd06d239a2)

And actually you can put "genius.com/" in front of ANY url to annotate that
page. For example:
[http://genius.com/5077492/www.paulgraham.com/yahoo.html](http://genius.com/5077492/www.paulgraham.com/yahoo.html)

There's also a chrome extension:
[https://chrome.google.com/webstore/detail/genius-
beta/ccaokn...](https://chrome.google.com/webstore/detail/genius-
beta/ccaokncpmmjiakalbcfdbfmpcaiddjdn?hl=en-US)

You can sign up for the beta at
[http://genius.com/beta](http://genius.com/beta).

(Questions / feedback welcome – tom@genius.com)

~~~
asadlionpk
But that code is just a html page you are annotating. What happens on a new
commit. The annotations should persist somehow across code changes. That would
require specialised solution for code annotation I suppose.

~~~
tomlemon
Well take this for example:
[http://genius.com/5079163/github.com/rails/rails/blob/master...](http://genius.com/5079163/github.com/rails/rails/blob/master/activemodel/lib/active_model.rb)

This annotation will always be on the version of active_model.rb at master,
even if it changes.

And we try pretty hard to anchor annotations even when the underlying text
changes. Here's a talk I did explaining our approach to "fuzzy annotation
anchoring" if you're super interested:
[https://www.youtube.com/watch?v=FJyqfRcyYIQ](https://www.youtube.com/watch?v=FJyqfRcyYIQ)

But it's definitely not perfect! Hit me up with suggestions: tom@genius.com

------
beliu
Check out Sourcegraph: [https://sourcegraph.com](https://sourcegraph.com). It
semantically analyzes code, makes it searchable, and lets you find usage
examples of how others use it. One of the features we're planning to ship soon
is commenting on pieces of code.

Because Sourcegraph understands the code at a semantic level, we can tie
comments to a specific function/class/module and show the discussion history
even as the specific lines of code change over time. Right now, we do comments
for code reviews, but want to add this for any existing version of the code.
I'm one of the creators of Sourcegraph and would love to hear any
feedback/suggestions the HN community has to offer!

~~~
fizwhiz
Hey, sourcegraph looks really neat! Another commenter provided the following
example:
[https://sourcegraph.com/github.com/golang/go@ac452349e4f40c3...](https://sourcegraph.com/github.com/golang/go@ac452349e4f40c30d50f9922bf2c4592e748ce5e/.tree/src/bytes/bytes.go#selected=3)

I love the fact that I can hover over anything (primtive, function etc) which
surfaces a blurb on what its accomplishing .

>> Right now, we do comments for code reviews, but want to add this for any
existing version of the code

Any idea on when you may roll such a feature out? I'd be hugely interested in
using something like this for my team.

~~~
beliu
We're shooting for sometime soon; it's high on our priorities list, and we'd
love to find partners to help test out the feature. Want to shoot me an email
at beyang@sourcegraph.com?

------
spellboots
"Omniref (YC W15) Is Rap Genius for Code":

[https://news.ycombinator.com/item?id=8821117](https://news.ycombinator.com/item?id=8821117)

------
striking
Genius already does code: [http://genius.com/James-somers-using-diff-match-
patch-to-cap...](http://genius.com/James-somers-using-diff-match-patch-to-
capture-revision-history-annotated)

~~~
fizwhiz
I wasn't able to locate an example (weak google foo i guess), so thanks for
providing it. My only mild gripe with this is that the "code" is actually
"static" on which the comments are being applied.

For most code bases, the code is bound to evolve and change, so I wonder what
the version reconciliation model would look like if there has to be constant
syncing between what's on GitHub and what's hosted on genius (how would we
capture multiple versions for example). Moreover, it appears that genius is
great for annotating lines, but doesn't have the same Q&A feel that Omniref
does[1]. I think what would be of real value is having the Q&A hosted
"closest" to the codebase which is why I was thinking about a GitHub plugin.
This in turn automatically has the ability to reconcile any old/deprecated
questions that were relevant when the code was old.

[1]
[https://tctechcrunch2011.files.wordpress.com/2014/12/screen-...](https://tctechcrunch2011.files.wordpress.com/2014/12/screen-
shot-2014-12-31-at-9-42-32-am.png?w=1360&h=452)

~~~
na85
>weak google foo

At risk of being pedantic, it's "fu" as in "Kung fu", which loosely translates
to English as something like "work and effort".

~~~
fizwhiz
Duly noted.

------
tonyhb
Think the chaps at Sourcegraph are already on it. Here's an example:

[https://sourcegraph.com/github.com/golang/go@ac452349e4f40c3...](https://sourcegraph.com/github.com/golang/go@ac452349e4f40c30d50f9922bf2c4592e748ce5e/.tree/src/bytes/bytes.go#selected=3)

------
def_illiterate
This would be an awesome pedagogical tool.

I'm a student and often find myself struggling with pseudocode to the point
that I end up writing it out by hand and annotating it in a similar fashion on
paper.

~~~
fizwhiz
I agree. Answer-hubs like stackoverflow have their own place, as do Git
discussions for PR's. But I'm tempted to say that there's a gap for more
effective collaboration in the "in-between parts" you know, where some new
contributor takes a look at the codebase and says "Huh, why is this written
like this?". Instead of chat/email, the entire conversation history can be
preserved adjacent to the codebase itself without being intrusive.

------
steele
Partially related:
[https://en.wikipedia.org/wiki/Literate_programming](https://en.wikipedia.org/wiki/Literate_programming)
[https://fogus.github.io/marginalia/](https://fogus.github.io/marginalia/)

~~~
e12e
And partially related to the task of understanding/navigating a code-base:

[https://github.com/OpenGrok/OpenGrok](https://github.com/OpenGrok/OpenGrok)

------
perdunov
In an ideal world, this would be pointless because if the code requires
"annotations", it should be rewritten, or annotations may be just a specific
kind of comments in the code itself rendered in a specific way.

But in the real world, I think, the use case for annotations is when _one
group of people_ writes code, and _another group of people_ annotates it
because authors and collaborators can be opinionated, stubborn, lazy, or too
busy, or there may be too much bureaucracy on the project, so it is much more
realistic to just put annotations on some third-party website than to try to
collaborate with the authors to add comments in the code or refactor it.

------
broodbucket
Something like Google Docs comments hanging off the side of the document? It
fits less for the Rap Genius example since the annotations explain the line,
and in code if the line needs explaining then it should have a comment within
the code itself.

I like the idea for discussions, but does the discussion stay there? Would an
individual line get bogged down in "stupid questions" that someone has to
trawl through to find what they want? If it's on by default, would it just be
annoying to those trying to read the code, and if it's off how many people
would go out of their way to turn it on?

It's certainly interesting, anyway.

~~~
fizwhiz
This is what I had in mind (lifted off of the techcrunch article on Omniref):
[https://tctechcrunch2011.files.wordpress.com/2014/12/screen-...](https://tctechcrunch2011.files.wordpress.com/2014/12/screen-
shot-2014-12-31-at-9-42-32-am.png?w=1360&h=452)

It's available if the person browsing the code is actually "interested" in
looking at the conversations around a particular part of the code.

------
allannienhuis
There are a lot of code review tools that might be suitably repurposed for
this sort of thing. Lots of quality/community issue I expect though.

------
simplyluke
So I reached out to them about this a few months back - some of their
engineers have pitched it and done it internally.

Check this out: [http://genius.com/3410852/Genius-engineering-jobs-at-
genius/...](http://genius.com/3410852/Genius-engineering-jobs-at-
genius/Introducing-code-genius)

------
vezzy-fnord
So this would be something like "Literate Programming as a Service", then?

~~~
fizwhiz
I'd never heard of that before, but just checked it[1] out and it looks pretty
cool. I guess the only distinction I'd make is for cases where people have a
bunch of code already written out, and someone comes in and says "Hmm, why was
this written like this?" and the original dev (or some other contributor) can
respond with answers that have votes and the possibility of follow ups.
Basically like an HN discussion board where the highest rated/popular answers
are up top and each comment can have its own children.

[1]
[https://en.wikipedia.org/wiki/Literate_programming#Example](https://en.wikipedia.org/wiki/Literate_programming#Example)

------
misiti3780
I think it is a good idea - one piece of advice, do not make your UI black :)

------
psm42
How about [https://notedcode.com](https://notedcode.com)

------
kbpowell03
i don't wana;turn.to look at yo face.man look atchyo mama man look at the
phaze.

    
    
                                                   by:kole

------
DwayneSamuels
StackOverflow?

------
diminoten
> I think RapGenius (i.e. Genius) is a really powerful way to arrive at a
> crowdsourced understanding of what content is.

I dunno if I agree with that.

