Searching yarn

Twts matching #coding
Sort by: Newest, Oldest, Most Relevant
In-reply-to » Btw @movq you've inspired me to try and have a good 'ol crack at writing a bootloader, stage1 and customer microkernel (µKernel) that will eventually load up a Mu (µ) program and run it! 🤣 I will teach Mu (µ) to have a ./bin/mu -B -o ... -p muos/amd64 ... target.

@prologic@twtxt.net I’d love to take a look at the code. šŸ˜…

I’m kind of curious to know how much Assembly I need vs. How much of a microkernel can I build purely in Mu (µ)? šŸ¤”

Can’t really answer that, because I only made a working kernel for 16-bit real mode yet. That is 99% C, though, only syscall entry points are Assembly. (The OpenWatcom compiler provides C wrappers for triggering software interrupts, which makes things easier.)

But in long mode? No idea yet. šŸ˜… At least changing the page tables will require a tiny little bit of Assembly.

⤋ Read More

Took me nearly all week (in my spare time), but Mu (µ) finally officially support linux/amd64 🄳 I completely refactored the native code backend and borrowed a lot of the structure from another project called wazero (the zero dependency Go WASM runtime/compiler). This is amazing stuff because now Mu (µ) runs in more places natively, as well as running everywhere Go runs via the bytecode VM interpreter šŸ¤ž

⤋ Read More

I’m trying to implement configurable key bindings in tt. Boy, is parsing the key names into tcell.EventKeys a horrible thing. This type consists of three information:

  1. maybe a predefined compound key sequence, like Ctrl+A
  2. maybe some modifiers, such as Shift, Ctrl, etc.
  3. maybe a rune if neither modifiers are present nor a predefined compound key exists

It’s hardcoded usage results in code like this:

func (t *TreeView[T]) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {
    return t.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {
        switch event.Key() {
        case tcell.KeyUp:
            t.moveUp()
        case tcell.KeyDown:
            t.moveDown()
        case tcell.KeyHome:
            t.moveTop()
        case tcell.KeyEnd:
            t.moveBottom()
        case tcell.KeyCtrlE:
            t.moveScrollOffsetDown()
        case tcell.KeyCtrlY:
            t.moveScrollOffsetUp()
        case tcell.KeyTab, tcell.KeyBacktab:
            if t.finished != nil {
                t.finished(event.Key())
            }
        case tcell.KeyRune:
            if event.Modifiers() == tcell.ModNone {
                switch event.Rune() {
                case 'k':
                    t.moveUp()
                case 'j':
                    t.moveDown()
                case 'g':
                    t.moveTop()
                case 'G':
                    t.moveBottom()
                }
            }
        }
    })
}

This data structure is just awful to handle and especially initialize in my opinion. Some compound tcell.Keys are mapped to human-readable names in tcell.KeyNames. However, these names always use - to join modifiers, e.g. resulting in Ctrl-A, whereas tcell.EventKey.Name() produces +-delimited strings, e.g. Ctrl+A. Gnaarf, why this asymmetry!? O_o

I just checked k9s and they’re extending tcell.KeyNames with their own tcell.Key definitions like crazy: https://github.com/derailed/k9s/blob/master/internal/ui/key.go Then, they convert an original tcell.EventKey to tcell.Key: https://github.com/derailed/k9s/blob/b53f3091ca2d9ab963913b0d5e59376aea3f3e51/internal/ui/app.go#L287 This must be used when actually handling keyboard input: https://github.com/derailed/k9s/blob/e55083ba271eed6fc4014674890f70c5ed6c70e0/internal/ui/tree.go#L101

This seems to be much nicer to use. However, I fear this will break eventually. And it’s more fragile in general, because it’s rather easy to forget the conversion or one can get confused whether a certain key at hand is now an original tcell.Key coming from the library or an ā€œextendedā€ one.

I will see if I can find some other programs that provide configurable tcell key bindings.

⤋ Read More

Since I used so much Rust during the holidays, I got totally used to rustfmt. I now use similar tools for Python (black and isort).

What have I been doing all these years?! I never want to format code manually again. šŸ¤£šŸ˜…

⤋ Read More

Vacation: Doing crazy things like C on DOS, lots of Rust, bare-metal assembly code, everything is fine.

Back at work: How the fuck do I move an email in this web mail program? Am I stupid? šŸ˜®ā€šŸ’Ø

⤋ Read More

I came across this on ā€œWhy Is SQLite Coded In Cā€, which I found interesting:

ā€œThere has lately been a lot of interest in ā€œsafeā€ programming languages like Rust or Go in which it is impossible, or is at least difficult, to make common programming errors like memory leaks or array overruns.ā€

