Live data from Hacker News

Your hex editor should color-code bytes

simonomi.dev

41–50 of 165 posts

Re: Your hex editor should color-code bytes

#41

Everything should try do some basic syntax highlighting IMO. Not too much, or it just becomes a sea of formatting that doesn't help at all. It is surprising how much difference just a little splash of colour can make if it isn't overdone. If possible, always include configuration options for the user though, so those with colour-blindness issues can tweak things to their needs, those who are just fussy can make the o…

As long as you just give people list of settings for colors, they can pick as much color or monochrome as they want.

So by all means "color everything", people have different opinions on what they want colored so give them option

Re: Your hex editor should color-code bytes

#43
post #23

For anyone who regularly has to look at/analyze binary files, i highly recommend ImHex [1]. Its a hex editor built with imgui and has a lot of built in tools. Imo the best feature is the data structure editor. You can write a data type definition similar to C and it overlays it on the hexdump and parses it in a structured way while you type. It also has a node based editor. 1: https://github.com/WerWolv/ImHex

Does it do color highlighting by value of hex bytes, though?

Re: Your hex editor should color-code bytes

#44
post #38

What a bad way to illustrate your point by using such similar looking pastel colours

Ironically, my complaint about the article was that the author apparently only uses typical human vision ranges here, rather than mapping 00..FFh onto an OKlab gradient of hue 0..359° that rewards those few of us with impeccable color fidelity with even better highlighting than most can see :) No doubt there’s value in contentful highlighting but I’d rather just have a straight hue translation on the circle at a fixed luminosity. There’s only 256 hues to discern, after all! And what a pleasure it would be to learn to read hex code by hue alone :D

Re: Your hex editor should color-code bytes

#45
post #39
post #35

Earlier quoted context omitted.

I'd recommend for every developer to get one or more colourblind friends. I have some, and regularly send them screenshots of what I'm working on to get feedback what they can see and what they can read/can't read. They've been absolutely invaluable for making sure their kind of people can't use my apps properly.

8% of the male population has some form of colorblindness (for women it’s around 0.5%). I have deuteranomaly colorblindness. If you search for images on the internet related to that type of colorblindness you’ll find representations of how we see color and how we see the world. It is not a fun condition to have, and leads to lots of problems in my everyday life. This blog post accidentally accentuated that issue, sin…

>1 in 12 men and 1 in 200 women go through the same sorts of experiences, and it’s worth it, if you aren’t color

Not the same, it's a gradient.

Re: Your hex editor should color-code bytes

#46
The first example is “go ahead, try to find the single C0 in these bytes” and then argues one should highlight C0 bytes.

If that’s true, how does the tool know I will be looking for C0 bytes and not for 03, D3, etc? The logical conclusion of that would be that the hex editor should uniquely color code every byte. And following the other examples even that’s not enough.

The proposed solution is to create groups of byte values that each get their unique color. I think that helps, but we can do better: add a search feature. That tells your editor what you are looking for. Once you enter a search string, it can highlight all hits.

Yes, “colorful output in a hexdump is useful for the same reason that syntax highlighting for code is useful”, but do you know what syntax highlighting needs? Knowledge of the expected content of a file. Without that, a hex editor at best can guess at how to color-code stuff.

IMO, if you want to add syntax coloring to a hex editor, give it pluggable syntax coloring and heuristics for deciding which one to use when.

While at it, also let those plugins control where to break lines, whether to show hex at all (why show it at all if a file has a few paragraphs of English text or an array of IEEE doubles?), etc.

Those plug-ins will make errors and sometimes, users will want to see all byte values, so you’ll need a way for the user to override them.

Re: Your hex editor should color-code bytes

#47
post #23

For anyone who regularly has to look at/analyze binary files, i highly recommend ImHex [1]. Its a hex editor built with imgui and has a lot of built in tools. Imo the best feature is the data structure editor. You can write a data type definition similar to C and it overlays it on the hexdump and parses it in a structured way while you type. It also has a node based editor. 1: https://github.com/WerWolv/ImHex

But does it have colors!?!??!

Re: Your hex editor should color-code bytes

#48

Everything should try do some basic syntax highlighting IMO. Not too much, or it just becomes a sea of formatting that doesn't help at all. It is surprising how much difference just a little splash of colour can make if it isn't overdone. If possible, always include configuration options for the user though, so those with colour-blindness issues can tweak things to their needs, those who are just fussy can make the o…

> Everything should try do some basic syntax highlighting IMO.

Interesting idea. So even syntax–highlighting natural language. Grammar highlighting, as it were. Prepositions, verbs, question marks, etc. An LLM could do it. Would it actually improve readability though? Seems likely!

Re: Your hex editor should color-code bytes

#49
post #48

Everything should try do some basic syntax highlighting IMO. Not too much, or it just becomes a sea of formatting that doesn't help at all. It is surprising how much difference just a little splash of colour can make if it isn't overdone. If possible, always include configuration options for the user though, so those with colour-blindness issues can tweak things to their needs, those who are just fussy can make the o…

> Everything should try do some basic syntax highlighting IMO. Interesting idea. So even syntax–highlighting natural language. Grammar highlighting, as it were. Prepositions, verbs, question marks, etc. An LLM could do it. Would it actually improve readability though? Seems likely!

I think that's a good idea, altho you can probably get away with good old NLP to do it.

Re: Your hex editor should color-code bytes

#50
> having more colors makes it possible to recognize more complex patterns

The implicit cost here is that the simple patterns become harder to recognize when every byte is only subtly differently colored. Rather than give everything a different color, I'd rather have the important stuff highlighted.

In the comparisons given, I think hexyl's highlighting scheme is significantly more useful.

Post reply on HN