PHP retrospective

Here's a talk Rasmus recently did on 25 years of working on PHP.  I found it interesting and entertaining.

One of the things I thought was really interesting was the explanation for many of the more hair-brained features of PHP.  It's all the same explanation - for most of it's history, Rasmus was operating under the assumption that PHP was about six months from being out-dated and replaced.  

This is interesting to me because it's the sort of thing that most developers can relate to.  In retrospect, it's obvious that features like safe_mode were a bad idea.  But on the other hand, if you think that your language is going to be replaced "soon", then it kind of makes sense as a quick-fix for a serious issue.

To me, this speaks to the trade-off between "always do it right" and "just do what you need to".  You often hear the latter perspective from the agile methods camp.  For instance, it's the motivating idea behind the "minimum viable product", i.e. that you should build the smallest thing that remotely even remotely fits the requirements, even if you know you're going to immediately throw it away, because "hey, you never know if it'll be good enough".  But then the software craftsmanship camp, which is kind of related to the agile one, often give the opposite advice, that you should "always do it right, because it might be good enough to go to production."

I had this conundrum in a previous job.  We were building a system to integrate 3D models of building interiors with 360-degree internal panoramic images and and external aerial imagery.  The general idea was that you could explore the interior of a building as well as look at the surroundings using oblique and orthogonal images, as well as orthomosaic imagery.  It was actually a pretty cool system, and we built a nice, unified web interface that allowed you to transition seamlessly between the various views.

That's all well and good, but there was a problem: the contract with the customer called for an offline version of the system.  This was a major issue, because the application was leveraging our existing technology (which was online-only) for the external imagery.  So we were faced with the prospect of taking our existing online infrastructure, which was based on PostgreSQL and PHP, and somehow turning that into a stand-alone offline application.  In the best-case scenario, this seemed like a big pain in the neck in terms of packaging and maintenance.  In the worst case, it could be a massive time and resource sink.

Neither I nor the other senior engineer on the team were enthusiastic about this.  I mean, it's a lot of work and there was no clear use-case for it.  In fact, the only reason we were doing it was because the contract said we had to.  So what did we do?  We cheated and went with the "minimum viable product" solution.  We knew that, either way, we'd only be able to include a limited set of external imagery, so we took advantage of that fact.  Rather than repackage the entire web-based system for offline use, we pre-calculated every possible AJAX call that the web page could make.  It was a decent number of calls, but completely unreasonable.  That allowed us to just ship the front-end (wrapped up in NW.js) with a bunch of JSON files and a little bit of custom mapper logic to map the standard AJAX calls to the pre-calculated JSON responses.

And you know what?  It worked just fine.  It met the requirements and held up our part of the contract.  It might not have been the "right way" to do it, but it worked.  And last I knew, there were no complaints from the customer and no interest in an offline solution from any other customer, which vindicates our choice of a "cheat" solution.

Of course, if we wanted to have a really flexible, powerful solution that we could extend in the future, we would have done it "right".  But in this case, we kinda figured that this project wasn't going anyplace long-term, so we went with the easy fix - just like Rasmus.  So while I'm still annoyed by some of his early choices, his explanation gives me a little context and some sympathy for his thought process.

Getting fit

The other week, I watched a Jarvis Johnson video about losing 50 pounds.  For the zero people who've been following my blog for over ten years, you might know that I did something similar in 2007 and documented my progress here.  (Although, unlike Jarvis, I did do some exercise.  Not a lot, but some.)

I've actually been on a similar journey this year.  It's a little different this time, though, both to what I did ten years ago and to what Jarvis did.  This time, instead of just trying to "lose weight", my goal is to actually get healthier and improve my overall fitness.

Motivation

The last time I lost weight, the goal was just the traditional "to lose X pounds" or "get to X weight".  This time, the goal is more specific: to lose fat (not the same as "losing weight"), build lean muscle, and develop healthier eating habits.  Why?  Well, there are several reasons.  For one, I want to be in sufficiently good shape to play with my son until he's too old to think I'm cool.  I also want to stay strong and healthy long enough that when I one day (hopefully) have grandchildren, I'll still be able to run around and play with them too.  In fact, I'd like be able to stay healthy and mobile for as long as humanly possible - preferably until I die.  And the best way to ensure that is to start taking better care of myself and building better habits now.

