news
Programming Leftovers
-
Andrew Nesbitt ☛ Features everyone should steal from npmx
Whether or not that continues, npmx has turned into a useful catalogue of ideas for anyone building a package registry website, and the whole thing is MIT licensed where the npm registry and website remain closed source, so every feature below comes with a working reference implementation rather than just screenshots. Prior art from other ecosystems is noted where it exists.
-
Tim Bradshaw ☛ Structures of arrays
A while ago, I decided that I’d like to test my intuition that Lisp (specifically implementations of Common Lisp) was not, in fact, bad at floating-point code and that the ease of designing languages in Lisp could make traditional Fortran-style array-bashing numerical code pretty pleasant to write.
I used an intentionally naïve numerical solution to a gravitating many-body system as a benchmark, so I could easily compare Lisp & C versions. The brief result is that the Lisp code is a little slower than C, but not much: Lisp is not, in fact, slow. Who knew?
The point here though, is that I wanted to dress up the array-bashing code so it looked a lot more structured. To do this I wrote a macro which hid what was in fact an array of (for instance) double floats behind a bunch of syntax which made it look like an array of structures. That macro took a couple of hours.
This was fine and pretty simple, but it only dealt with a single type for each conceptual array of objects, there was no inheritance and it was restricted in various other ways. In particular it really was syntactic sugar on a vector: there was no distinct implementational type at all. So I thought well, I could make it more general and nicer.
Big mistake.
-
Chris Jefferson ☛ Too much Discussion of the XOR swap trick
The most common place you might want to swap two variables is right there in a function, with local variables. So let’s write three functions and see what the compiler makes of them. First, a baseline – just return a / b: [...]
-
Perl / Raku
-
Arne Sommer ☛ Tag Division with Raku
This is my response to The Weekly Challenge #369.
-
Arne Sommer ☛ A Bigger Big with Raku
The task can be divided in three cases: [...]
-
-
R / R-Script
-
Rlang ☛ Why Most Time Series Models Fail Before They Start
Many time series models fail before they even begin. Not because the software crashes. Not because the code is wrong. But because the data entering the model violate one of the most important assumptions in time series analysis: stationarity.
This is where many analyses quietly go off the rails. A model is estimated, forecasts are produced, coefficients look serious, and the graphs appear convincing. But the model may be chasing a moving target rather than learning a stable data-generating mechanism.
In this post, we will work with a real macroeconomic series rather than a toy example. The data come from the Consumer Price Index for All Urban Consumers: All Items (CPIAUCSL), published by the U.S. Bureau of Labor Statistics and distributed through FRED. FRED describes CPIAUCSL as a monthly, seasonally adjusted price index and notes that percent changes in the index are commonly used to measure inflation.
-
Rlang ☛ logrittr: A Verbose Pipe Operator for Logging dplyr Pipelines
R’s dplyr pipelines are silent. logrittr fills that gap with %>=%, a drop-in pipe that logs row counts, column counts, added/dropped columns, and timing at every step, with no function masking.
With Fira Code ligatures, %>=% renders as a single wide arrow visually similar to %>% with an underline added, like a subtitle or, say, to read between the lines of a pipeline (what happened).
-
-
Java/Golang
-
Chris Lesiw ☛ Many-Step Sequences in Go
Build scripts are generally lots of linear steps, executed in sequence, which fail if any individual step fails. This is straightforward to express in a shell scripting language: begin with set -e (or the ever-popular “Bash strict mode”), write out your sequence of steps, and execute.
Recently I’ve been working on translating some venerable Bash scripts into my command buffers. Moving from Bash to Go provides some immediate benefits, like type safety, modularity, and a more expressive language with fewer gotchas. But, on a first pass, the code tends to end up in a single mega-function that does everything, start to finish.
-
-
Rust/Oldies
-
Adrian Plazas ☛ Adrien Plazas: Monster World IV: Disassembly and Code Analysis
This winter I was bored and needed something new, so I spent lots of my free time disassembling and analysing Monster World IV for the SEGA Mega Drive. More specifically, I looked at the 2008 Virtual Console revision of the game, which adds an English translation to the original 1994 release.
-
Rust Weekly Updates ☛ This Week In Rust: This Week in Rust 647
Hello and welcome to another issue of This Week in Rust!
-