RSSAmplifier

Blog

Irregularly Scheduled Programming

Recent content on Irregularly Scheduled Programming

jcarroll.com.auRSS feed ↗50 posts

Latest posts

Functions over Idioms - Writing R in Python with rfuns

If you’ve read any of my past posts you know I like to program in several different languages, some of which I like more than others. Sometimes a problem calls for a particular language to be used, and with that comes adjusting one’s brain to thinking in that language and using the appropriate idioms to leverage that language’s features. But what if I don’t want to? I don’t want to The line…

Comparing R's {targets} and dbt for Data Engineering

I’m getting more and more into data engineering these days and having used R for a long time, I’m seeing a lot of problems that look nail-shaped to my R-shaped hammer. The available tools to solve those problems exist for (presumably) very good reasons, so I wanted to take some time to dig into how to use them and compare their workflows to what I would otherwise naively do in R. I…

Schotter Plots in R

Translating things between languages reveals how each language approaches different design trade-offs, and I believe it’s a useful exercise. Having something to translate is the first step. I found a plot I wanted to generate, and some code that reproduced it, so off we go! I don’t recall how I originally found this page (I didn’t keep a note on it, it seems) and this has been sitting on my…

Haskell IS a Great Language for Data Science

I’ve been learning Haskell for a few years now and I am really liking a lot of the features, not least the strong typing and functional approach. I thought it was lacking some of the things I missed from R until I found the dataHaskell project. There have been several attempts recently to enhance R with some strong types, e.g. vapour , typr , using {rlang}’s checks , and even discussions about…

I Vibe Coded an R Package

Learning Japanese means memorizing thousands of characters, some of which look nearly identical. I wanted a way to visualize which kanji are similar to each other, and for once there wasn’t an R package for this, so I built one using Claude Code for $20 and an afternoon’s work. I got a fully-documented package with mocked tests, complete API coverage, caching, and graph visualizations. I won’t…

Counting Digits Quickly

When things run slower than we’d like in R we tend to reach for another, usually compiled, language, and move our code there. What if it “just happened”? What started out as a silly exploration of how to count digits ended up with a race to see which language does it fastest. Maybe some surprises here for some, maybe some bad implementations on my part - let’s find out. I saw some recent activity…

Rotation with Modulo

How well do you know your fundamental operators in different languages? ‘Easy’ examples help to fortify that knowledge, and comparing across languages makes for some neat implementation detail discoveries. I saw this toot from @gregeganSF on Mastodon Post by @gregeganSF @mathstodon.xyz View on Mastodon which says To rotate a j-digit number n by k digits, if n≠10^j-1 there is a simple formula:…

Function Generators vs Partial Application in R

In which I confront the way I read code in different languages, and end up wishing that R had a feature that it doesn’t. This is a bit of a thought-dump as I consider some code - please don’t take it as a criticism of any design choices; the tidyverse team have written magnitudes more code that I have and have certainly considered their approach more than I will. I believe it’s…

Book Review - Pandas Workout

Python seems to be everywhere these days, and I’m really into learning languages, so it should come as no surprise that I’m learning a lot of Python. This post serves as a review of Pandas Workout as well as a ‘first impression’ review of the Pandas approach to data. I am not entirely unfamiliar with Python, but I haven’t really had to do anything serious with a lot of data in the way that I do…

These Languages are Accumulating

I keep saying that the more programming languages you know, the more you will understand all the others you know - I’m now at the point where I want to solve every problem I see in a handful of different languages. They all offer different functionality, and some are certainly more suited to particular problems than others, but there’s a world of difference between two characters and importing…

Polyglot Maxxie and Minnie

Continuing my theme of learning all the languages, I took the opportunity of a programming puzzle to try out the same approach in a handful of different languages to compare how they work. For an upcoming APL’ers meetup the challenge was set as posed at the end of in this post , namely Maxxie and Minnie The maxxie of a number n is the largest number you can achieve by swapping two of its digits…

Monads in R

In this post I describe a useful programming pattern that I implemented, and hopefully provide a gentle introduction to the idea of monads. The motivation for all of this was that I had a {dplyr} pipeline as part of a {shiny} app that queries a database and I wanted to “record” what steps were in that pipeline so that I could offer them as a way to ‘reproduce’ the query. Some of the steps might be…

A Safe Space for Learning How to Make Pull Requests

As October rolls around once more, the term Hacktoberfest might pop across your feeds; an effort aiming to encourage people to contribute to open-source software, particularly if they’re new to that. In this post I’ll describe what I’m offering towards that goal. Hacktoberfest has been running since (I think) 2017 and I’ve participated in at least one year - previously contributors who had the…

In-Place Modifications

In this post I explore some differences between R, python, julia, and APL in terms of mutability, and try to make something that probably shouldn’t exist. I watched this code_report video which describes a leetcode problem ; You are given an integer array nums , an integer k , and an integer multiplier . You need to perform k operations on nums . In each operation: Find the minimum value x in nums…

Side by Side Comparison - Gleam vs R

Gleam vs R I thoroughly dislike ‘hot takes’ comparing programming languages based solely on a “feel” or differential familiarity (“I know this one better therefore it is better) so when I came across a blog post detailing a small learning project written in Gleam I wanted to understand what advantages and disadvantages that language brings to the problem. This post details a side-by-side…

IPv4 Components in APL

At a recent APL-focussed Meetup someone posed a challenge to slice up the components of an IPv4 address with an APL language and it prompted me to learn a bit more about how that works in general and how I could do the processing in APL myself. The person who posed the challenge had approached it themselves using J which I’m only vaguely familiar with, but it gave me an opportunity to learn a bit…

Tidy DataFrames but not Tibbles

A while ago (2019 seems so long ago now) I started working on something I thought was interesting but which never really got any traction. It has potential once more, so it’s about time I wrote up what it does and why I think it’s a useful idea. I’m going to talk about using the {dplyr} package on some data with rows and columns, but we’re not talking about data.frame s or tibble s… Okay, I…

{charcuterie} - What if Strings Were Iterable in R?

I’ve been using a lot of programming languages recently and they all have their quirks, differentiating features, and unique qualities, but one thing most of them have is that they handle strings as a collection of characters. R doesn’t, it has a “character” type which is 0 or more characters, and that’s what we call a “string”, but what if it did have iterable strings? For comparison, here’s some…

Let's Talk About the Weather

A while ago I made some plots I really liked, but I never made a blog post about them. Then the data source stopped working and I couldn’t make them again. Now there’s a new data source, so it’s time for a post about some weather data! Way back in the mid 2010s I was interested in getting my hands on some weather data to answer a question I had. In Australia we have the Bureau of Meteorology (…

Constructing HTML with Functional Functions

I heard that learning Elm is a good way to approach learning Haskell, so I gave it a go and was surprised early on about an approach to writing abstracted HTML. In this post I compare the way that R and Elm generate HTML and the differences between their approaches. I was listening to the Linux Dev Time podcast based on a recommendation and this episode ( episode 100 ) was about “how many…

Digits Dilemma

Another day, another short riddle to be solved with several programming languages! This one is nice because solving it doesn’t need a lot of code, but it uses some interesting aspects of evaluation. I saw this post which isn’t new (it’s from 2022) that poses a nice problem to solve: With the numbers 123456789, make them add up to 100. They must stay in the same order but you can use addition,…

Iterative Square Root

I saw a toot celebrating a short, clean implementation of a square root finding algorithm and wanted to dig a bit deeper into how it works, with a diversion into some APL. This was the toot from Jim Gardner Doubly pleased with myself. Been doing the Tour of Go. Got to the section where you make a square root function, which should return once the calculated value stops changing. Struggled for…

I Patched R to Solve an Exercism Problem

With a serious yak shaving deviation, I have a really short “cheat” solution to one of the featured Exercism problems. It’s been a really insightful journey getting to this point, and as always I’ve learned a lot along the way. The fact that I was able to understand the required changes and propose them is thanks to the open-source nature of programming languages. This all started out innocently…

My First Julia Package - TriangulArt.jl

I’ve tried to get this same image transformation working at least three times now, but I can finally celebrate that it’s working! I’ve been (re-)learning Julia and I still love the language, so it was time to take my learning to the next level and actually build a package. I’ve tried to get this same image transformation working at least three times now, but I can finally…

Making Links a Little Less Hyper

Hyperlinks are great - they add value to a block of text by adding additional links out to more things to read - but they’re a distraction if you’re trying to read an in-depth piece of text and comprehend it linearly. Let’s hack the web! Hyperlinks are great - they add value to a block of text by adding additional links out to more things to read - but they’re a distraction…

Advent of Array Elegance (AoC2023 Day 7)

I’m solving Advent of Code this year using a relaxed criteria compared to last year in that I’m allowing myself to use packages where they’re helpful, rather than strictly base R. Last year I re-solved half of the exercises using Rust which helped me learn a lot about Rust. This year I’m enamored with APL, and I wanted to share a particularly beautiful solution. ⚠⚠⚠⚠⚠ Spoilers ahead for Day 7, in…

Advent of Code 2022

In the lead up to Christmas each year, Advent of Code offers a series of 25 puzzles which start out reasonably simple, but get progressively harder, eventually requiring knowledge of algorithms and dynamic programming techniques. Last year I solved these in (strictly) base R on the day they were released (or as close to as I could). I then (starting Dec 27) went back and re-solved (13 of) them in…

Print Debugging (Now with Icecream!)

Print debugging has its place. Sure, it’s not always the best way to debug something, but it can often be the fastest. In this post I describe a useful way to do this in Rust and how we can get similar behaviour in R. I love the Rust dbg! macro - it wraps a value or expression and prints the result to help debug what’s happening in the middle of some function. If we had some complicated function…

Hooray, Array!

If you’re reading this hoping that I’m done with droning on about array-languages, close the tab… it only gets worse from here. If you thought APL was unreadable, even after my earlier blog posts , again - close button is right there. In this post I try out a brand new stack-based array language and continue to advocate for learning such things. I subscribe to a lot of RSS feeds these days - it’s…

Four Filters for Functional (Programming) Friends

I’m part of a local Functional Programming Meetup group which hosts talks, but also coordinates social meetings where we discuss all sorts of FP-related topics including Haskell and other languages. We’ve started running challenges where we all solve a given problem in a language of our choosing then discuss over drinks how they compare. This month we went with an “easy” problem with a wrinkle -…

Now You're Thinking with Arrays

I keep hearing the assertion that “writing APL/Haskell/etc… makes you think differently” and I kept wondering why I agreed with the statement but at the same time didn’t think too much of it. I believe I’ve figured out that it’s because I happened to have been using Array-aware languages this whole time! It turns out R is an even better language for beginners than I thought. Let’s start with some…

Taking from Infinite Sequences

One thing that has really caught my attention as I learn more programming languages is the idea of generators or infinite sequences of values. Yes, infinite . Coming from R, that seems unlikely, but in at least several other languages, it’s entirely possible thanks to iterators and lazy evaluation. I saw this video which solves a codewars challenge using an infinite list, which references this one…

Pythagorean Triples with Comprehensions

I’ve been learning at least one new programming language per month through Exercism and the #12in23 challenge. I’ve keep saying, every time you learn a new language, you learn something about all the others you know. Plus, once you know \(N\) languages, the \(N+1^{\rm th}\) is significantly easier. This post covers a calculation I came across in Haskell, and how I can now do the same in a lot of…

Wrapping C Code in an R Package

Your collaborator says to you “I have some code I’d like to distribute to people who will probably work in R most of the time. I don’t write R, but I write C. Can you package this up for me?” so you have a few options: re-write the code in R, package up the C code and make it available in R, or say no. I decided to try out the second of these, and this post details how I achieved that. Before we…

Argument Matching Across Languages

With Functional Programming, we write functions which take arguments and do something with or based on those arguments. You might not think there’s much to learn about given that tiny description of “an argument to a function” but the syntax and mechanics of different languages is actually widely variable and intricate. Let’s say I have some function in R that takes three arguments, x , y , and z…

Array Languages: R vs APL

Update : this post was discussed late March 2024 on HackerNews and lobste.rs . I’ve been learning at least one new programming language a month through Exercism which has been really fun and interesting. I frequently say that “every language you learn teaches you something about all the others you know” and with nearly a dozen under my belt so far I’m starting to worry about the combinatorics of…

Reflecting on Macros

I’ve been following the drama of the RustConf Keynote Fiasco (RKNF, per @fasterthanlime ) from a great distance - I’m not involved in that community beyond starting to learn the language. But the controversial topic itself Compile-Time Reflection seemed like something interesting I could learn something about. A good start is usually a Wikipedia page, and I found one called “Reflective…

Hyperlink Annotations in JavaScript and CSS

This might not have been difficult for a seasoned web-dev, but it was reasonably tricky to find a clear solution online (at least it was for me) so here’s how I added the neat domain hints next to all the hyperlinks on my blog. This might not have been difficult for a seasoned web-dev, but it was reasonably tricky to find a clear solution online (at least it was for me) so here’s how I…

Which Plot Was That?

Plotly has a nice way of making click-events available to the calling language, but it doesn’t quite work simply when using subplot() . This isn’t a post about a new feature, but I didn’t quickly find a resource for it so I’ll add my findings to make it easier for the next person. Plotly (as a graphics library) is a JavaScript library that has been ported to R, Python, Julia, and - surprising to…

Polyglot Exploration of Function Overloading

I’ve been working my way through Exercism exercises in a variety of languages because I strongly believe every language you learn something about teaches you about all the others you know, and makes for useful comparisons between what features they offer. I was 1 Learning Me a Haskell for Great Good (there’s a guide/book by that name) and something about Pattern Matching just seemed extremely…

Version Zero Easter Eggs

I’ve just finished reading ‘Version Zero’ by David Yoon. I really enjoyed it. There’s some (javascript) code on some separator pages between some of the chapters that is loosely tied into the plot and general theme of the book. I love solving puzzles, so what was I supposed to do, just leave it at that? Incidentally, I’ve hooked my reading list into my mini blog so my ‘Currently Reading’ list is…

The Most Complex Puzzle I've Ever Solved

Don’t show me puzzles, unless you want to be responsible for me staying up too late solving them. I’m far too easily nerd-sniped . This one was certainly the most complex I’ve ever solved. Quite complicated too, but definitely the most complex (you’ll see). A few days ago a colleague of mine pointed me to this FiveThirtyEight article , which isn’t new (2018), but does feature someone else we both…

Polyglot Sorting

I’ve had the impression lately that everyone is learning Rust and there’s plenty of great material out there to make that easier. {gifski} is perhaps the most well-known example of an R package wrapping a Rust Cargo crate. I don’t really know any system language particularly well, so I figured I’d wade into it and see what it’s like. The big advantages I’ve heard are that it’s more modern than…

Australian Signals Directorate 50c Coin Decryption

Updated: 2022-09-04 I took a very long time to post about the last Australian Signals Directorate (then DSD) decryption , so this time I’ll be a lot more punctual. This article was published today announcing that ASD have collaborated to release a new 50c coin containing a decryption challenge. The new ASD 50c coin That looks like fun! Typing in the letters and numbers from the image certainly…

Lissajous Curve Matrix in Julia

Another ‘small learning project’ for me as I continue to learn Julia. I’ve said many times that small projects with a defined goal are one of the best ways to learn, at least for me. This one was inspired by yet another Reddit post These are at least reminiscent of Lissajous curves but they primarily just looked pretty cool - that animation is very nicely put together. That graphic was made using…

Where for (loop) ARt Thou?

I’ve long been interested in exactly how R works - not quite enough for me to learn all the internals, but I was surprised that I could not find a clear guide towards exactly how vectorization works at the deepest level. Let’s say we want to add two vectors which we’ve defined as x and y x <- c(2, 4, 6) y <- c(1, 3, 2) One way to do this (the verbose, elementwise way) would be to add each pair of…

Codegolf - Lisp Edition

I occasionally like a round of code-golf (e.g. recently ) and I try to solve these with R, but this one gave me some hope that I could make use of a really cool feature I knew about in common lisp. lisp is timeless. https://xkcd.com/297 I have occasionally tinkered with lisp - initially because I learned emacs, but later because it’s really interesting and does teach a lot about quoting .…

Codegolfing Minecraft Lighting

I occasionally like to participate in an odd sport known as ‘code golf’ where the aim is to write some code to achieve a given task using the smallest number of characters. The tradtional way to cheat at golf is to lower your score R isn’t optimised for this in the slightest (why would it be?) and there are other languages which have expanded character sets which are, e.g. BQL , MATL , and 05AB1E…

Adventures in x86 ASM with rx86

I just finished ‘Code: The Hidden Language of Computer Hardware and Software’ by Charles Petzold which was a really well-written (in my opinion) guided journey from flashing a light in morse code through to building a whole computer, and everything needed along the way. The section on encoding instructions for the processor (built up from logic gates) - assembly instructions as a human readable…

Improving a Visualization

I saw this post on Reddit’s r/dataisbeautiful showing this plot of streaming services market share, comparing 2020 to 2021 US Streaming Services Market Share, 2020 vs 2021 and thought it looked like a good candidate for trying out some plot improvement techniques. Yes, that was a reasonably long while ago, this post has taken quite some time to put together. Life. I’ve played with adding images to…