Hacker Newsnew | past | comments | ask | show | jobs | submit | dmlerner's commentslogin

Why not ripgrep?


Why not ugrep?

They are more or less equivalent. One has obscure feature X other has obscure feature Y, one is a bit faster on A, other is a bit faster on B, the defaults are a bit different, and one is written in Rust, the other in C++.

Pick the one you like, or both. I have both on my machine, and tend to use the one that does what I want with the least options. I also use GNU grep when I don't need the speed or features of either ug and rg.


One thing I never liked about ripgrep is that it doesn't have a pager. Yes, it can be configured to use the system-wide ones, but it's an extra step (and every time I have to google how to preserve colors) and on Windows you're SOL unless you install gnu utils or something. The author always refused to fix that.

Ugrep not only has a pager built in, but it also allows searching the results which is super nice! And that feature works on all supported platforms!


Interesting - for me a built-in pager is an antifeature. I don't want to figure out how to leave the utility. Worst of all, pager usually means that sometimes you get more pages and you need to press q to exit, and sometimes not. Annoying. I often type yhe next command right away and the pager means I get stuck, or worse, pager starts doing something in response to my keys (looking at you, `git log`).

Then again I'm on Linux and can always pipe to less if I need to. I'm also not the target audience for ugrep because I've never noticed that grep would be slow. :shrug:


You might appreciate setting `PAGER=cat` in your environment. ;)

Git obeys that value, and I would hope that most other UNIXy terminal apps do too.


Oh, wow, thank you! I must try this.


Some terminal emulators (kitty for sure) support "open last command output in pager". Works great with a pager that can understand ANSI colors - less fussing around with variables and flags to preserve colors in the pager


This is what I do personally:

    $ cat ~/bin/rgp
    #!/bin/sh
    exec rg -p "$@" | less -RFX
Should work just fine. For Windows, you can install `bat` to use a pager if you don't otherwise have one. You don't need GNU utils to have a pager.


hi @burntsushi,

   fan of your tool. like it's speed and defaults.
I use windows : didn't understand what you mean by "install `bat`" to use a pager.

I use cygwin and WSL for my unix needs. I have more and less in cygwin for use in windows.


I referenced bat because I've found that suggesting cygwin sometimes provokes a negative reaction. The GP also mentioned needing to install GNU tooling as if it were a negative.

bat is fancy pager written in Rust. It's on GitHub: https://github.com/sharkdp/bat


I'm sure you know but windows command prompt always came with its inbuilt pager -- more. So, you could always do "dir | more" or "rg -p "%*" | more ". (more is good with colors without flags)


I didn't! I'm not a Windows user. Colors are half the battle, so that's good. Will it only appear if paging is actually needed? That's what the flags to `less` do in my wrapper script above. They are rather critical for this use case.


I don't believe bat is a paper; it's more of a pretty-printer that tends to call less.

Two pallets that should work on Windows are https://github.com/walles/moar (golang) and https://github.com/markbt/streampager (Rust). There might also be a newer one that uses rust, I'm unsure.


I'd recommend ov for Windows users.

https://github.com/noborus/ov

bat on Windows does page, but I believe it's only available on Choco and not winget.


Good find, thanks! I'll check if I prefer it to moar.

As for bat, according to https://github.com/sharkdp/bat#using-bat-on-windows, the Chocolatey package simply installs `less` alongside `bat`. Seems like a good idea, but I haven't tried it.


Ah, thanks for doing the footwork.


For me, it's a lot easier to compile a static binary of a C++ app than a Rust one. Never got that to work. Also nice to have compatibility with all of grep's arguments.


> to compile a static binary

Cargo is one of the main reasons to use Rust of C++. I am pretty sure there is more involved with C++ than this:

   rustup target add x86_64-unknown-linux-musl 
   cargo build --target=x86_64-unknown-linux-musl


From the ugrep README:

