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?

https://vnil.de/notice/AaqZISi1bhYt3ER7Z2

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?

quote

I don’t necessarily agree with all their points but this line is a nice one.
https://www.youtube.com/watch?v=QLsKAkzSMqE

天下兴亡,匹夫有责。
国家兴亡,肉食者谋之。

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!

Plans?

  • 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 ….

GNU’s (under)documentations:

The best documentation I’ve ever read is this:

man gcc(1)

-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

Midgards Messer “Valhalla”

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.

1
2
3
4
5
6
struct complex {
    int real;       // offset 0 bytes
    int imag;       // offset 4 bytes
};

struct complex array[5] = {....}

Address of array[3].imag is:

addr = array + 3    *  8              +  4
       BASE    index   sizeof(complex)     offset of imag

Effectively:

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]

https://handmade.network/forums/articles/t/7111-using_the_lea_instruction_for_arbitrary_arithmetic

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?


  1. https://en.wikipedia.org/wiki/Jacques_Ellul#On_technique ↩︎

  2. for many languages even you do need such navigations, vim motion already does that, for example ‘]}’ ↩︎

edited 20.04.2024
created 17.10.2023
EOF

[+] 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 <<

[BITS] - the weekly archive -
bits 0x51 - Calender Week 16, 2024 (WIP)
bits 0x50 - Calender Week 16, 2024
bits 0x49 - Calender Week 15, 2024
bits 0x48 - Calender Week 14, 2024
bits 0x47 - Calender Week 13, 2024
bits 0x46 - Calender Week 12, 2024
bits 0x45 - Calender Week 11, 2024
bits 0x44 - Calender Week 10, 2024
bits 0x43 - Calender Week 09, 2024 [VOID]
bits 0x42 - Calender Week 08, 2024 [VA]
bits 0x41 - Calender Week 07, 2024 [VOID]
bits 0x40 - Calender Week 06, 2024 [VOID]
bits 0x39 - Calender Week 05, 2024
bits 0x38 - Calender Week 04, 2024
bits 0x37 - Calender Week 03, 2024
bits 0x36 - Calender Week 02, 2024 [VA]
bits 0x35 - Calender Week 01, 2024
bits 0x34 - Calender Week 52, 2023
bits 0x33 - Calender Week 51, 2023
bits 0x32 - Calender Week 50, 2023 [VOID]
bits 0x31 - Calender Week 49, 2023
bits 0x30 - Calender Week 48, 2023
bits 0x2f - Calender Week 47, 2023
bits 0x2e - Calender Week 46, 2023
bits 0x2d - Calender Week 45, 2023
bits 0x2c - Calender Week 44, 2023
bits 0x2b - Calender Week 43, 2023
bits 0x2a - Calender Week 42, 2023