If that’s true, then encountering those issues means the programmer is, simply, horrible?

⤋ Read More

Spent most of the long weekend working on a few coding projects… specifically, I pushed some updates for TwtKpr to my test instance before spending some time working on the build process and demo page for my new twtxt-parsing library… which lead me to make some changes to my existing fluent-dom-esm library.

So, nothing actually got finished, but the incremental updates continue…

⤋ Read More
In-reply-to » @lyse A "Hello World" binary is ~372KB in size. I currently have peephole optimization and deac code optimizations in play, and a few other performance related ones, but nothing too fancy. I have a test case that ensures fib(35) doesn't regress too badly as I continue to evolve the language.

@lyse@lyse.isobeef.org It’s actually not nearly as half bad as I really thought it would be. Just having to eventually deal with the ā€œlowering downā€ to machine code / ARM64 assembly in the end once you’ve verified the semantics in the VM.

⤋ Read More
In-reply-to » Nice! 😊 Here are the startup latencies for the simplest Mu (µ) program. println("Hello World"):

@lyse@lyse.isobeef.org A ā€œHello Worldā€ binary is ~372KB in size. I currently have peephole optimization and deac code optimizations in play, and a few other performance related ones, but nothing too fancy. I have a test case that ensures fib(35) doesn’t regress too badly as I continue to evolve the language.

⤋ Read More

Opinion / Question time…

Do you think Mu (µ)’s native compiler and therefore emitted machine code ā€œruntimeā€ (which obviously adds a bit of weight to the resulting binary, and runtime overheads) needs to support ā€œruntime stack tracesā€, or would it be enough to only support that in the bytecode VM interpreter for debuggability / quick feedback loops and instead just rely on flat (no stacktraces) errors in natively built compiled executables?

So in effect:

Stack Traces:

  • Bytecode VM Interpreter: āœ…
  • Native Code Executables: āŒ

⤋ Read More
In-reply-to » @lyse You actually have a Markdown parser/renderer in there? Oh dear. I would have been (well, I am) way too lazy for that. šŸ˜…

@movq@www.uninformativ.de Well, just a very limited subset thereof:

  1. inline and multiline code blocks using single/double/triple backticks (but no code blocks with just indentation)
  2. markdown links using using [text](url)
  3. markdown media links using ![alt](url)

And that’s it. No bold, italics, lists, quotes, headlines, etc.

Just like mentions, plain URLs, markdown links and markdown media URLs are highlighted and available in the URLs View. They’re also colored differently, similarly to code segments.

I definitely should write some documentation and provide screenshots.

⤋ Read More

mu (µ) now has builtin code formatting and linting tools, making µ far more useful and useable as a general purpose programming language. Mu now includes:

  • An interpreter for quick ā€œscriptinogā€
  • A native code compiler for building native executables (Darwin / macOS only for now)
  • A builtin set of developer tools, currently: fmt (-fmt), check (-check) and test (-test).

⤋ Read More

I just fixed another bug in tt where the language hint in multiline markdown code blocks had not been stripped before rendering. It just looked like it was part of the actual code, which was ugly. I now throw it away. Actually, it’s already extracted into the data model for possible future syntax highlighting.

⤋ Read More
In-reply-to » Hmm, mine also resolves a leading tilde in these variables. And if $HOME is not specified it tries to resolve the user's home directory by user.Current().HomeDir. Maybe that's overkill, I have to check the XDG spec.

Ok, the standard library implementation is wonky at best, at least in regards to XDG, because it really doesn’t implement it properly. https://github.com/golang/go/issues/62382 I stick to my own code then. It doesn’t properly support anything else than Linux or Unixes that use XDG, but personally, I don’t care about them anyway. And the cross-platform situation is a giant mess. Unsurprisingly.

⤋ Read More
In-reply-to » @lyse Well, I used SnipMate years ago (until 2012). IIRC, it’s more than just ā€œinsert a bit of text hereā€, it can also jump to the correct next location(s) and stuff like that. Don’t remember why I stopped using it.

@movq@www.uninformativ.de Thanks! I’ll have a look at SnipMate. Currently, I’m (mis)using the abbreviation mechanism to expand a code snippet inplace, e.g.

autocmd FileType go inoreab <buffer> testfunc func Test(t *testing.T) {<CR>}<ESC>k0wwi

or this monstrosity:

autocmd FileType go inoreab <buffer> tabletest for _, tt := range []struct {<CR>    name string<CR><CR><BS>}{<CR>   {<CR>   name: "",<CR><BS>},<CR><BS>} {<CR>  t.Run(tt.name, func(t *testing.T) {<CR><CR>})<CR><BS>}<ESC>9ki<TAB>

