• 0 Posts
  • 16 Comments
Joined 1 year ago
cake
Cake day: June 25th, 2023

help-circle

  • I’ve only ever seen two parts of git that could arguably be called unintuitive, and they both got fixes:

    • git reset seems to do 2 unrelated things for some people. Nowadays git restore exists.
    • the inconsistent difference between a..b and a...b commit ranges in various commands. This is admittedly obscure enough that I would have to look up the manual half the time anyway.
    • I suppose we could call the fact that man git foo didn’t used to work unintuitive I guess.

    The tooling to integrate git submodule into normal tree operations could be improved though. But nowadays there’s git subtree for all the people who want to do it wrong but easily.


    The only reason people complain so much about git is that it’s the only VCS that’s actually widely used anymore. All the others have worse problems, but there’s nobody left to complain about them.


  • Unfortunately both of those are used in common English or computer words. The only letter pairs not used are: bq, bx, cf, cj, dx, fq, fx, fz, hx, jb, jc, jf, jg, jq, jv, jx, jz, kq, kz, mx, px, qc, qd, qg, qh, qj, qk, ql, qm, qn, qp, qq, qr, qt, qv, qx, qy, qz, sx, tx, vb, vc, vf, vj, vm, vq, vw, vx, wq, wx, xj, zx.

    Personally I have mappings based on <CR>, and press it twice to get a real newline.



  • Speed is far from the only thing that matters in terminal emulators though. Correctness is critical.

    The only terminals in which I have any confidence of correctness are xterm and pangoterm. And I suppose technically the BEL-for-ST extension is incorrect even there, but we have to live with that and a workaround is available.

    A lot of terminal emulators end up hard-coding a handful of common sequences, and fail to correctly ignore sequences they don’t implement. And worse, many go on to implement sequences that cannot be correctly handled.

    One simple example that usually fails: \e!!F. More nasty, however, are the ones that ignore intermediaries and execute some unrelated command instead.

    I can’t be bothered to pick apart specific terminals anymore. Most don’t even know what an IR is.


  • Even logging can sometimes be enough to hide the heisgenbug.

    Logging to a file descriptor can sometimes be avoided by logging to memory (which for crash-safety includes the possibility of an mmap’ed file, since the kernel will just take care of them as long as the whole system doesn’t go down). But logging from every thread to a single section of memory can also be problematic (even without mutexes, atomics can be expensive and certainly have side-effects) - sometimes you need a separate per-thread log, and combine in the log-reader tool.



  • I haven’t managed to break into the JS-adjacent ecosystem, but tooling around Typescript is definitely a major part of the problem:

    • following a basic tutorial somehow ended up spending multiple seconds just to transpile and run “Hello, World!”.
    • there are at least 3 different ways of specifying the files and settings you want to use, and some of them will cause others to be ignored entirely, even though it looks like they should be used.
    • embracing duck typing means many common type errors simply cannot be caught. Also that means dynamic type checks are impossible, even though JS itself supports them (admittedly with oddities, e.g. with string vs String).
    • there are at least 3 incompatible ways to define and use a “module”, and it’s not clear what’s actually useful or intended to be used, or what the outputs are supposed to be for different environments.

    At this point I’m seriously considering writing my own sanelanguage-to-JS transpiler or using some other one (maybe Haxe? but I’m not sure its object model allows full performance tweaking), because I’ve written literally dozens of other languages without this kind of pain.

    WASM has its own problems (we shouldn’t be quick to call asm.js obsolete … also, C’s object model is not what people think it is) but that’s another story.


    At this point, I’d be happy with some basic code reuse. Have a “generalized fibonacci” module taking 3 inputs, and call it 3 ways: from a web browser on the client side, as a web browser request to server (which is running nodejs), or as a nodejs command-line program. Transpiling one of the callers should not force the others to be transpiled, but if multiple of the callers need to be transpiled at once, it should not typecheck the library internals multiple times. I should also be able to choose whether to produce a “dynamic” library (which can be recompiled later without recompiling the dependencies) or a “static” one (only output a single merged file), and whether to minify.

    I’m not sure the TS ecosystem is competent enough to deal with this.




  • Two of the most expensive things a shell does are call fork and call execve for an external program. pwd is a builtin (at least for bash) but the former still applies. $PWD exists even if you don’t want that shortening; just like your backticks be sure to quote it once so it doesn’t get expanded when assigning to PS1.

    In general, for most things you might want to do, you can arrange for variables to be set ahead of time and simply expanded at use time, rather than recalculating them every time. For example, you can hook cd/pushd/popd to get an actually-fast git prompt. Rather than var=$(some_function) you should have some_function output directly to a variable (possibly hard-coded - REPLY is semi-common; you can move the value later); printf -v is often useful. Indirection should almost always be avoided (unless you do the indirect-unset bash-specific hack or don’t have any locals) due to shadowing problems (you have to hard-code variable name assumptions anyway so you might as well be explicit).


  • That doesn’t seem sensible. Moving the cursor will confuse bash and you can get the same effect by just omitting the last \n.

    Note that bash 5.0, but not earlier or later versions, is buggy with multiline prompts even if they’re correct.

    Your colors should use 39 (or 49) for reset.

    Avoid doing external commands in subshells when there’s a perfectly good prompt-expansion string that works.

    You seem to be generating several unnecessary blank lines, though I haven’t analyzed them in depth; remember that doing them conditionally is an option, like I do:

    #PS1 built up incrementally before this, including things like setting TTY title for appropriate terminals
    PS0='vvv \D{%F %T%z}\n'
    PS1='^^^ \D{%F %T%z}\n'"$PS1"
    prompt-command-exit-nonzero()
    {
        # TODO map signal names and <sysexits.h> and 126/127 errors?
        # (128 also appears in some weird job-control cases; there are also
        # numerous cases where $? is not in $PIPESTATUS)
        # This has to come first since $? will be invalidated.
        # It's also one of the few cases where `*` is non-buggy for an array.
        local e=$? pipestatus="${PIPESTATUS[*]}"
        # Fixup newline. Note that interactive shells specifically use stderr
        # for the prompt, not stdin, stdout, or /dev/tty
        printf '\e[93;41m%%\e[39;49m%'"$((COLUMNS-1))"'s\r' >&2
        # if e or any pipestatus is nonzero
        if [[ -n "${e/0}${pipestatus//[ 0]}" ]]
        then
            if [[ "$pipestatus" != "$e" ]]
            then
                local pipestatus_no_SIGPIPE="${pipestatus//141 /}"
                local color=41
                if [[ -z "${pipestatus_no_SIGPIPE//[ 0]}" ]]
                then
                    color=43
                fi
                printf '\e[%smexit_status: %s (%s)\e[49m\n' "$color" "$e" "${pipestatus// / | }" >&2
            else
                printf '\e[41mexit_status: %s\e[49m\n' "$e" >&2
            fi
        fi
    }
    PROMPT_COMMAND='prompt-command-exit-nonzero'
    
    

  • o11c@programming.devtoProgrammer Humor@programming.devBorrow Checker
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    2
    ·
    1 year ago

    What you are missing, of course, is the Rc<Refcell<T>> that you have to stick everywhere to make a nontrivial Rust program. It’s like monads in Haskell, parentheses in lisp, verbosity in Java, or warnings in C - they’re the magic words you have to incant correctly to make things work in their weird paradigms.