The alternatives to go iterators (AKA go range-over-func experiment) are all
worse.
The situation I have is: I have a struct that represents a large collection of
large structs, and I have a few reasonable requirements:
Encapsulation: clients of this package should not be able to mess with the
collection; its members are validated and sorted in some way
Iteration: clients of this package need to be able to make a subset of the
collection, hunt through the collection for a specific item, etc. In
general, clients need to be able to loop over the collection.
Performance: the collection and its members are large, but the application
is time and memory sensitive, so I don’t want to copy large slices
Simplicity to consume: clients of this package should not hate me.
We’ll look at some examples of things I could try to meet these requirements,
and see why all of them fall short in some way without using go iterators.
I know it’s 2024, but I just got a debug build of an iPhone app onto an iPhone.
I thought I’d document the process explicitly because, although this process
has been around forever, there is a lot of incomplete and confusing information
on the web about how to actually get an app on a phone. So now that I’m blessed
with the hindsight of seeing “Hello world” on my own little glowing rectangle,
I thought I’d share how I did it. This is the blog post I wish I’d found before
I started worrying about how to do it.
I just fixed a long-standing problem with my iPhone. Beginning about 2 years
ago, I noticed that the quality of plugging the phone in was falling
considerably. Sometimes it couldn’t charge. Sometimes it wouldn’t connect to
the (wired) Apple CarPlay in my Honda. Once I guessed the way home after a
giving a tech talk because my phone died and just wouldn’t charge at all.
But hey, phones are expensive and a little finicky. I figured I had been to
rough plugging and unplugging it, or gotten cheap charger cables that had over
bent the connectors or something, and the contact points had failed. I got a
wireless charger for my desk and my car, and a little Bluetooth-to-3.5mm thing
so that I could get podcasts out of the phone and into the aux jack, and went
on with my life.