Live data from Hacker News

My new Git utility `what-changed-twice` needs a new name

blog.plover.com

61–65 of 65 posts

Re: My new Git utility `what-changed-twice` needs a new name

#61
post #20

When I make Bash aliases or functions for Git functionality, I always name them as `git-something-or-other`. That way they're namespaced in a way that I find pleasant both for tab completion and for easy of memory. I think that should apply to more complex utilities, too. By my usual naming conventions, this one would be `git-repeatedly-changed`.

I usually do that too, but this seemed to me like it's not really a git utility. It's just a filter.

I can see the argument in favor of `git-` also.

But I think I'd prefer `git-changed-twice` to be a wrapper that takes a reflist argument, and runs `git-log --stat reflist | what-changed-twice`.

Re: My new Git utility `what-changed-twice` needs a new name

#63
post #42
post #17

Earlier quoted context omitted.

At the time I started writing the article, the utility was called `analyze-commits`. Hard to think of a worse name than that! By the time I finished writing it I had come up with a less crappy name, but I thought I'd leave the question in the post anyway.

If you’re looking for something descriptive and not clever/catchy, I propose ‘find-repeat-changes’.

What about git n-changed or even git nchanged. I feel like these commands need to be short and not consist of >3 words.

Re: My new Git utility `what-changed-twice` needs a new name

#64
post #60

Earlier quoted context omitted.

Is there any reason for doing so?

It's a pain in the backside to run on Windows, for two reasons. Firstly, Windows doesn't have (by default) a lot of the tools that are preinstalled in most nix environments. Git for Windows ships half a Cygwin distribution (MSYS2) including Bash, Perl, and Tcl. Second, Windows doesn't really have a 'fork' API. Creating a new process on Windows is a heavyweight operation compared to nix. As such, scripts that repeated…

I don't get why everything needs to be a library? Using the OS to invoke things gets you parallelism and isolation for free. When you need to deal with complicated combination of parameters to an API, it doesn't become too different from argument parsing, so you might as well do that instead.

You can still wrap the interface to the executable in a library.

Re: My new Git utility `what-changed-twice` needs a new name

#65

Earlier quoted context omitted.

https://github.com/stlab/adobe_source_libraries/blob/7659244... https://listarchives.boost.org/Archives/boost/2013/01/200366... I gotta say, I don't see the greatness any more than most of the repliers in that Boost thread — it's just two stable_partitions in a row. "[...] Or is there some optimization that gather provides over (stable_)partition? —— Nope. [...]"

The Boost thread starts with an example of how Bjarne replaced a bunch of complicated code with it. It may be just two stable partitions, but “just” is doing a lot of work there. The algorithm becomes obvious once someone has identified it.

The talk: https://www.youtube.com/watch?v=OB-bdWKwXsU&t=52m49s

Sadly the 25-line original code isn't presented; the code that is presented is the 5-line replacement using the STL's `find_if` and `rotate`. Bjarne sketches the idea that those five lines can be further condensed into two lines with the non-STL `gather` algorithm:

    auto dest = std::find_if(v.begin(), v.end(), contains(p));
    stdx::gather(v.begin(), dest, v.end(), [](const auto& elt) { return &elt == &*source; });
But this is overkill — replacing an O(distance(source,dest)) non-allocating rotate with an O(v.size()) potentially-allocating stable_partition — and more importantly it re-complicates the code.

Now, I think part of his point is that `stable_partition` is "simpler" than `gather` only because it's in the STL. If we add `gather` to the STL too and everyone learns what it means, then there's no objection to using `gather` for "simplification" like this: it would be a straightforward simplification in almost the same way that `std::equal_range(first, last, x)` is a straightforward simplification of `std::make_pair(std::lower_bound(first, last, x), std::upper_bound(first, last, x))`.

The "almost" is that actually there is an algorithmic advantage to `std::equal_range`: when you're looking for the upper bound, you don't have to consider any of the elements to the left of the lower bound you already found. You get a (very slight) performance boost by using the combined `equal_range` algorithm. `gather`, on the other hand, has no such advantage; and (as we've seen) has a (very slight) performance disadvantage when compared to the `rotate` that Bjarne's correspondent's code actually required.

We're not talking about replacing 25 lines of bespoke code with 1 line of Boost `gather`; we're talking about replacing 2 lines of STL `stable_partition` with 1 line of Boost `gather`. The former is probably worth it. The latter is not.

Post reply on HN