news
Programming Leftovers
-
Sebastian ☛ a neat trick i found for reusing physical memory
i found a neat trick which lets you take advantage of CoW to duplicate memory without allocating anything upfront. maybe some people already know about this, but i just discovered it and i think it's cool (and i kinda wish it was easier to take advantage of this with higher-level stdlib functions)
start by creating a memory-backed file descriptor and mmaping it (error handling omitted): [...]
-
Sandor Dargo ☛ C++26: Reducing undefined behaviour
Nowadays, safety is in the focus of C++. Whether it’s at committee meetings, conference talks, or hallway discussions, the topic keeps coming up. C++26 made some big steps forward in this area, and one recurring theme is the reduction of cases leading to undefined behaviour.
With the words of one of the presented proposals, “undefined behaviour has all but unbounded potential for bad program behaviour, including security leaks, data corruption, deadlocks, and so on”. The simple act of violating a precondition can silently turn a perfectly correct-looking program into one that exhibits any of these.
In today’s article, we look at how and where C++26 addresses this. A couple of these changes we have already covered on this blog, but they are worth reiterating in this context. And there is one important change we haven’t talked about yet. Let’s start with that.
-
Max Bernstein ☛ The inliner is yielding benefits for ZJIT
We recently enabled a really cool feature in ZJIT that makes it feel like a Real Compiler™: the inliner! We’ll write more about it soon. In this post, we’ll talk about one excellent concrete benefit we are already seeing and how it optimizes blocks in pretty much every Ruby program.
I’ll start off with a refresher on how blocks work in the Ruby interpreter, then show you how ZJIT understands and optimizes that bytecode, and then show you the impact of the inliner.
-
Den Odell ☛ Your SPA Is Leaking Memory. Soak Test It
Memory leaks are a constant battle for backend teams. A server stays up for weeks, responding to requests the whole time, and if any part of the code running on it has a memory leak, even a small one, that server will eventually run out of memory and crash or restart. So how do these teams know their services won’t end up like this? They soak test them.
In a soak test, a team points a script at their server and has it send fake traffic for hours at a time, sometimes thousands of requests a minute. These tests are often automated to run overnight, while the developers are away, and they compare the service’s memory at the end against the baseline from the start. If the memory climbed while the test ran, there’s a leak somewhere in the code, so the test fails and the team has to find it and fix it before the service goes live.
-
Carl Svensson ☛ User Interfaces of the Demo Scene
Ahh, the demo scene - a digital art subculture, a motley gang of creative nerds, and a favourite pastime of mine. So much amazing art, music and code has been produced by sceners, and anyone who comes into contact with the scene might start to wonder exactly how - apart from hours of dedicated grind, of course.
The scene has a long and storied tradition of building its own tools. Sometimes from scratch, sometimes by stealing ideas or even code from existing offerings. In a combination of teenage inexperience, old habits, a penchant for experimenting and a desire to make things look cool, this has resulted in some rather peculiar user interfaces.
A few of them are presented below. Most of them are for the Amiga, but several other platforms are represented as well.
-
Andrew Nesbitt ☛ Why npm Dependency Trees Are So Big
Every major release of Rails sets off a wave of releases across the rest of the gem ecosystem. An application that tries to upgrade runs bundle update rails and Bundler refuses, because some gem in the tree only allows activesupport up to the previous major. The error names the gem, an issue gets filed on its tracker, and a maintainer who had nothing to do with the Rails release widens a version range and ships. Multiply that across every gem with a Rails constraint and the upgrade arrives as dozens of small releases from maintainers who mostly don’t know each other, each responding to errors their own users are hitting.
-
Adam Ruka ☛ Functional programming from first principles, part 1 – motivation
Functional programming is considered one of the four major programming language paradigms. The typical classification divides all programming languages into either imperative or declarative. Imperative languages can be further subdivided into procedural (examples of which are: C, Go, and Rust) and object-oriented (examples: Smalltalk, C++, and Java), while declarative languages can be subdivided into logical (examples of which are: Prolog and Rocq), and functional (examples: Haskell, Elm, and Idris).
In this article series, we will focus on that last group – functional programming languages: their purpose, design, and how they are different from other kinds of languages. We will explore all these topics through the lens of creating a brand-new functional programming language from scratch, and seeing how the constraints of functional programming shape its design.
-
Dirk Eddelbuettel ☛ Dirk Eddelbuettel: RcppDate 0.0.7: New Upstream
RcppDate ships Hinnant to enable use from R packages. This header-only modern C++ library has been in pretty wide-spread use for a while now, and adds to C++11, C++14 and C++17 what is (with minor modifications) the ‘date’ library in C++20. The RcppDate package
This release syncs with upstream release 3.0.5 made yesterday. We also made two routine updates to the continuous integration since the last release a good year ago.
-
Python
-
Adam Johnson ☛ Python: fix TypeError: NotImplemented should not be used in a boolean context
NotImplemented isn’t False, None, or empty, so like most objects, it’s truthy by default. That means not NotImplemented evaluates to False, and that False becomes the (wrong) result of our != comparison. This “worked” only by accident: NotImplemented is meant to be returned from a comparison method, to tell Python “try something else”, not to be evaluated as a bool itself.
The warning was added in Python 3.9, per the release note: [...]
-
-
Java/Golang
-
Major Hayden ☛ Mount virtual media on Supermicro IPMI with less java
It’s been a while since I rented a dedicated server for my own personal infrastructure, but with the prices I’ve seen lately on cloud and virtual infrastructure, getting my own server seemed like a better detal.
I prefer to do my own custom installation of Fedora GNU/Linux on my servers and this meant another deep dive into the world of Supermicro’s IPMI interface, horribly old versions of Java, and lots of frustration.
With some help from Claude, I found a better way to mount virtual media! ✨
-
Redowan Delowar ☛ Accepted proposal: Go examples with any signature
Go’s proposal to allow examples with any signature was accepted on July 8. Today, an example must look like func ExampleXxx(). go/doc skips the function as soon as it sees a parameter or result. The example doesn’t appear in go doc or on pkg.go.dev.
-