But it's more than just that (as if that wasn't enough).  There's also a self-actualization aspect to it.  Part of living a fulfilling life is constantly trying to develop yourself and becoming better than you were before. There are many axes along which you can do that: social, intellectual, moral, spiritual, etc.  Well, I came to the realization that physical development is also a valid form of self-improvement.  We often forget that our physical and mental health are not independent - they directly impact each other.  Your mind is connected to your body, in a very literal sense.  So the healthier you are physically, the more mental energy and stamina you can muster, which in turn helps you grow in other areas.  Penn Jillette summed this aspect up nicely in his interview with Joe Rogan here:

Another important motivation is to serve as a role-model.  As I mentioned above, I have a young son and I want him to grow up to be a mentally and physically strong, healthy, confident, and independent adult.  He's still too young to appreciate the implications, but I want him to learn how to eat a healthy diet, exercise safely and productively, and develop the discipline to maintain the good habits he'll need to succeed in live.  We live in a society that doesn't encourage healthy living, in either the physical or emotional sense, so I can't count on him to pick this up on his own.  I figure if I can start living a healthy life-style myself, I can help him learn the skills he needs early and not have to figure it out later in life like me.

Inspiration

So, why bother to change?  Yes, I've given some good reasons above, but let's be honest - most people could give those same reasons.  And the fact is, most people don't act on them, as I didn't for many years.  So clearly I needed more than just motivation to change my lifestyle.  I needed inspiration.

It's kind of lame, but I'll be honest.  The truth is that I got inspired by allowing myself to be sucked down a YouTube rabbit-hole.  There, I said it.

It started with martial arts channels.  In particular, some of Ramsey Dewey's videos.  He had a video where he talked about training to be a fighter and gave this simple piece of advice - just do something to improve yourself every day.  It doesn't have to be a big, dramatic change - small things work too.  The key is to just do something, consistently, every day.  And if you keep at it and you will get better.  It might not happen fast, and your progress might not be even, but that's OK.  The important thing is to put in consistent effort towards your goal.

At that point, I felt like I'd like to be a little stronger (sitting behind a keyboard all day is not conducive to muscle development), so I decided to take Ramsey's advice and start doing some strength exercises every night.  Nothing fancy - just some push-ups and sit-ups before bed.  But it was something and I was doing it consistently.  And after a few weeks, I noticed that I was able to do more of them than when I started, so I was making progress.  That prompted me to start increasing the number of reps, trying different techniques, and adding some squats and other leg exercises.

Looking for more exercise ideas led me to the world of YouTube fitness, which, like the rest of the internet, has some great content as well as a whole lot of morons.  Fortunately, good channels aren't hard to find, so I quickly discovered Athlean-X and Calisthenicmovement.  Both offer lots of excellent exercise demonstrations, workout ideas, and lots of background information about nutrition, the bio-mechanics of various movements, and how they fit together.  From there, I branched out into channels that focus less on demonstrations and workout specifics and more on commentary and criticism, such as Every Damn Day Fitness and Shredded Sports Science, both of which offer humor combined with reality-checks intended to cut through the nonsense that permeates much of the fitness industry.

I think the main thing I took from these channels, and what inspired me to get into shape, was to really internalize the idea that your fitness is something that is within your control.  Quite often people think about fitness as something that happens to them - that either you're naturally thin and athletic, or you're not, and there's not really that much you can do about it either way.  But that's not the case.  Sure, there are people who have legitimate medical issues that impact their diet or ability to exercise, but the majority of over-weight or out-of-shape people do have the ability to change their body composition and fitness level.  And it's not a choice between "dad bod" and spending four hours a day in the gym, either.  Different people can have different goals in line with their lifestyle and other commitments, and there are different ways to achieve those goals.  It's not always easy, but it's certainly not impossible.

This sounds like a fairly obvious thing, and I think it's something I sort of knew on an intellectual level, but I didn't really "get it".  But after a while, I realized that, conceptually, getting in shape is no different than learning a new programming language or technology.  It requires hard work, and it's easier if you have a plan and someone to guide you, but it is achievable if you're willing to put in the time and effort.  There are no shortcuts, no silver bullets, no magic formula - just time and hard work.  And while it's true that this stuff comes easier to some people than to others, nobody is born into it - the limiting factors are time and energy, not genetics.

Taking Action

For me, internalizing this message and seeing a few good examples was enough to move me to action.  When you think about "getting in shape" in terms of "natural athletes" vs. "regular people", it's easy to write off the possibility of meaningful change.  But when you think of it in terms of "just putting in the work"...that's a different story.  At that point, I realized: I can do this.  I know how to work hard, maintain discipline, and follow and monitor a plan.  Heck, I do that in my work all the time.  This is something I can realistically achieve.  

So I started putting changes in place.  After a few months of doing the body-weight exercises I mentioned above, I decided to start adjusting my diet.  I didn't "go on a diet", but rather started trying to build healthier eating habits.  Basically, this meant moving towards a the kind of diet your grandmother always said you should be eating - cut down on the breads and sweets, cut down on between-meal snacks, and eat lots of vegetables.  In fact, for the first few months I completely cut out between meal snacks.  I also cut way down on my alcohol consumption.  I went from "a drink or two before bed" down to "one drink once in a while".

For my meals, I started making a point of having a sizable serving of green vegetables with every lunch and dinner and cutting down on the refined carbohydrates (breads, pasta, etc.).  To facilitate this, I started pre-cooking my lunches for the week.  On Sunday evening, I prepare four days worth of lunch (I still take advantage of "free lunch Friday" at the office) which I then portion out so that I can just grab them each morning before I leave.  As an example, last week I made turkey burgers and chicken breast (for alternate days), roasted sweet potatoes, broccoli sautéed with onions, and some chopped kale salad from Wegmans.  Lest this sound boring, I make liberal use of the spice cabinet to jazz things up.  We have a number of interesting spice mixes from Pennzey's that add a lot of flavor to the meat and veggies.

After about three months of this, I was down about 15 pounds (from 191 to around 175) and was feeling stronger from the strength training.  However, it was also becoming clear that I needed to be more organized about my training.  This whole "cobble together a workout from YouTube videos" think worked fine initially, but it was becoming clear that I didn't really know what I was doing.  I was starting to notice some strength imbalances and mobility issues and I didn't know how to address them or work around them.  So I decided to get myself on an organized training program.

I decided to go with the Athlean-X "AX-1 Training Camp" program.  I chose this partly because I was already familiar with the YouTube channel and trusted the quality of the material.  But the program had several other aspects that I found very appealing:

  1. It takes a "don't waste time" philosophy, which they sum up as "trading time for intensity".  The short version is that, unless you have difficulty executing one or more of the exercises (which did occasionally happen to me), the workouts shouldn't last more than 40 minutes (about 45 if you do the optional "six-pack shuffle" abdominal workouts that are included).  In fact, some of the conditioning workouts can take as little as ten minutes (just don't mistake "short" for "easy").
  2. The entire program can be accessed from your phone.  It's a mobile-friendly website that lets you access your workouts, watch the demo videos, and keep track of your weight and repetition numbers for each exercise.
  3. You can do the all the workouts from home with relatively little equipment.  I only had to buy a doorway pull-up bar, a physio ball, and a set of adjustable dumbbells.  Not only does it save money over a gym membership, it also saves time - no driving back and forth.  (Note that really do need an adjustable dumbbell set.  The program is based on lifting to failure in a certain range of repetitions, so you need to be able to move the weight up and down in fairly small increments, and the only way to do that is to have adjustable dumbbells or have a rack of a dozen dumbbells in five-pound increments, which is both costly and takes up a lot of space.)  In fact, the entire program has a "no excuses" philosophy to exercise, offering adaptations and substitutions you can make to the exercises.  One of the "extras" is a set of videos showing various ways to get an exercise in even if you don't have the "proper" equipment for it.  There are also plenty of options offered for the conditioning workouts, including ones that can be done indoors with zero equipment.

I've been really enjoying this program so far and would definitely recommend it.  The one thing to keep in mind is that when Athlean-X uses the tagline "if you want to look like an athlete, you have to train like an athlete," they aren't kidding.  Even though it's the "beginner-level" program, AX-1 is definitely challenging and requires dedication.  If you are extremely over-weight or if you haven't been exercising at all, then don't expect to have an easy time with it.  You might want to consider starting with something less demanding or be prepared in advance to repeat the first month several times.  (The program is structured around three one-month phases, each of which ends in a "challenge".  If you don't "pass" the challenge, you're supposed to repeat the current phase until you can pass.  You also repeat the challenges in later months, so you can track the changes in your performance.)

Results

Long story short: so far, my results have been very good.  

At this point, I'm down to about 168 pounds and in the best shape of my life by far.  I don't look like a fitness magazine model or anything, but I look better and feel stronger than I ever have and my energy and endurance levels, both physical and mental, are higher than before.  I'm also discovering bones and muscles that I didn't even know I had, which is cool but kinda weird at the same time.

In terms of lifestyle changes, things are going quite well.  I started the basic body-weight exercises last November, changed my diet in March, and switched over to doing AX-1 in June.  I'm currently maintaining a six-day training schedule (I'm on my second round of AX-1, this time including one of their "TNT" plugins, which adds an extra workout), doing my workouts first thing in the morning before work.  I am still pre-cooking my lunches and maintaining a healthy diet without too much difficulty or feeling of restriction.  I'm also being more mindful of my sleep schedule and getting to bed at a reasonable time.  While all of this does require some effort and discipline, I'm not finding it to be burdensome and I'm feeling really good, so the extra effort is definitely worth it.  At this point I can see myself maintaining this lifestyle for a very long time, which was exactly the point in the first place.

Birthday book acquisitions

This is my more-than-slightly belated birthday post. cool

This year, my birthday fell on the last day of our vacation in Cape Cod.  We've been there several times, so we've seen most of the attractions we're interested in at least once.  Thus we had a nice, restful, laid-back week.

I'm not usually much for shopping, but one of my traditional activities on the cape is to go shopping for used books.  (Actually, I do that pretty much everywhere.)  However, this year I was very disappointed to find that my favorite used book shop on Main St. in downtown Hyannis had closed! I'd shopped there every time we've been to the cape and they had a really nice selection.  I define a "nice selection" at a used book store as one that includes a wide range of unusual books on a wide variety of topics (such as this one, which I bought at that shop two years ago and spent my vacation week reading), as opposed to used book stores that carry mostly mass-market paperbacks, usually in the mystery and romance genres.  

Fortunately, I was able to find another good used book shop - Parnassus Book Services in Yarmouth.  We always stay in Hyannis, so it's not as convenient as the other one was, but they've got a great selection.  In fact, it's a bit daunting - the shelves literally go up to the ceiling and they're completely packed.

Yet even with the abbreviated browsing time I had when shopping with a small child, I still managed to find several interesting volumes, including:

  1. Islam by Karen Armstong
  2. A History of the Vikings by Gwyn Jones
  3. The Book of J by Bloom and Rosenberg
  4. Dinosaur Lives by John Horner
  5. Aristophanes' The Forgs
  6. Exodus: The True Story by Ian Wilson 
  7. Discovering Dinosaurs by Norell, Gaffney, and Dingus
  8. Fundamentals of Elcetronic Data Processing: An Introduction To Business Computer Programming, edited by Rice and Freidman

My birthday book haul

As you can see, my book tastes are a bit eclectic.  Two themes that are obvious are my interest in studying religion and Dinosaurs.  The former is a legacy of my BA in Philosophy, while the latter is a result of being the father of a six-year-old boy - I loved dinosaurs when I was young too, and my son's interest in them re-sparked mine.

I couldn't resist the one on the bottom, though: Fundamentals of Electronic Data Processing: An Introduction to Business Computer Programming.  It's from the 1960's, so basically a piece of computing history.  I've got a couple of other computing books of similar vintage sitting on my shelf, though this is certainly the oldest.  One of these days I'll have to read them all the way through and write up some reviews, like I did with my copy of The Mythical Man-Month.  It's always interesting to see just how much has stayed the same despite the radical changes in technology.