For an up-to-date performance comparison of the latest ugrep, please see the ugrep performance benchmarks [at https://github.com/Genivia/ugrep-benchmarks]. Ugrep is faster than GNU grep, Silver Searcher, ack, sift. Ugrep's speed beats ripgrep in most benchmarks.


Does these performance comparison take into account the things BurntSushi (ripgrep author) pointed out in the ripgrep issue link elsewhere ITT? https://github.com/BurntSushi/ripgrep/discussions/2597

Either way, ripgrep is awesome and I’m staying with it.


Agreed - ripgrep is great, and I'm not planning to switch either. The performance improvement is tiny, anyways.


The best practical reason to choose this is its interactive features, like regexp building.


Although being faster in some cases, ripgrep lacks archive search support (no, transparent decompression ignoring the archive structure is not enough) which works great in ugrep.


I assume the grep compatible bit is attractive to some people. Not me, but they exist.


I find myself returning to grep from my default of rg because I'm just too lazy to learn a new regex language. Stuff like word boundaries "\<word\>" or multiple patterns "\(one\|two\)".


That seems like the weirdest take ever: ripgrep uses pretty standard PCRE patterns, which are a lot more common than posix’s bre monstrosity.

To me the regex langage is very much a reason to not use grep.


A bit hyperbolic, no?

If you consider it "the weirdest ever", I'm guessing that I'm probably older than you. I've certainly been using regex long before PCRE became common.

As a vim user I compose 10s if not 100s of regexes a day. It does not use PCRE. Nor does sed, a tool I've been using for decades. Do you also recommend not using these?


I use all of those tools but the inconsistency drives me crazy as it's hard to remember which syntax to use where. Here's how to match the end of a word:

ripgrep, Python, JavaScript, and practically every other non-C language: \b

vim: \>

BSD sed: [[:>:]]

GNU sed, GNU grep: \> or \b

BSD grep: \>, \b, or [[:>:]]

less: depends on the OS it's running on


Did you know that not all of those use the same definition of what a "word" character is? Regex engines differ on the inclusion of things like \p{Join_Control}, \p{Mark} and \p{Connector_Puncuation}. Although in the case of \p{Connector_Punctuation}, regex engines will usually at least include underscore. See: https://github.com/BurntSushi/rebar/blob/f9a4f5c9efda069e798...

And then there's \p{Letter}. It can be spelled in a lot of ways: \pL, \p{L}, \p{Letter}, \p{gc=Letter}, \p{gc:Letter}, \p{LeTtEr}. All equivalent. Very few regex engines support all of them. Several support \p{L} but not \pL. See: https://github.com/BurntSushi/rebar/blob/f9a4f5c9efda069e798...


`pgrep`, or `grep -P`, uses PCRE though, AFAIUI.


ripgrep's regex syntax is pretty similar to grep -E. So if you know grep -E, most of that will transfer over.

Also, \< and \> are in ripgrep 14. Although you usually just want to use the -w/--word-regexp flag.


> Also, \< and \> are in ripgrep 14

Isn't that inconsistent with the way Perl's regex syntax was designed? In Perl's syntax an escaped non-ASCII character is always a literal [^1], and that is guaranteed not to change.

That's nice for beginners because it saves you from having to memorize all the metacharacters. If you are in doubt you on whether something has a special meaning, you just escape it.

[^1]: https://perldoc.perl.org/perlrebackslash#The-backslash


Yes, it's inconsistent with Perl. But there are many things in ripgrep's default regex engine that are inconsistent with Perl, including the fact that all patterns are guaranteed to finish a search in linear time with respect to the haystack. (So no look-around or back-references are supported.) It is a non-goal of ripgrep to be consistent with Perl. Thankfully, if you want that, then you can get pretty close by passing the -P/--pcre2 flag.

With that said, I do like Perl's philosophy here. And it was my philosophy too up until recently. I decided to make an exception for \< and \> given their prevalence.

It was also only relatively recently that I made it possible for superfluous escapes to exist. Prior to ripgrep 14, unrecognized escapes were forbidden:

    $ echo '@' | rg-13.0.0 '\@'
    regex parse error:
        \@
        ^^
    error: unrecognized escape sequence
    $ echo '@' | rg '\@'
    @
I had done it this way to make it possible to add new escape sequences in a semver compatible release. But in reality, if I were to ever add new escape sequences, it use one of the ascii alpha-numeric characters, as Perl does. So I decided it was okay to forever and always give up the ability to make, e.g., `\@` mean something other than just matching a literal `@`.

`\<` and `\>` are forever and always the lone exceptions to this. It is perhaps a trap for beginners, but there are many traps in regexes, and this seemed worth it.

Note that `\b{start}` and `\b{end}` also exist and are aliases for `\<` and `\>`. The more niche `\b{start-half}` and `\b{end-half}` also exist, and those are what are used to implement the -w/--word-regexp flag. (Their semantics match GNU grep's -w/--word-regexp.) For example, `\b-2\b` will not match in `foo -2 bar` since `-` is not a word character and `\b` demands `\w` on one side and `\W` on the other. However, `rg -w -e -2` will match `-2` in `foo -2 bar`:

    $ echo 'foo -2 bar' | rg -w -e '\b-2\b'
    $ echo 'foo -2 bar' | rg -w -e -2
    foo -2 bar


Ok, makes sense. And thanks for the detailed explaination about word boundaries and the hint about the --pcre flag (I hadn't realized it existed).


Fuzzy matching is the main reason I switched to ugrep. This is insanely useful.


Because this is faster?


ripgrep stole the name but doesn’t follow the posix standard.


I initially was going to cancel as well - I don't care that much about the fast shipping, and if you hit the minimum order, you get free shipping anyway. But, it means 3% back instead of 5% on the Amazon visa, so if you spend more than 150/12*50=625/month, prime is negative cost. Especially using it for many groceries, I usually hit that.


Can't live without this. The 10% of the time it doesn't work makes me sad. Super useful from cVim/Vimmium etc, I keep it mapped to 'gh'


In addition to the normal vaccuum insulation layer, it has a layer that does a (constant-temperature) phase change at ~140F. If your drink is hotter than this, energy flows out of the drink, cooling it and liquifying the layer. If you drink is cooler, energy flows into the drink, solidifying the layer.

grep for technogeek [here](https://joeveo.com/pages/the-temperfect-mug)


Just a quick, non-hostile technical nitpick: I don't believe that at any point, energy will actually be flowing back into the drink. If the drink is cooler, the insulator layer will become a significantly worse conductor, preventing heat from flowing outward as well as from the liquid-phase insulator, but thermodynamics/the law of entropy shouldn't really allow for the energy to flow back into the liquid, even when the insulator does re-solidify.


If you open the mug and rapidly cool the drink (eg dropping a few ice cubes in), heat should be flowing back into the drink?

(I mean that's not a crazy notion: if you have any warm mug and fill it with cold stuff, the warm mug will heat up your cold stuff.)

You are right that if you keep your mug closed, there shouldn't be any energy flowing back into your drink.


If you rapidly cool the drink, you're definitely right - energy would flow PCM -> drink. Otherwise, it's semantic if GP is correct. There would be dynamic equilibrium, i.e. flow of thermal energy in both directions, but no true flow from PCM->drink.

The steps would be:

1) Drink > 140, PCM solid

2) energy flows drink -> PCM, drink cools toward 140, PCM liquifies gradually

Then two possibilities:

3a) drink cools to 140-epsilon before PCM liquifies fully

4a) PCM gives energy to drink in dynamic equilibrium, while also losing energy to environment, solidifying

5a) PCM is entirely solid at 140