But this of course has the disadvantage that I still have to remove the last space or tab to trigger the expansion by hand again. It’s a bit annoying, but better than typing it out by hand.

⤋ Read More
In-reply-to » @lyse Yeah I remember you said some days back that your interest in compilers was rekindled by my work on mu (µ) šŸ˜…

@lyse@lyse.isobeef.org I can tell you this right now, writing assembly / machine code is fucking hard workā„¢ šŸ˜“ I’m sure @movq@www.uninformativ.de can affirm 🤣 And when it all goes to shitā„¢ (which it does often), man is debugging fucking hard as hell! Without debug symbols I can’t use the regular tools like lldb or gdb šŸ˜‚

⤋ Read More
In-reply-to » @lyse Yeah I remember you said some days back that your interest in compilers was rekindled by my work on mu (µ) šŸ˜…

@prologic@twtxt.net Yeah, the parser part is what I typically enjoy. Haven’t really looked into code generation itself.

I’m currently looking at your µ commits from the last few days. Holy cow! :-)

⤋ Read More

Whoo! I fixed one of the hardest bugs in mu (µ) I think I’ve had to figure out. Took me several days in fact to figure it out. The basic problem was, println(1, 2) was bring printed as 1 2 in the bytecode VM and 1 nil when natively compiled to machine code on macOS. In the end it turned out the machine code being generated / emitted meant that the list pointers for the rest... of the variadic arguments was being slot into a register that was being clobbered by the mu_retain and mu_release calls and effectively getting freed up on first use by the RC (reference counting) garbage collector šŸ¤¦ā€ā™‚ļø

⤋ Read More
In-reply-to » Hmmm I need to figure out a way to reduce the no. of lines of code / complexity of the ARM64 native code emitter for mu (µ). It's insane really, it's a whopping ~6k SLOC, the next biggest source file is the compiler at only ~800 SLOC šŸ¤”

@shinyoukai@neko.laidback.moe Nah it’s more like there’s a lot of repeated code, because when you go from source language to intermediate representation to machine code, well you just end up writing a lot of the same patterns over and over again. I need to dedupe this I think.

⤋ Read More
In-reply-to » Hmmm I need to figure out a way to reduce the no. of lines of code / complexity of the ARM64 native code emitter for mu (µ). It's insane really, it's a whopping ~6k SLOC, the next biggest source file is the compiler at only ~800 SLOC šŸ¤”

The compiler technique I’m using here is to not ā€œemitā€ most of the runtime if it’s actually never used in your program, and also dropping dead code in the SSA pass.

⤋ Read More

Hmmm I need to figure out a way to reduce the no. of lines of code / complexity of the ARM64 native code emitter for mu (µ). It’s insane really, it’s a whopping ~6k SLOC, the next biggest source file is the compiler at only ~800 SLOC šŸ¤”

⤋ Read More
In-reply-to » My little toy operating system from last year runs in 16-bit Real Mode (like DOS). Since I’ve recently figured out how to switch to 64-bit Long Mode right after BIOS boot, I now have a little program that performs this switch on my toy OS. It will load and run any x86-64 program, assuming it’s freestanding, a flat binary, and small enough (< 128 KiB code, only uses the first 2 MiB of memory).

@movq@www.uninformativ.de I think I can get binaries even smaller with a bit more work and effort šŸ¤” But yeah still working on the native code generation (at least for macOS targets)

⤋ Read More
In-reply-to » My little toy operating system from last year runs in 16-bit Real Mode (like DOS). Since I’ve recently figured out how to switch to 64-bit Long Mode right after BIOS boot, I now have a little program that performs this switch on my toy OS. It will load and run any x86-64 program, assuming it’s freestanding, a flat binary, and small enough (< 128 KiB code, only uses the first 2 MiB of memory).

@movq@www.uninformativ.de Oh that’s fine, Mu can compile to native code and so far binaries. at least on macOS are in the order of Kb in size šŸ˜‚

⤋ Read More

My little toy operating system from last year runs in 16-bit Real Mode (like DOS). Since I’ve recently figured out how to switch to 64-bit Long Mode right after BIOS boot, I now have a little program that performs this switch on my toy OS. It will load and run any x86-64 program, assuming it’s freestanding, a flat binary, and small enough (< 128 KiB code, only uses the first 2 MiB of memory).

Here I’m running a little C program (compiled using normal GCC, no Watcom trickery):

https://movq.de/v/b27ced6dcb/los86%2D64.mp4

https://movq.de/v/b27ced6dcb/c.png

Next steps could include:

  • Use Rust instead of C for that 64-bit program?
  • Provide interrupt service routines. (At the moment, it just keeps interrupts disabled.)

⤋ Read More
In-reply-to » @movq wow! what is assembler?

@movq@www.uninformativ.de @kiwu@twtxt.net it just so happens to be a happy coincidence that I’m extending mu’s capabilities to now include a native toolchain-free compiler (doesn’t rely on any external gcc/clang or linkers, etc) that lowers the mu source code into an intermediate representation / IR (what @movq@www.uninformativ.de refers to as ā€œthick layers of abstractionsā€ā€¦) and finally to SSA + ARM64 + Mach-O encoder to produce native binary executables (at least for me on my Mac, Linux may some later?) 🤣

⤋ Read More

Got a nice conspiracy theory for you:

https://mastodon.social/@mcc/115670290552252848

Actually wait I just thought about this and realized that the precise timing of the ACTUAL GitHub seed bank, by which I mean the Arctic Code Vault, on 2020-02-02, makes it more or less a perfect snapshot of pre-Copilot GitHub. Also precisely timed before we all got brain damage from COVID. This is the only remaining archive of source code by people with a fully working sense of smell

(Bonus points because the Arctic World Archive is located in Svaldbard and that’s the name of the AI in Stacey Kade’s ā€œCold Eternityā€.)

⤋ Read More

I cleaned up all my of AoC (Advent of Code) 2025 solutions, refactored many of the utilities I had to write as reusable libraries, re-tested Day 1 (but nothing else). here it is if you’re curious! This is written in mu, my own language I built as a self-hosted minimal compiler/vm with very few types and builtins.

https://git.mills.io/prologic/aoc2025

⤋ Read More
In-reply-to » Advent of Code 2025 starts tomorrow. šŸ„³šŸŽ„

Alright, Advent of Code is over:

https://www.uninformativ.de/blog/postings/2025-12-12/0/POSTING-en.html

It’s been quite the time sink, especially with the DOS games on top, but it was fun. 🄳

In case you’re wondering: All puzzles (except for part 2 of day 10) were doable in Python 1 on SuSE Linux 6.4 and ran in a finite time on the Pentium 133. Puzzle 10/2 might have been doable as well if I had better education. 🤣

⤋ Read More

i’ve learned a lot of lessons from writing my notes app, gonna apply this to bbycll and refactor the code to make it way more legible cause my custom templating system is only kind of a giant mess

⤋ Read More
In-reply-to » In case you haven’t seen it yet:

@prologic@twtxt.net Here you go:

(LTT = ā€œLinus Tech Tipsā€, that’s the host.)

LTT: There was a recent thing from a major tech company, where developers were asked to say how many lines of code they wrote – and if it wasn’t enough, they were terminated. And there was someone here that was extremely upset about that approach to measuring productivity, because–

Torvalds: Oh yeah, no, you shouldn’t even be upset. At that point, that’s just incompetence. Anybody who thinks that’s a valid metric is too stupid to work at a tech company.

LTT: You do know who you just said that about, right?

Torvalds: No.

LTT: Oh. Uh, he was a prominent figure in the, uh, improved efficiency of the US government recently.

Torvalds: Oh. Apparently I was spot on.

⤋ Read More
In-reply-to » @prologic Bwahahaha! I tried to establish some form of ā€œconventionā€ for commit messages at work (not exactly what you linked to, though), but it’s a lost cause. šŸ˜‚ Nobody is following any of that. Nobody wants to invest time in good commit messages. People just want to get stuff done.

@lyse@lyse.isobeef.org My theory is that these people simply don’t do ā€œcode archeologyā€. When something breaks, they don’t reach for git log. They simply don’t experience the pain that comes with bad commits / commit messages.

Or is that different in your company? šŸ˜…

⤋ Read More
In-reply-to » @prologic Bwahahaha! I tried to establish some form of ā€œconventionā€ for commit messages at work (not exactly what you linked to, though), but it’s a lost cause. šŸ˜‚ Nobody is following any of that. Nobody wants to invest time in good commit messages. People just want to get stuff done.

@movq@www.uninformativ.de Same. :ā€˜-( I just don’t get how people do code archeology with all their shit messages and huge commits changing a gazillion of different things. I always try to lead by setting good examples, but nofuckingbody is picking up on that. At all. Even when bringing this up every now and then.

⤋ Read More
In-reply-to » AoC Day #1 solution (mu): https://gist.mills.io/prologic/d3c22bcbc22949939b715a850fe63131

I actually can’t progress to day two till I get home 🤣 – I haven’t pushed the code for the mu compiler yet šŸ¤¦ā€ā™‚ļø So no-one can check my work even if they were so kind 🤣

⤋ Read More