Live data from Hacker News

Hexyl: A command-line hex viewer

github.com

111–119 of 119 posts

Re: Hexyl: A command-line hex viewer

#111
post #106
post #96

Earlier quoted context omitted.

What's replacing Jemalloc?

The system malloc implementation. Users who want to use jemalloc have to opt in, but doing so is relatively easy (using the jemallocator crate from crates.io).

Why was this done?

Did rust become less dependent on allocator performance, or did system allocators improve enough? IIRC glibc malloc has improved a lot over the last few years, particularly for multithreaded use, but I don't know about windows / macOS.

Re: Hexyl: A command-line hex viewer

#112
post #49
post #40

the author appears to be a true rust master, he wrote quite a few neat programs in rust, very impressive and that actually got me interested in rust lang

Same here, I like small and neat Rust projects like this, the source code is concise and easy to read. He also authors https://github.com/sharkdp/bat , which is also worth to check out.

bat is awesome, I'm using it daily since I found that, better that 'cat'

Re: Hexyl: A command-line hex viewer

#113
post #111
post #106

Earlier quoted context omitted.

The system malloc implementation. Users who want to use jemalloc have to opt in, but doing so is relatively easy (using the jemallocator crate from crates.io).

Why was this done? Did rust become less dependent on allocator performance, or did system allocators improve enough? IIRC glibc malloc has improved a lot over the last few years, particularly for multithreaded use, but I don't know about windows / macOS.

So, long ago, Rust actually had a large, Erlang-like runtime. So jemalloc was used. Over time, we shed more and more of this runtime, but jemalloc stayed. We didn't have a pluggable allocator story, and so we couldn't really remove it without causing a regression for people who do need jemalloc. Additionally, jemalloc was already removed on some platforms for a long time; Windows has been shipping the system allocator for as long as I can remember.

So, now that we have a stable way to let you use jemalloc, the right default for a systems language is to use the system allocator. If jemalloc makes sense for you, you can still use it, but if not, you save a non-significant amount of binary size, which matters to a lot of people. See the parent I originally replied to for an example of a very common response when looking at Rust binary sizes.

It's really more about letting you choose the tradeoff than it is about specific improvements between the allocators.

Re: Hexyl: A command-line hex viewer

#114
post #97

Earlier quoted context omitted.

You may be able to speed things up by using a lookup table instead of branching. (If it's spending a lot of time in Rust's format function you could also use a (or the same) lookup table to convert to hex/dec/oct.)

The format function is going to end up allocating a string for every single byte. That's a huge overhead. Edit: Turns out to be about 22% overhead, see https://github.com/sharkdp/hexyl/pull/23 . Also it was 2 strings per byte, not 1.

I made a little clone for fun and got a bit carried away optimising. Now at about 3x the speed of hexyl 0.3.1:

https://github.com/sjmulder/hxl

Most of the improvement came from not using printf, fputs, and putchar in favour of operating directly on an array for the line that can be fwritten in one call.

Re: Hexyl: A command-line hex viewer

#115
post #6

While reading this my hope was it not being written in JavaScript. I'm not disappointed ;)

Yeah! -- Because prejudice rocks and JavaScript sucks right?

Every problem requires appropriate tools. Why would you use a slow and resource-intensive language for a thing as simple as hex viewing?

Re: Hexyl: A command-line hex viewer

#116

Earlier quoted context omitted.

Me neither. I did use it religiously for a long, long time; then tried without for a week and never went back. It's not like telling the difference between string literals and keywords was ever a major issue for me. I guess it could help short term when learning a new language, but I'm pretty sure it slows down overall progress.

How does it slow down progress?

I find it's a bit like navigating using GPS, once I get there I still have no clue because I was mostly acting on cues.

Slow compiles have the same effect for me, I get pushed out of flow and into reactive mode.

The only way to write good code is to be proactive, and any features that interfere with that process are worse than whatever "problems" they "solve".

Re: Hexyl: A command-line hex viewer

#117
post #39

Earlier quoted context omitted.

I'm struggling to even find the canonical source code for xxd, let alone a way to provide a patch. You could probably email the address in the man page, but that's from 1997 so I wouldn't be too optimistic about getting a response. And even then it's quite likely that the original author considers xxd finished and would be reluctant to accept patches for it anyway. On top of all that the hard part of this work (cross…

Cross-platform terminal coloring was solved in the 1980s with termcap and then terminfo, for every terminal that's even come close to seeing mainstream use and which had colors in the first place. The libraries are part of the ncurses library and are shipped with every OS this stuff would build on to begin with. This also solves the problem of moving the cursor and drawing a screen in general.

The downvotes prove how much HN hates history, I suppose.

Re: Hexyl: A command-line hex viewer

#118
post #39

Earlier quoted context omitted.

Cross-platform terminal coloring was solved in the 1980s with termcap and then terminfo, for every terminal that's even come close to seeing mainstream use and which had colors in the first place. The libraries are part of the ncurses library and are shipped with every OS this stuff would build on to begin with. This also solves the problem of moving the cursor and drawing a screen in general.

termcap/terminfo styling is limited to features like underline, bold and reverse. No coloring, per se.

It's entirely possible termcap and terminfo have been allowing applications to color their output for longer than you've been alive.

Re: Hexyl: A command-line hex viewer

#119
post #39

Earlier quoted context omitted.

Cross-platform terminal coloring was solved in the 1980s with termcap and then terminfo, for every terminal that's even come close to seeing mainstream use and which had colors in the first place. The libraries are part of the ncurses library and are shipped with every OS this stuff would build on to begin with. This also solves the problem of moving the cursor and drawing a screen in general.

Eh, A lot of modern terminal emulators don't seem to bother providing termcap/info entries, or setting their own $TERM variables. In reality, most code just fires off ANSI sequences and hopes for the best. Looking quickly at the source for Hexyl, I think that's what the ansi_term library it uses does. If anything, I've found doing this works better then trying to muck around with ncurses, which often gets actively mi…

ncurses wins once you use terminals beyond xterm.
Post reply on HN