6a) PCM drops below 140. drink gives energy to PCM and PCM to environment. drink -> PCM thermal conductivity is presumably much higher than PCM -> env, so drink and PCM remain at same temp

OR

3b) PCM liquifies fully before drink hits 140-epsilon

4b) drink and PCM stay at thermal equilibrium (see 6a) while cooling toward 140. energy flows drink -> PCM and PCM -> environment. The former is faster, so the PCM continues liquifying

5b) PCM is entirely liquid at 140. Due to thermal equilibrium, drink is also at 140.

6b) drink stays at 140 while PCM solidifies

7b) see 5a

8b) see 6a


You seem to assume that the PCM encapsulates the drink on all sides. But the cup has a lid, which doesn't have a PCM inside, and which isn't perfectly isolated.

So there will be energy going from the drink to the environment through the lid, which in turn allows energy to flow back from PCM -> drink.


When the "insulator layer" (a phase change material or PCM) is between phases, it can absorb or emit energy without changing temperature.

The drink on the other hand will change temperature as it looses energy.

The drink will lose energy through the lid, leading to a small temperature gradient between the PCM and the drink. This gradient should allow energy to flow back from the PCM into the drink.


Its „Temperfect insulation“ is most likely a PCM i.e. a phase changing material storing heat in a phase transition. It absorbs or releases heat depending on the outer temperature by means of a physical phase transition (not sure if this is really liquid-solid but perhaps a crystal reconfiguration).


Sigh, anywhere I can buy this for my wife and I in Australia? The shipping for 2 cups is $60 USD, and it all totals out to something like $250 AUD which is completely unjustifiable.

Insulated keep cup on display at any cafe is around $15-25 AUD.


You might enjoy the [Aharonov-Bohm effect](https://en.wikipedia.org/wiki/Aharonov%E2%80%93Bohm_effect). Quantum mechanics says we can in fact detect `A`. A similar effect exists for `phi`.


Neat! Any reference you could share for me to read more?


There is a short but sufficient Wikipedia article on it - it is called uncomputation : https://en.wikipedia.org/wiki/Uncomputation?wprov=sfla1

The textbook I used in my quantum computing class dealt with the subject far better, but unfortunately it's not public yet :/


I find this plausible:

..........

> The formula looks at the variables below, and then spits out a "number" for every Googler. Each PA VP gets a % to cut, and as such there is a threshold. Anyone below that threshold gets RIF'd.

Variables are:

1) Location of labor. US Premium Plus was largely impacted versus cheaper areas. 2) Tenure and performance in level. 3) "Runway" of comp. (e.g. base salary vs MRP. eg. .8 of MRP Googlers have a long runway, vs 1.x of MRP Googlers are basically top of band, and 'tenured' with no runway except promo 4) Promo velocity

..........

Taken from https://www.teamblind.com/post/THE-DEFINITIVE-GOOGLE-LAYOFF-...

Disclaimer: Googler, but no particular internal-only information backing my impression of the above


Blind post is no longer there.

Anyways, I didn't understand the acronyms so I decided to feed it to GPT and it definitely made it easier to understand:

Google is using a formula to determine which employees will be laid off (known as RIF: Reduction in Force)

The formula takes into account various factors such as location of labor (with US Premium Plus areas being more heavily impacted), tenure and performance in the current level, "runway" of compensation (the difference between base salary and maximum potential salary), and promo velocity (how quickly the employee has been promoted within the company)

This formula calculates a "number" for each employee based on these factors

Each Product Area Vice President (PA VP) is given a percentage of employees they must lay off

Employees with a score below a certain threshold, determined by the formula, will be laid off


The post is still there


Combine with a blood pressure medicine? Guanfacine is specifically an ADHD treating blood pressure medication.


I'm not the GP, so I don't get to make that call. If they say no that's the end of the story. It's frustrating, but ultimatly just how it is.

There's no possibility of a second opinion either because I'm really damn lucky to even have access to a GP, the waiting list for one is ~3-4 years long right now if you don't already have one.


That's crazy. Where do you live? In Poland I just skipped the insurance system to get ADHD meds and went to a psychiatrist specialising in ADHD privately - $70 for a 20 minute visit seems a bit steep but it's better than waiting years.

Could you possibly do something similar?


No, that's impossible. I live in a Canadian province where the provincial healthcare situation is very, very bad.

There are no private doctors and private psychiatrists are not legally allowed to perscribe. ADHD medication is controlled so only NPs, GPs, and (I think) psychologists are permitted to write a script for it.

Basically there are no options for me except the ones I have already taken, short of moving to a different province thousands of kilometers away.


Can they prescribe non-stimulant ADHD medications? I imagine those are less-strictly regulated.

My previous psychiatrist said he's had some luck with patients on stimulants lowering their stimulant doses and adding a non-stimulant treatment like Strattera, but his patients rarely had success stopping all stimulants and taking only Strattera. That's just one docs opinion, but having been treated for adhd for 15 years, it doesn't surprise me.

So, consider yourself lucky you don't already need stimulants to get by. Some of the newer non-stimulant options may be effective for you, and you won't have to deal with the "druggy" aspect of being on stimulants for work. Stimulants can seriously affect your life, both positively and negatively. You might be able to get things done that you never would have done before - I felt like I was finally able to compete at a normal level when I started - but you might retreat from society at the same time, be less interested in spending time with loved ones or building relationships, and then there's all the short-term side-effects like trouble sleeping or losing interest in eating.

Basically my experience has been a double-edged sword and it's bittersweet. For every way that it's benefited me, ADHD meds negatively affect me in some other way and it's hard to quantify the net balance.


> So, consider yourself lucky you don't already need stimulants to get by.

I wish that were the case, I've been heavily "abusing" Redbull and Claritan-D (non-drowsey with sudafed, I found this helped purely by accident a few years ago) for years just so I can barely function enough to hold down a job. It's probably part of why my blood pressure is so bad in the first place.

I have to put literally all the energy I have into work, by the time 1700 rolls around I have no energy left to give for anything, I just crash. Most nights even getting supper is a huge ordeal, much less anything else.

Non-stimulant drugs might be an viable option, I haven't inquired about that yet, but I intend too.

I apreciate you giving a small window into what the medication has been like for you. How it would affect me and how I'd change on it has been one of my main concerns should I somehow actually get perscribed anything. At this point I'd try anything because the older I get the less sustainable this all becomes.


Medical tourism is an option too, I think. If you visited a doctor in another country, and obtained a prescription, you'd be allowed to bring it with you back to Canada, right?


> you'd be allowed to bring it with you back to Canada, right?

You’d never be able to get a foreign prescription filled in Canada, federal and provincial regulations forbid that. Brining medicine back would be fine, but then you can’t get more without an expensive flight again.

If I lived near the US border I’d just get an American doctor and get prescriptions filled in America, but I’m nowhere even remotely close to the border.


You may need special permits to move scheduled substances across borders. ADHD meds can even be problematic between EU states.


Blow dryer.


How are you not informed in advance? Every job I've had, there's a contract I sign in advance with all terms, and no addendum on day one. I'd think you could refuse to sign an addendum, and even sue for promissory estoppel if they fire you for not signing.


Yes, a lawsuit aimed at a big corporation will be surely at the fingertips of everyone who is forced by circumstances to sign such clauses.

Let's be real, most people will sign whatever is presented to them on day 1 of their new employment because they need money now. They could refuse to sign, in which case they will be shown the door and encouraged to seek opportunities elsewhere.

That in 4 years time they might've won a legal battle they can't afford is little consolation when they won't be able to make rent now.

Nevermind that once they are in a legal battle, they'll have great difficulty being hired again.

Please don't take offense, but the level of disconnect shown on HN from the prospects and struggles of an average person is sometimes staggering.


Depends on state law. In "at will" to work states they can terminate you for anything.


Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: