Feed fabulous-adventures-in-coding Fabulous adventures in coding

Favorite IconFabulous adventures in coding

Link https://ericlippert.com/
Feed http://ericlippert.com/feed
Updated 2024-04-19 14:31
Bean Machine Retrospective, part 9
I wanted to implement concise pattern matching" in Python, a language which unlike C#, F#, Scala, and so on, does not have any pattern matching built in. Logically a pattern is just a predicate: a function which takes a value ... Continue reading
Bean Machine Retrospective, part 8
Before getting into the details of how my combinator-inspired source code transformation system works, I should say first, what is a general overview of the system? and second, why did I build it at all? In my experience, a typical ... Continue reading
Bean Machine Retrospective, part 7
How do we write a compiler in a typical general-purpose line-of-business OO programming language such as Python, C#, Java, and so on? Compilers are programs, so we could make the question more general: how do we write programs? The basic ... Continue reading
The names of birds, part 4
The European starling is a lovely looking bird, though territorial, noisy and aggressive up close. Unfortunately, they are very invasive in North America. Most of the hundreds of millions of European starlings now living in the Americas can be found ... Continue reading
The names of birds, part 3
In the autumn of last year my friend Joan and I went on a little trip up to the Skagit valley north of Seattle to photograph birds of prey; I managed to get a blurry but recognizable shot of this ... Continue reading
The names of birds, part 2
Reader Joel" had an insightful comment on the first part of this series which I thought deserved a short episode of its own. Recall that we proved the theorem if a compositional forest contains a mockingbird then every bird in ... Continue reading
The names of birds, part 1
For the next part in my Bean Machine retrospective to make sense I'll need to make a short digression. In looking back on the almost 20 years I've been blogging, it is surprising to me that I've only briefly alluded ... Continue reading
Bean Machine Retrospective, part 6
Happy New Year all! Last time I briefly described the basic strategy of the Beanstalk compiler: transform the source codeof each queried or observed function (and transitively their callees) into an equivalent program whichpartially evaluatesthe model,accumulating a graphas it goes. ... Continue reading
Bean Machine Retrospective, part 5
Let’s take another look at the “hello world” example and think more carefully about what is actually going on: There’s a lot going on here. Let’s start by clearing up what the returned values of the random variables are. It … Continue reading →
I want toast
I’ll get back to Bean Machine and Beanstalk in the next episode; today, a brief diversion to discuss a general principle of language design and congratulate some of my former colleagues. Back when we were all at Waterloo, a bunch … Continue reading →
Bean Machine Retrospective, part 4
Did I actually build a compiler? Yes and no. Traditionally we think of a compiler as a program which takes as its input the text of a program written in one language (C#, say), and produces as its output an … Continue reading →
Bean Machine Retrospective, part 3
Introducing Beanstalk Last time I introduced Bean Machine Graph, a second implementation of the PPL team’s Bayesian inference algorithm. We can compare and contrast the two implementations: In short, the BMG user experience is comparatively not a great experience for … Continue reading →
Bean Machine Retrospective, part 2
Introducing Bean Machine Graph Bean Machine has many nice properties: I’m not going to go into details of how Bean Machine proper implements inference, at least not at this time. Suffice to say that the implementation of the inference algorithms … Continue reading →
Bean Machine Retrospective, part 1
As I mentioned in the previous episode, the entire Bean Machine team was dissolved; some team members were simply fired, others were absorbed into other teams, and some left the company. In this series I’m going to talk a bit … Continue reading →
A long expected update
It’s been almost two years since my last update here. A lot has happened. I hope you all are continuing to weather the ongoing multiple global pandemics and other anthropogenic crises. Apologies that this is so long; I didn’t have … Continue reading →
Life, part 38
Here we go again! Fellow BASIC enthusiast Jeff “Coding Horror” Atwood, of Stack Overflow and Discourse fame, has started a project to translate the programs in the 1978 classic BASIC Computer Games into more modern languages. I never had a … Continue reading →
Hey now, you’re an all-star
What regular work activity has the highest impact on the organization in the least amount of time and effort? I haven’t done any science on this, but anecdotally it sure feels like recruiting, interviewing and mentoring are all huge impact-per-time … Continue reading →
Backyard birds of Seattle
Since I’m staying home all day due to the ongoing pandemic emergency, I’ve decided to document all the different species of birds that arrive in my yard. I am not a great bird photographer but I am enjoying practicing every … Continue reading →
The VSTO startup sequence
Earlier this week I was looking for an old photo, and while browsing I came across a photo I took of my whiteboard in my office at Microsoft in 2004. Or rather, it was two photos; I’ve crudely stitched them … Continue reading →
Life, part 37
All right, let’s finish this thing off and finally answer the question that I’ve been asking for a while: are there any Life patterns that have unbounded quadratic growth? (Code for this final episode is here.) The answer is yes; … Continue reading →
Life, part 36
This was supposed to be the last episode of this series, but while writing it I discovered a bug in my implementation of Hensel’s QuickLife algorithm. It’s a small defect, easily fixed, but I thought it might be interesting to … Continue reading →
Introducing Bean Machine
The final part of my Life series is still in the works but I need to interrupt that series with some exciting news. The new programming language I have been working on for the last year or so has just … Continue reading →
Life, part 35
Last time we implemented what looked like Gosper’s algorithm and got a disappointing result; though the quadtree data structure is elegant and the recursive algorithm is simple, and even though we memoize every operation, the time performance is on par … Continue reading →
Life, part 34
All right, we have our quad data structure, we know how to get and set individual elements, and we know how to display it. We’ve deduplicated it using memoization. How do we step it forward one tick? (Code for this … Continue reading →
Installing windows
Episode 34 will be delayed again — sorry! — because once again the time I had set aside for writing this weekend got consumed by a real-world task that could not wait. (I will try for Thursday of this week.) … Continue reading →
Implementing a full fence
Episode 34 of my ongoing series will be slightly delayed because I spent the time on the weekend I normally spend writing instead rebuilding one of my backyard fences. I forgot to take a before picture, but believe me, it … Continue reading →
Life, part 33
Last time in this series we learned about the fundamental (and only!) data structure in Gosper’s algorithm: a complete quadtree, where every leaf is either alive or dead and every sub-tree is deduplicated by memoizing the static factory. Suppose we … Continue reading →
Approximate results may vary
Part 33 of my ongoing series is coming but I did not get all the code written that I wanted to this week, so it will be delayed. In the meanwhile: Living in Canada as a child, of course I … Continue reading →
Life, part 32
All right, after that excessively long introduction let’s get into Gosper’s algorithm, also known as “HashLife” for reasons that will become clear quite soon. Since the early days of this series I’ve mostly glossed over the code that does stuff … Continue reading →
Socially distant abbreviated summer vacation
Normally this time of year I would be visiting friends and family in Canada, but obviously that’s impossible right now. Instead we took a long weekend at a rental on Bainbridge Island and strolled around some parks in a socially … Continue reading →
Life, part 31
Today we will finish off our implementation of Hensel’s QuickLife algorithm, rewritten in C#. Code for this episode is here. Last time we saw that adding change tracking is an enormous win, but we still have not got an O(changes) … Continue reading →
Life, part 30
Holy goodness, we are on part 30; I never expected this to go for so long and we have not even gotten to Gosper’s algorithm yet! We will finish up Hensel’s QuickLife algorithm soon I hope. Code for this episode … Continue reading →
Life, part 29
We’ve built the foundation of the QuickLife algorithm; now let’s make it go fast. This is going to be a longer episode than usual because we have a large volume of code to get through to perform a relatively straightforward … Continue reading →
Life, part 28
We now have enough gear to make a naïve “proto-QuickLife” implementation as a test to see (1) does it work at all? and (2) what is the performance compared to our other implementations at various levels of sophistication? Code for … Continue reading →
Life, part 27
We’re continuing with our deep dive into Alan Hensel’s QuickLife algorithm, rewritten in C# with an emphasis on clarity. When last we left off we had the following established: A Quad2 is an immutable wrapper around a ushort A Quad3 … Continue reading →
Life, part 26
Last time on FAIC we saw how we could start with nine 2-quads — a 12×12 grid of cells — and with only a handful of ands, ors and table lookups we could get an 8×8 grid of cells of … Continue reading →
Life, part 25
Let’s crisp up the problem from last episode. The problem for today’s episode is to write a method that takes these nine 2-quads: Computes these sixteen 1-quads: And returns these four 2-quads: Those four 2-quads form a 3-quad; I haven’t … Continue reading →
Life, part 24
When last we left off we had representations for 0-quads — a single bit — 1-quads — four bits in a row — and 2-quads — a wrapper data structure around an unsigned short that could extract single cells or … Continue reading →
Comet NEOWISE
I went out to Shilshole Bay Marina Tuesday night to get a few photos of the comet; it is quite spectacular! If you’re going stargazing this week, bring binoculars, look to the northwest about an hour after sunset, below the … Continue reading →
Life, part 23
This series is getting much longer than I expected, but I’m having a great time, so let’s keep it going. I want to look at two more algorithms; for the next few episodes we’ll look at the brilliant and subtle … Continue reading →
Life, part 22
Code for this episode is here. So far in this series every algorithm we’ve attempted has been either O(cells) or O(changes) in time, and O(cells) in space. Going with a straightforward “big square with dead cells surrounding it” approach tends … Continue reading →
Life, part 21
Last time on FAIC I said that we were done with Stafford’s algorithm, but right after that went up I received a thoughtful email from David Stafford himself; he then introduced me to Michael Abrash and Terje Mathisen, who was … Continue reading →
Life, part 20
In today’s episode I want to again pause for a moment — this time, to verify that our allegedly O(change) implementation of Stafford’s algorithm really does have its performance gated on the number of cells changing in a tick. Here’s … Continue reading →
Life, part 19
Code for this episode is here. Today we can finish off our C# implementation of Stafford’s algorithm. Last time we turned the first pass into a table lookup; it might be a bit harder to optimize the second pass. Let’s … Continue reading →
Life, part 18
Code for this episode is here. A couple episodes back we did a first cut at implementing Stafford’s algorithm using the triplet data structure to store the current and upcoming states of three cells and their living neighbour counts, all … Continue reading →
Life, part 17
Code for this episode is here. We’ll take a short break from getting to our C# version of Stafford’s algorithm; in this episode I want to talk about some improvements to the UI, and also talk about some more fundamental … Continue reading →
Life, part 16
Source code for this episode is here. We are continuing with our project to gradually morph Abrash’s “remember the living neighbour counts” algorithm into Stafford’s algorithm. I’m going to start today by adding two very small bit-twiddling optimizations to the … Continue reading →
Life, part 15
Code for this episode is here. Where were we? I was gradually changing Abrash’s “remember the neighbour counts” into Stafford’s algorithm from an early 1990s optimization contest. In this series I’m going to illustrate the algorithm in C#, and we’ll … Continue reading →
Life, part 14
Source code for this episode is here. Before we get into today’s episode proper, a quick note. I’ve updated the client so that it now supports the ability to load a pattern off disk, execute that pattern, and “reset” back … Continue reading →
Police brutality in Seattle
First off, a brief programming note: now is not the right time to continue with the usual topic of this blog: a lighthearted exploration of algorithmic complexity and optimization. We’ll get back to that at a later date. I have … Continue reading →
123456