Better HN
topnewbestaskshowjobs
Log inSign up

GrumpySloth

4,901 karma · joined Sep 13, 2020 (6y ago) · 1,641 submissions

Submissions

comment 5y ago · link · parent

It's necessary when you need to debug something, regardless of who wrote the implementation, now it's you're responsibility.

comment 5y ago · link · parent

APT already has a signal handler for SIGWINCH, in order to resize the progress bar. The problem is that after APT finds out about the resize it clears the last line on the screen, but it's a visual line, which is only a part of a semantic line which was wrapped after shrinking the terminal window. APT doesn't know how many visual lines the progress bar takes after being rewrapped by a resize, so it doesn't know how many lines to clear. It could try to compensate by remembering the old width in characters, looking at the new one and calculating what rewrapping would result in, but that would probably not be very reliable across different terminals.

Redrawing everything is annoying from UX point of view, because it breaks copying lines out of the terminal. Instead of getting a bunch of lines separated by line feeds corresponding to semantic lines, the user gets a bunch of lines corresponding to the visual lines in the terminal (so a lot of lines broken, some of them midword), including loads of meaningless whitespace.

I wish the modern terminal was less of an old terminal emulator and more of a GUI for displaying pipelines. So no ncurses-like applications, such as vim, more first-class support for progress bars (instead of the hacks that we have), support for jumping between the lines in scrollback where the user typed in the commands, no possibility of breaking the terminal state (such as what happens when I hit Ctrl+C in the password prompt of openvpn) forcing the user to run "reset", etc. etc.

comment 5y ago · link · parent

APT's progress bar does have issues though. When you shrink the terminal when the progress bar is visible, you're going to have gibberish in the terminal. That's because the terminal commands to move the cursor by lines work on visual lines, not semantic lines, so they aren't invariant under the operation of resizing the terminal window. That's a really rough area of Linux terminals: when you resize a window, the terminal is going to rewrap the lines according to semantic lines (based on line feed characters), so it's clear that all major terminals understand this distinction, but the terminal API doesn't give applications access to moving by semantic lines, so we're left with bugs like these.

I think PowerShell has the concept of progress reporting specially recognized? That sounds like a good idea. It could be used to render a GUI progress bar and leave the pipeline alone, for the objects. That's just my vague idea, since I didn't spend much time with PowerShell.

comment 5y ago · link · parent

No. Vendoring doesn't change the picture in that way in Rust at all. Let's go one by one:

> Obviously you're only protected against new compromises.

Same as in the case of default Rust workflow. Cargo.lock ensures that versions of your dependencies are the same across different machines/devs.

> If the code is already compromised you're screwed (but not worse than using normal downloaded dependencies).

Yes, I generally read the code of my dependencies, so that's fine. Checking all the digests and crypto ever won't protect me from having to check what I use.

> This does make it possible that you miss security updates and other important features.

Again. Same as in normal Rust, thanks to Cargo.lock. But I think that's great, because the flip side of it is: I'm also going to miss all the new bugs. I don't want updates to be something that's happening behind my back. I want to check them and do them at the time of my choosing.

What vendoring brings to the table is the simplest solution to "is the code on crates.io the same as in the upstream repo", because with vendoring I don't care about the upstream repo at all. I only care about the copy of code that I have in my own repo. Going to GitHub and then checking if digests match would be a very roundabout way to do that, and then over the years people discover flaws in the hash functions etc. etc. I don't bother, I choose not to have to wonder about it at all. I don't care about what's on GitHub, I only care about what's in my own repo. And then again, there are issues of disappearing dependencies, which digests do not solve, but vendoring solves in the simplest way possible. Digests (already incorporated by Cargo by default) only solve someone pushing malicious code; vendoring solves the problem wholesale (assuming that you actually read the code).

comment 5y ago · link · parent

I routinely read code of crates I use (which is placed under ~/.cargo if you do not vendor) and of the Rust standard library (which is placed under ~/.rustup). It's usually the fastest way to figure out how something works, since Googling/Stack Overflow will usually result in a lot of related, but not really applicable answers, and some incorrect ones.

