Day 33: Discipline

Recently an online discussion about film vs. digital photography got me thinking. I absolutely love digital photography, and would never consider going back to film. Sure, it’s really tough to match the richness of color of Kodachrome 64, or the detail and subtle gradation of 4×5 black and white film, but to me, those are not the most important things when creating art. Those considerations are more like a measure of craftmanship than critical elements for conveying an idea.

However, I am so grateful that I grew up in the age of film photography because of the discipline it instilled in me. Every time you pressed the shutter button, you were spending money. Period. Contrast that to today, where images cost nothing: take a bunch of bad shots, who cares? Click the little trash can icon, and they’re gone. Doesn’t cost a cent.

If you were a poor, struggling student, as I was at the time, buying film was a good chunk of what was left of your money after paying for rent, food, and other essentials. So if I saw something interesting to photograph, I didn’t fire away, taking several exposures from a few different angles in the hope that one would be what I needed. Instead, I composed the image in the viewfinder, looking at it from various angles, and through this process learned to recognize what was important for the final image. Most of the time I walked away without taking the shot, because on further reflection, it didn’t seem worth it.

What if I had had lots of money to spend? I believe that I would not have developed the visual discipline that I have today, as there would never have been a need to limit what I shot. Without that discipline, I don’t believe that I would have become as good a photographer. Even today, with all my digital equipment, I still shoot as though every exposure means something.

In general, scarcity forces one to become disciplined. For example, when you grow up in an environment where food is in short supply, you learn not to waste anything, and to only eat enough to keep going. Back in the early days of computing, when both disk storage and RAM were expensive, you coded in a way to ensure that your program would fit into memory, and would require as little space as possible when written to disk. That parsimonious approach resulted in the “640K Ought to be Enough for Anyone” quote that Bill Gates never said, but keeps getting repeated anyway.

There’s something to be said for learning how to get through tough times. It’s a delicate balance, though – too much scarcity can damage you physically and/or psychologically. My mom grew up as one of six kids in a family during the Great Depression, and it definitely left its mark on her. She wasn’t a full-blown hoarder, but she definitely had a hard time throwing things away – “you never know when you might need it!” was her refrain. And we were not allowed to be fussy about the food we were served at mealtimes: you had to eat every bit on your plate before you could leave the table. That experience has had an effect on me, as I really hate to throw food out. Maybe it’s my mom’s voice still echoing in my mind.

Day 32: Caterpillar Update

Last week I wrote about the experience of finding over 30 caterpillar eggs at once, when typically I only find a few. So I thought I’d post an update on how they are doing.

A few days old

As far as I can tell, all of the eggs hatched. It’s hard to say for sure because in the two days after the initial finding, I found 5 more eggs, and then shortly after that, two baby caterpillars, like the ones in the photo above. So honestly I’ve lost count. Suffice to say that there are many, many caterpillars crawling around and eating like crazy!

Second Instar caterpillar among its smaller siblings.

When they’re this small, they are mostly black with a band of white around their middle. This is actually a form of camouflage, as it makes them look a bit like bird poop. Yes, bird poop mimicry is actually a thing! They keep eating and growing until they need to shed their skin to get larger. They look a little different in this next phase, or instar, besides the obvious part of being bigger.

I keep them in a plastic container until they reach the third instar, at which point I move them to a bigger enclosure where I can provide more food for them. It’s important to keep them contained, because they do like to wander!

Last night I moved a lot of them to the larger container, but there were a few that had wandered away from the food, and were just hanging out motionless. Usually if you place a bit of food in front of them, they crawl on top and start eating, but not these caterpillars – they weren’t interested.

In the morning, though, I checked in on these stragglers, and saw this:

Leaving the old skin behind

The dark, crumpled-up bit on the left is the old skin from its previous instar. The new, much bigger third instar caterpillar emerged by attaching the back section of its body to the surface with some silk, splitting the skin at the head, and then crawling forward, leaving the old skin behind. A short while later it definitely was interested in the sprig of parsley I placed in front of it, so once it was aboard, I transferred that sprig and its passenger to the larger enclosure. There they’ll continue to eat and poop for a few days, until an internal trigger tells them it’s time to move on…

Day 31: Using etcd As a Mediator

