
Ack 2.0 has been released - petdance
http://perlbuzz.com/2013/04/ack-20-has-been-released.html
======
saidajigumi
Anyone have a sense of how the new Ack 2.0 compares to The Silver Searcher[1]
(aka Ag)? I've been using TSS for some time now and it's been completely
awesome in both performance and functionality compared to Ack v1.

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

~~~
cpeterso
I had never heard of The Silver Searcher. Thanks! A test search of a huge
codebase (Firefox) took 38 seconds with ack, but only 17 with ag! After my
page cache had been warmed up, ack then took 10 seconds and ag only took 3.
That said, I am using ack 1.96, not ack 2.0.

    
    
      $ brew uninstall ack

~~~
petdance
It's OK to have two similar tools in your toolbox. When you need the --output
option, for example, you use ack. When you want crazy speed, you use ag.

You don't have to choose one over the other. That's why I changed the name
from "betterthangrep.com" to "beyondgrep.com". There's no need to have a
ranking of "I use this over that."

~~~
__david__
Ah, you Perl guys and your "there's more than one way to do it". :-)
Disclaimer: I'm a Perl guy and I agree.

------
akavlie
ack has been an indispensable tool in my workflow for a few years now. I use
it several times a day to search code bases... most of the time, not even
taking advantage of regexes or all of its many abilities. Just a basic keyword
search is usually enough; the output looks great.

The feature I've wanted the most is the local project-specific .ackrc ability.
I have some projects where I need to be able to ignore specific files/dirs; I
think this feature will address that need.

~~~
cpleppert
I usually just open up sublime on a codebase to do some quick searches, you
can jump straight to the file and see the results in context.

~~~
ajross
Editor integrations fail badly with big codebases though. I don't use sublime
text, but I can't imagine getting it to index, say, the entire kernel (or the
/frameworks subtree of an Android build, etc...) faster than a recursive grep
will return.

That said, I don't use ack. I've tried it a few times and it looks great and
works well, but honestly this particular task turns out not to be one where I
demand polish and features. Really, all I want is grep.

~~~
n0mad01
me too, i've tried ack several times but i'm not stuck to it because i've
always been able to find anything i was searching for with, tataaa : simple
grep and locate.

------
gyepi
Ack is wonderful example of tool use evolution. Before ack, I used grep to
find stuff, but each use would frequently require additional options to
exclude certain types of files, then coupled with a pipe to filter other
stuff, etc, etc. After ack, everything is much simpler; just specify what you
want. It has replaced most of my grep invocations. Honestly, if you work on
the command line and use grep, you owe it to yourself to try ack. You
(probably) won't look back.

------
oinksoft
Vim users, don't forget the essential ack.vim:
<http://www.vim.org/scripts/script.php?script_id=2572>

~~~
a3n
Vim users, don't forget the included vimgrep. It greps your file. But the nice
thing is, it puts the results in the quickfix window (where your compiler
errors go, for example).

I keep a project log file in restructured text. My entry headers look like
this:

    
    
      2013.03.17 Sunday, Set up base box
      ==================================
    

When you filter that file with rst2html, your output file can have a table of
contents, but not your source file where you probably spend more time.

Use vimgrep to find all your headers:

    
    
      :vimgrep /^20[0-9][0-9]/gj %
    

Nothing happens, but the result is in the quickfix window.

    
    
      :copen
    

And now you have a second window with entries like the following:

    
    
      log.rst|1559 col 1| 2013.03.17 Sunday, Set up base box
      log.rst|1624 col 1| 2013.03.14 Thursday, configured widgets
    

In the quickfix window, enter on any line and it brings you back to the main
window, at that location.

    
    
      :help vimgrep
      :help quickfix
      :help copen
      :help cc
      :help cn

------
Kototama
Ack is a nice tool. I wrote a blog post about how to use it for ClojureScript
within Emacs: [http://inclojurewetrust.blogspot.de/2013/01/searching-in-
clo...](http://inclojurewetrust.blogspot.de/2013/01/searching-in-clojure-and-
clojurescript.html)

~~~
petdance
Excellent. I've added it to the to-do list of articles to put on
beyondgrep.com

<https://github.com/petdance/beyondgrep/issues/12>

------
clord
We have a really big C++ codebase at work and I find codesearch[1] to be the
best way to search through the code, although the UX is terrible compared to
Ack/Ag. Another problem is that it's written in go; so hard to get builds for
the AIX PPC machines. Faster than everything though -- running a complex regex
against 2-3 million SLOC and getting an answer within a second is certainly
worth something.

[1]: <http://code.google.com/p/codesearch/>

~~~
wiml
There's also cscope, which is ancient as the hills but still quite handy for
navigating a codebase you're not completely familiar with.

------
kevinburke
Sadly this change broke every script I had which followed the old instructions
for putting ack on a box:

    
    
        curl http://betterthangrep.com/ack-standalone > ~/bin/ack && chmod 0755 !#:3
    

Now gives a Nginx 302 text/html page. Yes, yes, I should have done curl -L,
but those are the instructions they had pasted on the box.

In addition just changing the hostname

    
    
        curl http://beyondgrep.com/ack-standalone
    

just gives a 404.

~~~
petdance
I put in a redirect from <http://betterthangrep.com/ack-standalone> to the new
location, but it's temporary. I never intended for anyone to use that command
line as ad hoc API, nor did I realize that people were scripting against it.
:-/

So, sorry I broke it, and, I can't promise that URLs are going to stay where
they are unless I explicitly say that I am promising that.

------
Groxx
Sweet. I'm a complete ack convert - `ack 'some str' --no-haml` (which, in
rails project roots, will ignore specific build folders because of my .ackrc
file) is just so much easier and more readable than the grep equivalent, it's
hard to go back.

------
jamesseattle
I couldn't do my job without ack. We have a code base with millions of lines
of C/C++ and tons of PHP. I use ack every day to find code and files. I've
been looking forward to 2.0 for a long time. Will try to help melt his server
right now :)

------
lazyjones
I stopped using ack because it opens the same files several times (strace it
to see for yourself - I've seen version 1.94 open the same file 17 times) and
has problematic performance on our a little higher latency setup (Xen + FC
storage). ag does everything I need and has no such issues...

------
omaranto
I haven't used either one, but from reading the descriptions it sounds like ag
has fewer features, for examples it doesn't have the --output option to tailor
how results of matches are presented. On the other hand, it sounds like it
should be faster.

------
nimrody
Can someone explain how Ack is better than "git grep"? Assuming, of course,
you use git to manage your code.

I find "git grep" as fast as Ack and very flexible.

~~~
dmpk2k
There is a large world beyond source code. Surely you've done some system
administration or looked in logs?

~~~
petdance
I'd suggest that for most cases that are not source code that you stick with
grep.

~~~
dmpk2k
I'd suggest that for most of my cases that are not source code that I'll stick
with ack.

------
eliben
If you prefer Python and don't want to have Perl around just for the sake of
'ack', check out 'pss' - a similar tool written in pure Python:
<https://bitbucket.org/eliben/pss>

[sorry for the plug, but it's definitely relevant to the discussion]

~~~
philh
Is it common these days not to have perl installed? I assumed it was still
standard on UNIX systems.

I count 308 perl scripts in my /usr/bin.

~~~
eliben
Actually my initial motivation for developing pss was Windows. I had to use
Windows at work at the time, and installing Perl just for the sake of ack was
pain. ack also needs an additional module from CPAN (for console coloring), so
double pain.

Python, OTOH, is always one of the first I install on every machine that
doesn't have it :) pss requires no installation, no additional modules, just
Python.

