news
Programming Leftovers
-
WerWolv ☛ Adding Stack Traces to C++ Exceptions
Compared to languages like Python or Java, C++ does not provide built-in support for stack traces in exceptions. This can make debugging somewhat difficult when all you end up having is a crash log stating what(): bad optional access. With some linker ticks and a bit of code, it is possible though to add cleaner stack traces to C++ exceptions, including standard library ones.
-
University of Toronto ☛ Tiny Go and Rust programs appear to start equally fast (on some machines)
I've already spoiled the answer, which is that on the machine I care about in this case, any difference in startup time between a 'hello world' program in Rust and Go is down in the noise. Perhaps there is a ten or twenty microsecond difference in timing, but perhaps not and it's an artifact of scheduling, CPU caches, physical memory layout, and other random variations you experience in anything on a normal Unix system. A 'hello world' program written in pure C is typically faster than both the Rust and the Go programs by a visible amount of microseconds, but hyperfine also says it has a higher variation in timing.
-
Corsix ☛ A simplified model of Fil-C
I've seen lots of chatter about Fil-C recently, which pitches itself as a memory safe implementation of C/C++. You can read the gritty details of how this is achieved, but for people coming across it for the first time, I think there is value in showing a simplified version, as once you've understood the simplified version it becomes a smaller mental step to then understand the production-quality version.
-
Perl / Raku
-
Perl ☛ Happy sharing
These are all good, proven tools. But they have something in common: they're about storage. You put data in, you get data out. They don't give you a queue that consumers can block on. They don't give you a pub/sub channel, a ring buffer, a semaphore, a priority heap, or a lock-free MPMC algorithm. They don't do atomic counters or futex-based blocking with timeouts.
That's the gap the Data::*::Shared family fills - fourteen Perl modules that give you proper, typed, concurrent data structures backed by mmap. Not better storage - concurrent data structures that happen to live in shared memory. Queues, hash maps, pub/sub, stacks, ring buffers, heaps, graphs, sync primitives - the works. All written in XS/C, all designed to work across fork()'d processes with zero serialization overhead.
Let me walk you through what's in the box.
-
Perl ☛ Faster UTF-8 Validation
It turned out that this shift-based DFA approach was quite popular a few years ago. Several implementations appeared in different programming languages and even in some RDBMs. However, I couldn’t find any reusable code, so I decided to implement it as a header-only C library, updating a UTF-8 validator I originally wrote in 2017.
-
-
R / R-Script
-
Rlang ☛ Fun pictures with ggplot2 and scico packages
I took the code from the toot mentioned above, modified it, and used it to have a little fun creating graphics that look like paintings with imperfections around the edges, among other things.
All in all, I think it’s a good way to test color palettes.
When you get higher dot per inch images, it can be really cool.
-