etcd is a database originally developed by CoreOS, and is most famously used as the database at the heart of Kubernetes. It is a distributed key-value store, which in itself is not all that remarkable. The thing about etcd that makes it so attractive is the ability to watch a key for changes.

Other key/value stores, such as Redis, have implemented a similar feature, and may work just as well for you. I’ve been using etcd for years, and it’s worked well for me, so I’ve never had a reason to try these other tools.

For most data stores, the only way to find if a particular value has changed is to poll. You issue a query for that value on a regular basis, and compare it to the last value returned to see if it has changed. This is terribly inefficient, especially with values that don’t change often. It’s also inexact with respect time, because your system’s reaction to a changed value depends on the interval between polls. Longer intervals, while less chatty, mean that more time will elapse between when the value changes, and when your application responds to that change.

Enter etcd. Instead of polling an etcd server for changes, you can watch for changes. This is essentially a pubsub system that requires almost no configuration to work. When a key is written to etcd, if there are any watchers for that key, a message is sent to them with the new value.

This is kind of dry in theory, so let’s look at a real-world application using this system: my photoviewer and photoserver applications. These applications allow me to display photographs on monitors that can be anywhere with an internet connection, and control each of those displays from a central server. They represent the ultimate convergence of my work as an artist and my love of programming.

Each display consists of a monitor (actually a TV, but all I want is an HDMI input) and a Raspberry Pi that runs the photoviewer application. Each display has a unique ID to identify it, and when a display starts up, it registers itself with the server. The server contains the settings for that display, such as the list of photos to display, and how often to change the displayed photo.

Photoviewer running in my kitchen

I have one such display in the kitchen of my home, and like to change the photos displayed on it from time to time. To do that, I go into my photoserver app and change the album for that display. Almost instantly the image on the display changes. How did that happen? The server is a virtual machine running in the Digital Ocean cloud, not local to the kitchen display.

The reason this works is that I’m also running an etcd server on another cloud instance. When I change any setting for a display, the photoserver app writes a new value for that display’s key. The key consists of the unique ID of the display plus the type of value being changed. For example, if I change the photos I want displayed for a display with the ID of 65febdde-3e8a-4c76-ab8f-d8a653e466c7, the server would write a value of a list of the names of those images to the key /551a441f-8aba-44b5-b70b-349af0be5b67:images.

That application uses the etcd3 library to watch my etcd server for changes to any key beginning with /<unique ID>. The watch() method is called with a callback method, and when a new key is written beginning with that display’s prefix, the value is sent to the callback.

The callback method sees that the full key ends with :images, so it passes the value (the list of image names) to the photo display method, which then retrieves the image and displays it. This happens in real time, without any polling of the server needed.

The original version of these apps used the traditional polling method, which seemed wasteful, considering that it was typically weeks between any changes being made. Switching to an etcd watch makes much more sense from a design perspective, and it greatly simplified the code.

Look for cases in your applications where a response is needed to a change in data. Using etcd as a mediator might be a good approach.

Day 30: It Ain’t Over

It’s tiring. I get it. Dealing with the pandemic is exhausting: wondering if any time you touch something that you’re picking up the virus, or if that person is walking by a little to close, or if it’s worth the risk to pick up some fresh vegetables from the store. It’s been months!

And it’s going to be many months more, thanks to the completely inept handing of things by the Republicans in this country. I single them out because they took common-sense safety precautions and politicized them. How is wearing a mask to limit the spreading of the virus a political question?

But thanks to Governor Abbott here in Texas, the number of new cases of COVID-19 infection is climbing rapidly. Here in San Antonio we had the biggest number of new cases (311) on Tuesday, and the most significant increase in the number of people on ventilators. Houston has the world’s largest medical center, but is so overwhelmed by COVID-19 cases that its Children’s Hospital has started admitting adult patients. Back in April Abbott issued an order that forbids localities from enforcing rules requiring face masks, in an effort “open Texas back up”. There was no evidence that the risk of contagion was gone; in fact, everything said the exact opposite. But in keeping with the Republican strategy of pretending it’s gone, he kept lifting the restrictions that had kept the infection rates low. Now the infection rates are spiking, and they’re acting surprised. The same pattern is happening in Florida, where Governor DeSantis is likewise pretending that things are normal.

And this isn’t a case of “how could we have known?”. Every epidemiologist was saying that re-opening was the wrong thing to do. Every medical authority was saying that we needed more testing to understand the extent of the disease, and that we needed stricter precautions: masks that cover the nose and mouth, full social distancing, and banning public gatherings. We have the evidence from the last global pandemic from 100 years ago: relaxing the precautions led to a second wave of infections. This may be the first time any of us have experienced a pandemic, but it isn’t the first time it’s happened, so we have historical data.

But instead the Republicans, following Trump’s lead, ignored that advice in the hope of giving a boost to the economy.

Priorities!

How is this anything but criminal? If I kill someone so that I can get some money, that’s murder. But if I kill someone to boost the economy (and, by extension, help myself get re-elected), that’s just politics?

Nobody could have prevented this pandemic. I’m certainly not blaming Trump, Abbott, DeSantis, or anyone else for it. But it could have been handled in a way to minimize the suffering and death, as we’ve seen in other countries that treat this like the medical issue it is, rather than political football.

Day 29: Death to Superman

Have you ever worked with a large team on a complex project? Usually there is a mix of experience levels, and those with more experience create the application design as well as the workflow that everyone will use. They also serve as the disseminators of information, especially when a new member joins the team. They are the resources that help everyone become more productive

At least that’s how it’s supposed to work. In a company with a good development culture, knowledge is freely shared, and the goal of the senior developers is to help create new senior developers.

In other situations, there is a different dynamic: the overall knowledge of the project is in the brains of a select few developers, and they consider the intricacies of the application their domain. Often it isn’t a group, but rather a single individual in that role. They begin to act like Superman: swooping in to save the day in a manner that only they can do.

This is common in companies without a healthy developer culture. Typically there is a sole developer assigned to create an application, so of course they are the only one who knows how it works. Or the project could have started with a small team, and eventually everyone leaves the project except for one. Other teams that need that functionality need to go through this person, who is now the bottleneck, the gatekeeper. As new people are added to the team, this one developer keeps them dependent on him (yeah, it’s usually a man) by only sharing bits of knowledge only as needed, and not educating the new members. He tends to treat the other developers as inferior, and as a result, no one else feels competent to handle the work that Superman can do.

Back in the ’90s when I was a junior developer I was placed on a team that had exactly that dynamic. Someone would have a great idea, but nobody would act on it until that one lead dev signed off on it. People were even a little afraid to say that they thought it was a good idea, because if this Superman figure didn’t like it, he wouldn’t simply explain why. Instead he’d make you feel dumb for not understanding every implication your change would have.

Of course, when he wanted to change something, he just did it without involving anyone else. It wasn’t unusual to come in one day to find the part of the code you’d been working on had been changed, or sometimes even deleted. Needless to say, there was a general unhappiness on the team.

After a few months, Superman started throwing his weight around with our boss, taking the attitude “you can’t afford to lose me”. It worked for a while, but after one particularly obnoxious outburst, our boss called his bluff, and Superman quit on the spot and stormed out. Everyone on the team was both relieved that the source of tension was gone, and also afraid of how much more work this would mean for us. We were all afraid that the project would founder, and we would have to re-hire Superman, who would then be even more insufferable.

To our surprise, it wasn’t all that bad at all. Everyone started exploring the code base a bit more, now that we didn’t have Superman to supply that knowledge and make those changes. We started talking among ourselves about things we thought needed to be changed, and team members who were always quiet began to speak up more. The entire dynamic of the team changed for the better. And instead of the project falling apart without Superman to lead the way, it got better. Maybe no single person knew the entire code base like he did, but we all learned a lot more, and with people working together, got more done. We divvied up the code so that each person was responsible for learning that part well enough to be a resource to the others. Knowledge was once again being shared.

So while it’s good to have some knowledgeable people on a team to serve as guides for the newer members, it can become toxic with the wrong people and the wrong environment. If you’re on a team with such a toxic member (or members), don’t worry about what would happen if they left the project. Inevitably, the team will be better off without them. Speak with your manager if they aren’t already aware of the situation, and try to come up with a plan to spread the knowledge around better. And if you are told that they think things are fine the way they are, that’s a very strong signal that it’s time to update your resume. It’s not worth the mental toll to remain in a toxic environment.