Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ruby's Object.new in C (omniref.com)
59 points by montanalow on Oct 23, 2014 | hide | past | favorite | 14 comments


Whoa, this is potentially amazing.

I always mean to dig into some popular Ruby gems or the Ruby core and read the code so I can improve my style.

But reading other peoples' code is tough - you can usually figure out what they're doing, but not necessarily why. This could change that.

It's like Genius (neé RapGenius) for code. That's a very good thing.


For layout purposes, have you seen Docco[1] based on Rocco[2]? Coffeescript uses this[3] and the documentation looks very similar. The longform comments are a style choice in this case, as these packages just pull comments from the code.

Literate style code[4] is another example of comments being a primary actor in programming.

If having long comments inline is a problem, most text editors could hypothetically be extended to have automatically collapsed/collapsible comments after the first line.

[1]: http://jashkenas.github.io/docco/

[2]: http://rtomayko.github.io/rocco/rocco.html

[3]: http://coffeescript.org/documentation/docs/coffee-script.htm...

[4]: https://raw.githubusercontent.com/jashkenas/journo/master/jo...


Whoa, thanks! I hadn't seen any of those. Those all produce some really nice output.

Ultimately, I think the two can and should coexist. The benefit (and, I guess, potential drawback) of the OmniRef/RapGenius approach is that it allows the whole world to comment on code (and perhaps ask questions as well) versus generators like Docco/Rocco that (of course) can only display comments in the code that are provided by the code's maintainers.

Genius.com has a feature where they have verified contributors - for example, Genius/GZA from Wu-Tang sometimes explains his own lyrics on there. Those comments are displayed much like everybody elses' comments but are given special visual prominence because they're assumed to be authoritative.

OmniRef could do something like that too - longform inline comments could be displayed on the sidebar (ala http://coffeescript.org/documentation/docs/coffee-script.htm...) as a part of the stream of comments, and given special precedence.


We actually do give project members the ability to claim their code and make "verified" annotations -- we're just not doing the greatest job of surfacing that right now.

I'll add that to our to-do list. Thanks!


Agreed. Annotated code with long-form explanations on the side (instead of annoying comments which clutter up the code itself) is a huge help to aiding my understanding. I hope one day that IDEs will incorporate a code commenting system with clickable 'overview comments' which expand into broader side bar descriptions, making the code shorter and more readable yet at the same time better documented.


Which IDE do you use? We've been considering building extensions to common IDE's to allow teams to annotate code like this.


I think something like a built-in 'back' function for previously visited annotations would be very useful instead of having to press back on the browser. Perhaps even a whole listing of annotations that you visited before.

Either way, I would like to agree with JohnBooty in that this has amazing potential. Great work!


I strongly dislike this 'Didn't find what you needed?' modal popping up whenever I mouse away from the site. Please stop it, or use a cookie to check if I've already closed the window.


Sorry, that's a bug. I'll make it less obtrusive.


Basic C question. In the rb_class_new_instance function, isn't "VALUE obj" a local variable and therefor should not be returned?


Would love to have questions like this on Omniref for other code readers. VALUE is in fact a pointer, ie a raw integer, which is pass by value in C, so it's fine to return.


The line numbers are messed up in latest Chrome OSX.


Do you have a local copy of inconsolata installed? When people have reported code line numbering problems in the past, it's been because they're (unknowingly) using a local font with a messed-up line height.


Do you happen to have an old version of Inconsolata font installed? In this case, chrome and firefox both prefer the font on disk to the google webfont specified in the css, which causes a display bug.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: