bits 0x2a - Calender Week 42, 2023
people like dramas more than facts.
Came across this thread: https://www.quora.com/What-line-of-code-changed-the-world-of-programming
There are some good takes and I learned new things, but this question here
What line of code changed the world of programming?
kinda annoyes me, because there is NO SINGLE LINE OF CODE that has ever changed programming. When you ask for misinformation, what do you expect to get?
hacking an elf loader
The other day we were debugging a program where the dynamic loader was not working correctly. I suddenly realized that we can simply look into the memory dump: find the virtual memory maps, find the one of interest, go to gdb, dump the memory within the specified range, then feed the data to hexdump – luckily I identified the magic numbers and the elf header from the dump, then identified the problem.
The roundabout of aethestics
yesterday I randomly clicked into /r/unixporn, which I’ve not been visiting for a very long time.As I scrolled down the trending threads I was constantly thinking “what the fuck is this bullshit and why does it have so many likes?”. Because they seem so counter-productive and they look bad. However there was a time when I was obssessed with “ricing” my desktop envoronment… What changed?
Björk has no time for your sexism bullshit 1994
Men: They can be silly, fat, funny, intelligent, hard-core, sensual, philosophical," says 90s Björk. “But with women they always have to be feminine. Feminine, feminine.
ARM Stage 2 address translation
surves the same purpose (and works in the same way) as the x86 extended page table. Also known as Second Level Address Translation(SLAT).
RISC or CISC? They are the same!
Arm is a RISC that offloads the microcodes to programmers.
x86_64 is CISC that’s internally a RISC but have stock microcodes.
They are all the same.
Terry Davis - The Hardest Question In Programming
Right here is the hardest question in programming: is this too much voodoo for our purposes?
I don’t necessarily agree with all their points but this line is a nice one.
I have never learnt bash
I have been joking that I have to google “how to center a div” every single time. Now the joke as changed (joke still on me). I have to google “bash how to test if a directory exists” every single funcking time. And I never learned the basic syntax by heart, like how you a loop or conditions, or how to properly handle arguments. Or even worse, how to do regular expressions.
neovim plugin: Diffview
This is a nice plugin that let me review diffs before I do a commit, or examine
each single commit in the git log. Now I don’t need to constantly run
git status and
git diff in another terminal.
I hate the ergonomics of my keybindings
Especially I hate the position of ctrl and the meta key given how frequently I use them and the fact that they are always used in a combination. Putting a combination key at the bottom left corner is stupid, you have to tuck either your pinky finger or thumb… Try pressing these on a querty:
- left meta + 123 (switching wm workspace)
- left meta/ctrl + any key in [1,2,3,q,w,e,a,s,d,z,x,c]
- left ctrl + w (leader key for vim split managements)
I don’t really see another solution. In fact there should NOT BE ANY FREQUENTLY USED KEY in the bottom corner at all!
- I want the mouse keys above the thinkpad touchpad to be mapped to ctrl, meta or alt.
I never used right hand for modifier keys…
R-Ctrl, R-Alt, R-Mod, R-Shift : these keys exists and they make keybindings like Ctrl-1 much more comfortable, yet I never trained my muscle memory to use them. Perhaps I need to ….
The best documentation I’ve ever read is this:
-fexpensive-optimizations Perform a number of minor optimizations that are relatively expensive.
Literally, that’s it, no explanation, no elaboration!
“why”” is not part of their vocabulary
you might be asking why? why? why did they do that! just because, if you are in any way familiar with midgards messer you know that “why” is not part of their vocabulary. https://www.youtube.com/watch?v=RAduaJ8ftY8
More x86 magic - use LEA to do arithmetic
LEA instruction is used to effectively get an address from the form like
addr = [BASE + INDEX * SIZE + OFFSET]
For example we have a struct for a complex number, 32 bits int for the real part and 32 bits int for the imaginary part. That makes each complex number 64 bits in size.
Address of array.imag is:
addr = array + 3 * 8 + 4 BASE index sizeof(complex) offset of imag
mov rdi, array_base mov rsi 3 LEA rax, [rdi + rsi*8 + 4]
Not the (black) magic:
‘LEA’ evaluates expressions in the form of [b + i*s + o] efficiently, so we can actually use it to do arithmetic.
ADD RAX, 1
Is equivalent to
LEA RAX, [RAX + 1]
Jacques Ellul on “technique”
Ellul was one of Ted Kaczynski, the Unabomber’s main influences.
The Ellulian concept of technique is briefly defined within the “Notes to Reader” section of The Technological Society (1964). It is “the totality of methods rationally arrived at and having absolute efficiency (for a given stage of development) in every field of human activity.”1
what makes fault resistance, when there is no fault tolerance?
When your program is short and runs fast, it’s “statistically” less likely to be hit by a fault. When your program is sophisticated and has redundancy, it’s inherently(at least designed to be) fault resilient.
The question: is there a dominant factor? What makes fault resistance?
treesitter - is it too much voodo?
A treesitter parses the text buffer and builds a syntax tree at runtime, so that your editor “understands” your code better and therefore makes more sophiscated highlighting and navigation. I’ve used before but soon realized that it didn’t worth it.
First, performance. This thing can be REALLY slow if you are editing a big file, and by “slow” I mean to some extent it even blocks your input, i.e. not fully async. This is not tolerable – any plugin that blocks user input is not tolerable. I’m ok with lsp taking some time to give me a candidate list for completion, but I’m not ok if it blocks my input while trying completion!
Now the second question: does the gain justify the cost? For me it doesn’t. I know you can do (maybe cool) thing with treesitter besides syntax highlighting, for example navigation by code block, but hey, ask yourself how often do you need to e.g. “jump out of this function definition with one key combination” 2? Then is the cooler highlighting worth it? Still no! For me absolutely no. I’m partly colorblind, so sophisticated highlighting is useless if not counter-productive. Even if I wasn’t colorblind, I still don’t think the extended highlighting is any helpful: you need extra brain cells to maintain the color-coded mappings. My two cents are: if you code A FUCKING LOT, you will realize that additional highlighting doesn’t necessarily give you additional productivity. And if you highlight everything, you are effectively highlighting nothing.
And finally, treesitters are in an awkward position next to lsp. Language servers already provide enough information for a good syntax highlighting, then why bother having an additional layer when things already work?
for many languages even you do need such navigations, vim motion already does that, for example ‘]}’ ↩︎
[+] click to leave a comment [+]
the comment system on this blog works via email. The button below will generate a mailto: link based on this page's url and invoke your email client - please edit the comment there! [optional] even better, encrypt the email with my public key - don't modify the subject field - specify a nickname, otherwise your comment will be shown as anonymous - your email address will not be disclosed - you agree that the comment is to be made public. - to take down a comment, send the request via email.>> SEND COMMENT <<