
Hound: A Fast Code Search Tool - caiobegotti
http://codeascraft.com/2015/01/27/announcing-hound-a-lightning-fast-code-search-tool/
======
spain
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](https://github.com/ggreer/the_silver_searcher)

~~~
reledi
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.

~~~
escherize
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](https://tuhdo.github.io/helm-
projectile.html)

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

1: [https://houndci.com](https://houndci.com)

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

------
bucky
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.

------
knodi123
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?

~~~
spdustin
Yes. It's linked in the article.

[https://github.com/bgreenlee/SublimeHound](https://github.com/bgreenlee/SublimeHound)

------
sciurus
For another example of a code search service written in Go, see the software
powering [http://codesearch.debian.net](http://codesearch.debian.net)

[https://lwn.net/Articles/627609/](https://lwn.net/Articles/627609/)

[https://github.com/Debian/dcs](https://github.com/Debian/dcs)

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

~~~
JimmyL
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...](https://help.github.com/articles/creating-an-access-token-for-command-
line-use/)), 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.

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

~~~
mdaniel
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)

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

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

------
caio1982
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.

~~~
4ad
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.

------
quanticle
How is hound better than ag [1]?

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

~~~
kellegous
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](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.

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

------
hatred
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 ?

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

~~~
mindcrash
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....](https://github.com/etsy/Hound/blob/master/src/hound/api/api.go#L155)
(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...](https://github.com/etsy/Hound/blob/master/pub/assets/js/hound.js#L95)

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 ;)

------
weitzj
Is this similar to SourceGraph?

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

------
johncoltrane
> 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".

~~~
comex
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.

~~~
taeric
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.

------
lloydde
[https://news.ycombinator.com/item?id=8955663](https://news.ycombinator.com/item?id=8955663)

~~~
prezjordan
How was this posted again?

~~~
dang
See
[https://news.ycombinator.com/item?id=8961739](https://news.ycombinator.com/item?id=8961739).

------
dang
[https://news.ycombinator.com/item?id=8955663](https://news.ycombinator.com/item?id=8955663)

~~~
caio1982
Dang, is there any design reason for not listing only a single news for
submissions with both [http://](http://) and [https://](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

~~~
dang
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](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.

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

