Hacker News new | past | comments | ask | show | jobs | submit login
Hound: A Fast Code Search Tool (codeascraft.com)
96 points by caiobegotti on Jan 28, 2015 | hide | past | favorite | 43 comments



I'd be interested in knowing how this compares to the Silver Searcher [0], I'm surprised it wasn't mentioned at all since they're similar.

[0] https://github.com/ggreer/the_silver_searcher


Pretty sure ag searches on-the-fly, whereas Hound builds an index.

Edit: Yup, from previous discussion: https://news.ycombinator.com/item?id=8957565


One big difference is the UI. Silver Searcher is used on the command line whereas Hound is used in a webpage.

Edit: A command line version is also on the way.


I've been using helm-projectile's helm-projectile-ag in emacs (on prelude) a lot lately. It's very nice to have live filtering while you type a query, and the ability to search for symbol at point.

https://tuhdo.github.io/helm-projectile.html


rking's ag.vim provides a UI to Silver Searcher in vim, it is effectively similar to this, plus it's right in your next editor! https://github.com/rking/ag.vim

That said Hound looks like a nice tool. I'm giving it a try.


I was a little confused by the title because thoughtbot has an open sourced tool also named Hound [1].

1: https://houndci.com


Same here. Since they're both dealing with code I think the name confusion is a pretty big deal.


This has basically replaced ack for me. I was dubious of a web -based search tool when Kelly first sent an email about it, but after trying it a couple of times, I abandoned ack. It being linkable is extra icing on the cake for me.


I really feel the burn with simple "find globally" in my IDE... but I won't use this unless it can integrate into an IDE or advanced editor.

Is there a sublime or textmate plugin?


Yes. It's linked in the article.

https://github.com/bgreenlee/SublimeHound


From the article: "…but with a command line version on the way and a Sublime Text plugin already live…"


For another example of a code search service written in Go, see the software powering http://codesearch.debian.net

https://lwn.net/Articles/627609/

https://github.com/Debian/dcs


Looks like the config requires you to specify repo URLs (only GitHub?). Can't seem to get a private repo to work.


If you're experimenting, use `git config --global credential.helper 'store'` to set git to store your credentials in a plain-text file. Then (if you're on GitHub), generate a personal access token (https://help.github.com/articles/creating-an-access-token-fo...), and then use that as the password - once you've entered it once, it should be stored and not prompted for again.

Please remember how insecure this is.


"file:///"-based URLs also appear to work. Clone your private repo and point Hound at your local clone.


I've wanted one of these for Java, that reads my POM file and searches over the dependencies of my project.


Do you mean outside of an IDE, because as the sibling comment notes: both IntelliJ and other inferior editors do this.

If you mean from the command-line, then, yes, it likely take some use of mvn dependency:tree and javap invocations (or unzip for the deps that ship -sources.jar artifacts)


Eclipse does this.


I have been using Google Code Search (https://code.google.com/p/codesearch/) and find it indispensable.


I am maintaining a fork of it at https://github.com/junkblocker/codesearch where I've added some niceties.



It is a pity this didn't get much traction when it was posted! I was loosing some hair trying to deploy OpenGrok and I think I am going to give Hound a try instead.


Well, as far as J2EE apps go, OpenGrok is a breeze to deploy, but it's still a PITA.

OpenGrok indexing is very very slow. It used to take 10+ minutes on my codebase and my machine. When I switched to Russ Cox' codesearch, indexing was so fast that I just put it in my .profile. And I didn't have to run Tomcat on my laptop.

I haven't tried this tool yet, but if it works by the same principles as codesearch I'd expect it to be very fast.


How is hound better than ag [1]?

[1] https://github.com/ggreer/the_silver_searcher


The biggest difference is that Hound uses an inverted index to support regular expression searches. This is a technique borrowed from the original Google Code Search. The details are discussed on Russ Cox's site (http://swtch.com/~rsc/regexp/regexp4.html). With this technique, you can generally avoid even opening the vast majority of the files you are "grepping" (the number obviously depends on the pattern). To give you a sense, I just searched for a particular method name in several repositories totally several 100k of files and the search only had to open and search 9 files.


Thanks for the explanation. I guess I missed the part that said that Hound is indexed search rather than straight file search.


I tried using file based URL's (file:///) but it did not work for me. Is it supposed to work with f ile based URL's ?


I wonder how difficult it would be to write additional frontends to this. A documented API would be huge.


Looks like there isn't any. But after a bit of code spelunking I found this: https://github.com/etsy/Hound/blob/master/src/hound/api/api.... (it basically tells the service how to interact with the outside world using mux - which, as a small aside, one of the more popular http routing packages in Go. But I wander...)

How the frontend interacts with the backend per default can be found here: https://github.com/etsy/Hound/blob/master/pub/assets/js/houn...

So it looks like wiring the default backend onto a custom frontend shouldn't be that difficult. Unless you want extra features ofcourse, because then it seems you need to learn a bit of Go ;)


Is this similar to SourceGraph?


Cool. Seems like a perfect use case for Go. That code is a pleasure to read.


> Before Hound, most engineers used ack or grep to search code,

…meanwhile, programmers used actual code searching tools like GLOBAL, cscope or ctags to "search code".


I use cscope extensively, but it serves a quite different purpose from grep. It's good at jumping to definitions and references for a specific symbol (although C++ support is miserable; AFAIK the other tools you listed are similar), but grep's required if you need more structure/context, if you're searching comments or don't know exactly what something is called, etc.


I've gotten used to GLOBAL. Basically a nicer version of cscope, from my memories of it. Some of that could just be a better emacs mode, though.

It is funny, because I can not deny that there are more powerful ways of doing searches on source code. However, I think there is a beautiful thing about code that is easily greppable.


Yes, that's exactly my point. Use cscope and co for searching code and grep and co for searching text.


Cool alternatives. Also git grep if in a repo, it's quite fast: http://git-scm.com/docs/git-grep

But hey, this has a web interface. Might be useful for documentation or less technical users too. I'll have to try it sometime.



How was this posted again?




Dang, is there any design reason for not listing only a single news for submissions with both http:// and https:// in the URL? I basically posted that again because IMHO the original post didn't get attention that Hound deserved (since it was posted in a shitty hour of the day), but this is a cheap trick to bypass the submit form I know.

EDIT: clarification


The duplicate detector is left weak like that on purpose to allow for reposts of good stories that didn't get significant attention the first time they were posted. This is described in the FAQ: https://news.ycombinator.com/newsfaq.html.

We treated this one as a dupe because it's pretty hard to argue that the previous post didn't get significant attention at 46 points. On the other hand, the interest in this project (including the repost) looks organic and genuine, so as an experiment, we've unburied it and merged yesterday's comments into this thread.


Oh, +1 for merging these cases indeed. Thanks for the info :-)




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: