5 ms·
> Poetry does the same by default, using a format like >=1.23.4,<2.0.0. I find this less readable than ^1.23.4, but the effect is the same. What??? I understo
by jimbokun 5mo ago
> Poetry does the same by default, using a format like >=1.23.4,<2.0.0. I find this less readable than ^1.23.4, but the effect is the same.
What???
I understood the first format instantly, but had no idea what the second meant until the author explained it.
- jim33442 5mo agoI saw that ^ so many times in npm and never knew what it meant until now
- saghm 5mo agoI don't know if there's a good source for where this convention started but it's not that uncommon; offhand, both npm[1] and Cargo[2] support that format. [1]: https://docs.npmjs.com/about-semantic-versioning#using-semantic-versioning-to-specify-update-types-your-package-can-accept https://docs.npmjs.com/about-semantic-versioning#using-seman... [2]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#caret-requirements https://doc.rust-lang.org/cargo/reference/specifying-depende...
- skeledrew 5mo agoSame. I found that wild to take in.
- kjmr 5mo agoOnce you know what the ^ means (I always think of “roof”), I do think that one character is easier to read than >=,<
- pie_flavor 5mo agoAnd then you look it up once, and now you know what it means forever. By contrast, the former expression is much wider with more going on, and furthermore you can't skim past it being sure nothing funny is going on because it may or may not be a range compatible with the latter form.
- scubbo 5mo ago> now you know what it means forever Not, in fact, correct. Knowledge only cements itself in the brain when it's regularly referenced. Because `>=` and `<=` borrow well-established concepts well-established, they are both intuitive to people reading them for the first time, and easier to solidify or to re-infer for someone who's forgotten their meaning.
- deathanatos 5mo ago> Knowledge only cements itself in the brain when it's regularly referenced. While true, this is a molehill, not a mountain, of a bar, like "coding once in a while". I'm doing mostly SRE work, and this syntax has no trouble sticking in my head, and I encounter it pretty regularly? (And heck, most of my work these days is in Python, so there I get the >=,< syntax and yearn for the ~mines~ caret, and I still recognize it?) If you're actively developing a codebase, this definitely isn't going to be arcane trivia.
- saghm 5mo agoI'd argue that complaining about using combined "greater than" and "less than" operators instead of the caret is about the same size of molehill as complaining about the usage of it. Seeing either of them in dependencies at my job would be a pretty mundane event that I wouldn't bother trying to do anything about.
- j16sdiz 5mo agoNo. I have look it up years ago, and I don't remember all combination of `=` vs `^` vs `~` across all languages and package managers
- alexanderchr 5mo agoTo make it even more interesting, in npm ^ works differently depending on what version you are on
- saghm 5mo ago