8 ms·
Hound: A Fast Code Search Tool
- bucky 12y agoThis 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 12y agoI 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?
- benaiah 12y agoI wonder how difficult it would be to write additional frontends to this. A documented API would be huge.
- mindcrash 12y agoLooks 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.go#L155 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/hound.js#L95 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 ;)
- prezjordan 12y agoLooks like the config requires you to specify repo URLs (only GitHub?). Can't seem to get a private repo to work.
- JimmyL 12y agoIf 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-for-command-line-use/ 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.
- mikenj 12y ago"file:///"-based URLs also appear to work. Clone your private repo and point Hound at your local clone.
- quanticle 12y agoHow is hound better than ag [1]? [1] https://github.com/ggreer/the_silver_searcher https://github.com/ggreer/the_silver_searcher
- kellegous 12y agoThe 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 12y agoThanks for the explanation. I guess I missed the part that said that Hound is indexed search rather than straight file search.
- lloydde 12y agohttps://news.ycombinator.com/item?id=8955663 https://news.ycombinator.com/item?id=8955663
- prezjordan 12y agoHow was this posted again?
- dang 12y agoSee https://news.ycombinator.com/item?id=8961739 https://news.ycombinator.com/item?id=8961739.
- PaulHoule 12y agoI've wanted one of these for Java, that reads my POM file and searches over the dependencies of my project.
- BetaCygni 12y agoEclipse does this.
- mdaniel 12y agoDo 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)
- spain 12y agoI'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
- zellyn 12y agoPretty sure ag searches on-the-fly, whereas Hound builds an index. Edit: Yup, from previous discussion: https://news.ycombinator.com/item?id=8957565 https://news.ycombinator.com/item?id=8957565
- reledi 12y agoOne 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.
- bullfightonmars 12y agorking'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 https://github.com/rking/ag.vim That said Hound looks like a nice tool. I'm giving it a try.
- escherize 12y agoI'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
- caio1982 12y agoIt 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 12y agoWell, 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.
- reledi 12y agoI 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 12y agoSame here. Since they're both dealing with code I think the name confusion is a pretty big deal.
- weitzj 12y agoIs this similar to SourceGraph?
- dang 12y agohttps://news.ycombinator.com/item?id=8955663 https://news.ycombinator.com/item?id=8955663
- caio1982 12y agoDang, 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 12y agoThe 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 12y agoOh, +1 for merging these cases indeed. Thanks for the info :-)
- blt 12y agoCool. Seems like a perfect use case for Go. That code is a pleasure to read.
- stephenmm 12y agoI have been using Google Code Search (https://code.google.com/p/codesearch/ https://code.google.com/p/codesearch/) and find it indispensable.
- mdaniel 12y agoEvidently so does Hound: https://github.com/etsy/Hound/tree/master/src/code.google.com/p/codesearch https://github.com/etsy/Hound/tree/master/src/code.google.co...
- junkblocker 12y agoI am maintaining a fork of it at https://github.com/junkblocker/codesearch https://github.com/junkblocker/codesearch where I've added some niceties.
- johncoltrane 12y ago> 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".
- lstamour 12y agoCool alternatives. Also git grep if in a repo, it's quite fast: http://git-scm.com/docs/git-grep 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.
- comex 12y agoI 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.
- johncoltrane 12y agoYes, that's exactly my point. Use cscope and co for searching code and grep and co for searching text.
- taeric 12y agoI'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.
- hatred 12y agoI 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 ?
- sciurus 12y agoFor 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