As for supply-chain issues, I just vendor my dependencies. Problem solved. Just run cargo vendor and copy stdout to .cargo/config.toml in your project. Done. Now not only you're not vulnerable to someone pushing malicious code to crates.io, but also have one place where all the dependencies of your project have their source code available to read for you. If you archive your project and then want to get back to it after years on another computer which did not have the dependencies installed, you don't need to hunt on the internet for dependencies that don't exist anymore[1]. If you want to work on a project without an Internet connection, all you need is the repo, you don't need to worry if a given computer has all the dependencies installed in the right versions. If crates.io ever goes down, or they take down a crate, you're safe as well. Although it's not the default in Rust, it's very well supported by cargo, if you want to develop in this model.

[1]: Yes, those are my bad experiences with Python dependencies.

comment 5y ago · link · parent

What jcelerier said, but also as for:

> This is true in monomorphized languages like Rust

It's not necessarily true for monomorphized code. Inlining is enabled by monomorphization, but is not required.

You can see it with templates in C++: function template instantiations aren't always inlined. They are instantiated in every TU separately, if they are defined in headers, but then they may be called in this TU just like any other function without inlining. This requires the linker to deduplicate the instantiations later. In another scenario you may declare a function template in a header without the implementation, putting the implementation in a CPP file along with explicit instantiation. In that case the compiler is not able to inline this function in another TU (without LTO).

As for Rust, Rust is not universally monomorphized. The user of generic code in Rust gets to decide whether they want to use monomorphization or vtables, regardless of the ideas of the author of said generic code.

comment 5y ago · link · parent

Joe Armstrong in his talk "The Mess We're In"[1]:

> Robert Virding, who developed Erlang with me, was famed for his comment... I think he only... Singular... The entire stuff he wrote had one comment. In the middle of a pattern-matching compiler was a single line that said "And now for the tricky bit"

[1]: <https://youtu.be/lKXe3HUG2l4?t=645>

comment 5y ago · link · parent

There is a long tradition, especially in England, of distinguishing between Europe (the continent) and the islands of Britain and Ireland. It's very prominent in English literature of past centuries.

comment 5y ago · link · parent

(Not the commenter you replied to.)

That's correct. But neither can you think in sentences in that case, unless your relationships are just calculated means to an end. Whether you want to continue a relationship is not a conclusion of a sentence, but something you know without words, just like you know without words whether you want to eat the dish that's on your plate.

comment 5y ago · link · parent

I don't. I know a friend who doesn't as well. Both of us mainly think through an awareness of some kind of graph structure (non-visual).

But what's more interesting is that through talking with others we've discovered one interesting thing about what it's like for other people to hear a voice in their heads:

In most people's dreams, when someone talks, they can hear the voice, which has a specific pitch, rasp, etc. For me and my friend, in our dreams we can never characterize the voice. We just become aware of the sentence spoken and the time passed (even though in a way it feels immediate), but if we focus, it's clear that we cannot recall any sensation of hearing a voice in any way. It blew our minds off when we realized that other people's dreams are different in such a way.

I can think of sentences. But they are not spoken in my head. There is no voice, which would be male or female etc. And I only do that when the sentences are the goal. They are not the means.

comment 5y ago · link · parent

Same here. I'm curious if it has any correlation to having an internal voice. Do you have an internal voice for your thoughts?

comment 5y ago · link · parent

Anecdotally, my personal website feels faster than normally. Gandi DNS.

comment 5y ago · link · parent

Addendum: just today there are two of those on the front page:

[1]: <https://news.ycombinator.com/item?id=28746549>

[2]: <https://news.ycombinator.com/item?id=28745949>

comment 5y ago · link · parent

It's boring. Every week there is a post with a title of this form. It's as if mindless bots were writing the titles, not creative humans.

comment 5y ago · link · parent

If the array is stack-allocated and the elements are boxed (i.e. heap-allocated) or have destructors, you are still going to need to call the destructors or the free on the elements when the array goes out of scope.

comment 5y ago · link · parent

> In most languages, freeing all all the heap-allocated objects of a big array will take longer than in a language with GC.

Only if elements of the array are separately allocated (boxed) or have destructors.

comment 5y ago · link · parent

Wikpedia links point to <https://encyclopedia.marginalia.nu/> instead, which to my eyes is less readable. The justified text, done with CSS, instead of the LaTeX algorithm, looks wild. The font used for quotations is even worse (very thin).

Wikipedia is perfectly usable without JavaScript and it's one of the nicest sites out there typography-wise, so I'd reconsider this redirection.

comment 5y ago · link · parent

People bring this point up every time C++ is criticized, but no, not all C++ shortcomings come from its age. In fact, most of the shortcomings it is criticized for today are new. The committee just keeps on adding new ones: initialization (mentioned by another reply to my comment), std::optional & std::variant (UB), concepts[1], std::thread (good luck debugging where the std::thread which crashes your program in a destructor came from), std::random_device()() being allowed to return 0 every time (which e.g. won't show up when you compile for your own machine, but will when you cross-compile) and probably many others which I don't remember off the top of my head.

[1]: <https://news.ycombinator.com/item?id=28098153>

But back to the point, my original comment wasn't about C++ being a bad choice. It was about STL. You can use C++ without STL. I pointed to one alternative: abseil.

comment 5y ago · link · parent

STL has a lot of weird pitfalls. There was std::vector<bool>. Here you can see some pitfalls of std::unordered_map: <https://youtu.be/ncHmEUmJZf4?t=2220>. The whole talk is interesting to watch. In the beginning you can also see the puzzling design of std::unordered_map (puzzling because of the number of indirections).

I'd reach for abseil first: <https://abseil.io/>.

comment 5y ago · link · parent

It depends on the category. You can have a category of arrays of ints, but you can also have a category of arrays.

comment 5y ago · link · parent

MPL and CDDL are copyleft licenses as well. It is a feature of GPL.

comment 5y ago · link · parent

This incompatibility is a unique feature of GPL. Wherever it goes, it's incompatible with something (in this case, with itself). You could use MPL or CDDL and, as long as GPL isn't involved, you won't have problems with license compatibility.

However, in the case of the Linux kernel (which "perf" is distributed with) changing the license is not an option --- no CLA and, even if it was practical to ask so many people for permission, many contributors are dead now. So here the only option is using dependencies which are compatible with GPLv2. So maybe we need a new library to replace libbfd, which would be more permissively licensed.

comment 5y ago · link · parent

The "or later" clause is a backdoor. Not wanting backdoors in your license doesn't seem like a bad reason to me.

comment 5y ago · link · parent

In my Emacs config I redefined one of internal Emacs functions which is responsible for creating new windows (panes in more common parlance), which I think is superior, and I'm working more efficiently, rearranging windows less frequently than before (not to mention with other window managers)[1]. That's something I don't get outside of Emacs.

[1]: Efficiency is probably second priority though to getting rid of the annoyance of windows showing up in weird places making everything around hardly legible. Prior to the customization I felt as if I was pair-programming with an angry gremlin who would keep making a mess on my desk. Now I have more peace of mind.

comment 5y ago · link · parent

It wasn't. Without "!" it isn't obvious that you cannot take a:

  let a: Result<u8, u8> = /* whatever *;
  let b = match a {
      Ok(v) => Ok(foo(v)),
      e => e,
  };
and transform it into:

  let a: Result<u8, u8> = /* whatever *;
  let b = a.map(foo);
if "foo" is a macro. When you substitute "foo!" for all the "foo" above, it is obvious.

comment 5y ago · link · parent

Yes, but "->" vs ":", or kinds of brackets are superficial, while method syntax has a specific meaning.

comment 5y ago · link · parent

std::array will instantiate function templates for all used array sizes, lengthen compilation time, and be hard to use across separately-compiled code without putting code into headers. It has its uses, but more often I'd prefer T[N] with bounds-checking, and, in another world, a builtin variably-sized, non-resizable array type; basically a sort of absl::FixedArray[1], but with the semantics of operator[] and at() reversed, so that bounds-checking is the default. Sadly, nothing like that is included in the standard, so won't be a lingua-franca.

[1]: <https://github.com/abseil/abseil-cpp/blob/master/absl/contai...>

comment 5y ago · link · parent

> File.open(path).orReturnErr()

Method syntax is reserved for functions. There are no method syntax macros. Since a return in a function terminates execution of this function, and not its caller, your example would not work.

comment 5y ago · link · parent

Can you escape from a mount namespace? You can escape from a chroot.
1
424344
55