Thursday, July 21, 2011

on perl's open()

There's a minor brouhaha in the Perl community these days regarding perlopentut. One bone of contention regards the style of Perl that is shown to readers of the tutorial - ostensibly they're beginners to the language.

Another contentious aspect is that Tom Christiansen, the original author of the tutorial, sees the proposed changes as stomping across his authorship. This latter point is complicated a bit by the license on the tutorial, which allows anyone to make changes to it. (Tom's "I'll take my toys and go home," knee-jerk reaction was greeted with the equally inflammatory, "Neener neener.")

The "Modern Perl" movers-and-shakers would like to see something like this:

open FH, '>some-file.txt' or die "open some-file.txt: $!\n";

replaced with this:

open my $fh, '>', 'some-file.txt' or die "open some-file.txt: $!\n";

I personally prefer the three-arg form of open. I could tell you that it's because I like my filehandles to close themselves when they go out of scope, or that I care about the safeness of the three-arg over the two-arg. But really it's that I find FH makes my code look like it's shouting special magic at me, whereas $fh just tells me to relax: filehandles can be safely hidden inside a scalar. The $, which newcomers to Perl find so perlpexing, and which detractors of the language find so jangly to look at, is a soothing reassurance to my eyes.

Seriously. That's why I like the three-arg form of open(). Because it looks nicer to me. If I were interviewing, I'd mumble stuff about open() being safer in the three- than two-arg form. But I look at code all day long, so I choose to look at what I find to be pretty code.

Recently one of my colleagues pointed out a bug in one of the write-to-a-file routines that I dashed off inside some script. Despite being a perl developer for 6 years, and having 11 years experience with the language, I'd written:

open my $fh, '>', '/tmp/wherever' or die "open /tmp/wherever: $!\n";
print $fh, "here's the data I want logged\n";

There's a subtle bug there, which perl can't find. Here's two programs you can run side-by-side to compare. First, let's write to a file using the two-arg form of open():

1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 open FH, '>two-arg.txt' or die "two-arg.txt: $!\n";
7 print FH, "hello world\n";
8 close FH;

And here's the same program using the three-arg form of open():

1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 open my $fh, '>', 'three-arg.txt' or die "three-arg.txt: $!\n";
7 print $fh, "hello world\n";
8 close $fh;

Can you figure out the bug before hitting the jump?

Friday, December 10, 2010

Enabled comments

I dug around in the options and enabled comments, so unless I've disabled comments on a particular post you should be able to comment on posts now. Previously I had somehow set comments to "members of this blog only," which apparently didn't work for spammers that wanted to point me at \/iagra.

Thursday, December 9, 2010

Switching to a Midwife: or, Everything I Know and Think I Know About Pregnancy and Labor

This is a very long post, and you shouldn't feel obligated to read the entire thing. Like a bad novel, you can go ahead and return this to the library after you've skimmed the first few paragraphs.

Today I posted the rather innocuous tweet: Switched to a midwife today.

Pretty quickly, people were curious. Katie quickly asked, what made you switch?

and my mom jumped right in on Buzz, asking:  Is this home delivery?

Mom's question is really easy: no, we're not doing a home delivery. I've joked about having the baby on the boat, but Venece pointed out that Alma's on the hard right now. V isn't keen on using a ladder to clamber aboard a boat. Especially when she's in labor.

I also joke about sneakily getting our baby foreign nationality. One day I suggested we take a drive up to Niagara Falls near the end of February. Another day I pointed out that we could just extend our holiday trip to England into a two month European vacation. My brother got in on the game, pointing out that the car that parks two stalls over from ours has diplomatic license plates, "So it's technically foreign soil."

But somehow Venece started thinking that I wasn't taking this very seriously. She added The Business of Being Born to her Netflix queue, and we were dutifully scared by Ricki Lake. Or scared of the awful feedback cycle that occurs when obstetricians get impatient. As near as I can tell, the story goes like this:
  • Obstetrician wants to get home, it's Spaghetti Tuesday.
  • But the baby hasn't been born yet. In fact, labor isn't progressing.
  • So they induce labor! pitocin does this.
  • Pitocin can give you very strong contractions, so many mothers get an epidural.
  • The epidural reduces the pain, which is good, but reduces the mother's ability to contribute to pushing the baby out. So more pitocin is given, to increase the strength of contractions. Since the contractions become stronger, we need more anesthesia via epidural, to deal with the stronger contractions. Rinse and repeat.
  • Time ticks on. If the baby isn't born soon enough, and if the obstetrician is super-Italian and loves their spaghetti, then they decide to cut bait: and calming phrases such as, "Okay, it's time. You need to do what's best for your baby. You need an emergency C section."
Well, that's kind of the worst-case scenario. And I'm sure that the average childbirth doesn't go that way: after all, 70% of all children in the USA are not born via C-section.

But that means that 30% of all children are born via C-section.

When we were in Nepal, standing at the bottom of Mount Everest at Base Camp, our guide asked the three of us whether we would ever want to make a summit attempt. We all said no.

For my brother, it was a economic decision: it costs about $70,000 to join an expedition, and he could probably get more enjoyment out of the same amount of money if he used it differently. For my father, it was a question of time: it takes about 4 months on the mountain to be acclimated enough to make a summit attempt. But neither of those things were really relevant to me not wanting to do it. After all, I want to sail around the world, which is neither a cheap undertaking nor is it a short one.

For me, it was knowing that somewhere between 20-25% of all people who attempt to summit Everest in a given year never come back. They die on the mountain. If I had a 1:4 or 1:5 chance of winning the lottery, I'd think it was a guaranteed deal: of course I'd buy a ticket. So for me, my no came from that  part of me that is certain I'd be in that 20-25%.

So partly our decision to look at midwives was due to this fearful cycle that Ricki Lake told us about, and which Orgasmic Birth reinforced. I blushed to borrow this last movie from our birthing educator, but borrow it we did.

And actually, Orgasmic Birth is kind of a misnomer of a title. Out of the 6 or 7 women that they show giving birth on that movie, only 2 or 3 of them actually seem to be groaning pleasurably. One woman almost passes out.

So this was kind of interesting: the idea that labor doesn't need to be a rush-to-the-hospital, legs-in-the-air, episiotomy-pitocin-epidural haze. That it actually might not be as painful as TV drama would have me believe.

I used to follow @dooce, and read her blog a lot when V and I were trying to conceive. I forget why I got tired of her blog: there were some parts I really liked. My internet connection doesn't want to load Dooce's blog for me to link to, so here's a goldfish with funny eyes instead. And one thing that you learn about Dooce really quickly is that she suffered postpartum depression after her first child was born. Did she have to be hospitalized for it? Maybe.

But there's this fear in me- that postpartum depression can be so severe as to require hospitalization- that made me pick up a book on postpartum mental disorders at the library. And one thing that I started to pick up on really quickly is that
  • it's fairly common to have a postpartum disorder of some sort, so we'll both need to be alert to each other's mental state in the weeks after delivery;
  • one contributing factor to postpartum disorders is how good is the interaction between the mother and her obstetrician. (There are other important contributing factors, like prior mental disorders and horrible sexual offenses against the mother.)
I also started developing a theory based around oxytocin, which is also known as the love hormone and the bonding hormone. My theory goes like this: if the mother's body is denied the opportunity to produce oxytocin, then she'll have less of a loving bonding response when she first meets her baby. And apparently oxytocin crosses the placental barrier? so when the baby is born, it too is high on this loving bonding stimulant? So if this is true, then the baby will have less of this kind of response to its mother.

Yow, that sucks. That sounds almost depressive.

Absent any medical intervention during labor, a childbirth goes something like this:
  • The baby starts bouncing up and down on the cervix.
  • Yowch, that hurts: pain goes to the brain.
  • The pituitary gland releases a chemical signal to offset the pain and induce the uterus to contract. That signal is, you guessed it, oxytocin.
  • Every now and then the adrenal gland gets in on the chemical swamp that's flying throughout the laboring woman: adrenaline triggers the bear-down reflex.
  • Labor progresses. There's more pain: more oxytocin. There's more adrenaline: pushing.
  • Eventually, baby.
A thousand years ago, either your labor went like that or the baby got stuck and you died.

Pitocin interferes with the female body's normal hormonal feedback loop. I'm not sure how: either it's the fact that there's synthetic oxytocin floating around in the bloodstream, or it's the seemingly inevitable use of anesthesia to mask the pain. Something disrupts the oxytocin production. And that's kind of too bad, because pitocin doesn't cross the blood-brain barrier: so the sweet aftereffects of oxytocin in an induced mother are reduced, I guess.

And those sweet aftereffects are pretty cool. There's the love and bonding, which I already mentioned. Another thing oxytocin is thought to do (by me, at least, if not a larger medical community) is to prevent short-term memories from turning into long-term ones. The "Nature Provides a Way" school of thought explains this: if a woman remembered exactly how painful her first childbirth was, she would never have a second child.

But all of this talking about what I know, what I think I know, and what I fear does not explain why we switched to a midwife. After all, I just need to tell our obstetrician: "Look, don't do an episiotomy; don't give my wife pitocin; don't tell me we need a C-section just because she's labored beyond some artificial time limit that you've set."

If I could do that, and if I knew I could stick to my guns, then we'd be all set. But I've seen how I reacted when my cat started throwing up: she vomited three times in 24 hours, and I took her to the vet. The vet could have asked for $3,000 and I would have paid it. I'm gutless in the face of suffering: a few years ago we took in a cat that had a funny scab on its nose. It turned out to be squamous cell carcinoma- a malignant cancer. We did spend $3,000 on strontium-90 laser treatments for that damn cat.

Well, Old Man Cat recovered from his cancer, and moved with us from California to New York. He died in our arms one morning, and when I think about him I try really hard to remember his horribly stinky breath, his oily fur, and his annoying way of bitching us out if we fed him a little off schedule. All the good things. I try really hard not to remember those dying moments.

When Old Man Cat was dying, I remember thinking very clearly that if someone were to walk into our home and offer us more time with him in exchange for money, I would have gladly made the trade.

So Venece and I know that she'll be in pain when she's in labor, and at some point she'll probably beg for the pain to stop. And if our obstetrician is eager to get the labor "on track" - you know, pitocin epidural etc.- and if V is in pain, then it'd just really be up to me to say, "Yeah, she says she wants anesthesia, but see we've been talking about this for months, and I know she doesn't really want it."

I've joked about getting a power of attorney to wave in the doctor's face, simply to be able to say that. And V takes that joke seriously, and thinks that maybe it might be the way to go.

We don't have an obstetrician. We have a team of obstetricians. There's 8 total. We went from Venece's normal ladydoctor, Dr. D-
actually, Dr. Delasho is so awesome that she deserves a proper link, so here it comes: If you're a woman near White Plains, NY and you're looking around for a good OB/GYN, then Dr. Delasho is someone you definitely need to meet.
we went from Venece's normal ladydoctor, Dr. D, who has such a good bedside manner that neither V nor I felt weird about the internal ultrasound being used to view our little fetal pole - we went from a great, friendly doctor to a practice of 8 obstetricians.

During our interview, we asked Dr. J whether she'd be the one delivering our baby. "Well, it all depends on the call rotation schedule," she explained. "So I'd suggest scheduling your appointments around with all the different doctors in the practice, so you get to know all of them."

This sounded fine in theory, but in practice what happened is that none of the doctors got to know us.

Remember the stuff I underlined earlier? Here it is: one contributing factor to postpartum disorders is how good is the interaction between the mother and her obstetrician. If you ask enough women to make a list of "what sucked the worst about your childbirth", you find that "the sheer pain of it" ranks number 4 on the list. (I'm pretty sure I read this in Mark Sloan's Birth Day, but 5 minutes of flipping through it hasn't turned up the page.)

This might be due in part to the short-term/long-term memory effects I claimed oxytocin is responsible for. But it's interesting to know what ranks higher on the list: the quality of the relationship between laboring woman and obstetrician. That's number 1 or 2. Number 3 is probably all the dumb jokes I'll be making about how there's still time to charter a chopper to sunny Papua-New Guinea.

So how well you get on with your obstetrician is a very fundamental determiner of whether you, the woman in labor, feel like an active or passive participant in the childbirth; it has an impact on whether medical procedures are done to you, or whether they're done for you; it colors a woman's perception of her labor in days and weeks that follow.

Today we met Lucille C. Milne, a local midwife from Scotland who has been delivering children in White Plains for fourteen years. She has privileges at White Plains Hospital, which is kind of significant because the OB group we were with also has privileges at White Plains Hospital. And it's a little important insurance-wise, since the hospital is in-network for V.

A long time ago Venece taught me to go with my gut when deciding who to do business with: when we were planning our wedding, we chose our bakery, florist, photographer, restaurant, and venue based not on what we had in mind as a perfect cake, bouquet, etc. but instead based on whether we got a good feeling from the people. If we could trust the people, we could trust they would give us what we wanted.

When Lucy walked into the room, we both relaxed. For an hour we sat and talked, and we asked her questions that we haven't been able to ask our previous OB group. She has two OBs that are part of her practice, and they're available if anything is needed: so that's a relief.

Ever since we walked out of Dr. Delasho's office four months ago, we've been bouncing throughout the medical system in Westchester County. Today when we met Lucy, it felt like we'd finally found a calm place to rest, breathe, and push.

Thanks for listening. I'm sure this was a hilarious read for all my friends that have had first and second children over the past 12 months.

Friday, November 5, 2010

Reviving tradition

Back before we got acquired by Aruba, the devteam had a tradition of sending out humorously false statements about new developers. Peter Sanford was advertised as indulging in "extreme sports as shark wrestling and skydiving"; Thomas Whaples was "well-known to late-night viewers of the Antiques Roadshow for his world-famous collection of scrimshaw and ships in a bottle".

I can't make this stuff up, people. Nate did. No, hang on, this Nate.

We have a new tech writer now. I sent this out to the team in response to the rather bland "please welcome Christina aboard" email that went out.

Christina's favorite color is stagecoach, and she's allergic to tautologies. Once while undercover on vacation in Newfoundland she adopted the name Charlie, snuck into enemy territory, and wrassled a rutabaga into submission using only the power of her mocha blue gaze. She's a huge fan of the New York Knicks, chili peppers on her pizza, and the Oxford Comma. In her spare time, Christina does synchronized crocheting with waterninjas.
Please give Christina a proper AirWave welcome!

Nate was better at this.

Thanks for reading.

Tuesday, September 14, 2010

Where I've been

I think there's only about five friends from high school that I still keep irregular contact with, and even fewer friends from college. So if you've somehow been looking for Belden Lyman, and if I happen to be that guy- here's my story.

High school. I barely remember it. Shoutout to Lisa Nemer, my Spanish teacher for 3 years. I send her postcards whenever I leave the country: something about travelling abroad reminds me of her.

College. Freshman year in New Mexico, then a transfer to Moorhead. I fumbled around with various degrees: Criminal Justice; Elementary Education; Anthropolgy; Sociology. I always paired this with "and Spanish", since Nemer always told us that just by graduating from her Spanish program, we were already halfway to a Spanish major. She was right.

Funnily, my college let students take Introduction to Chinese Language as a substitute for a math credit. Starting in fifth grade I began disliking math, so the choice here was easy. I took Chinese for three years, then took a year off college to teach English and study Mandarin in southern China. I met a fellow student there, who also had two years of college left. We traveled together, and apparently fell in love.

I returned to college, finished two years in one, and moved to the Bay Area in California. An aunt put me up in her basement for a while. One day she shopped my resume around at work, which got me an interview at Innovative Interfaces, Inc.

Meanwhile, the gal I'd met in China finished her last year of college, then returned back home to the Bay Area. Her employer sent her to an introductory Perl programming class at UC Berkeley Extension. I decided that it would be fun to sit next to my girlfriend on the company dime, so convinced my manager that some introductory programming classes were just what I needed to succeed in my job.

I was working in QA at the time, and the QA workcycle went through boom and bust periods. We were in a bust period, so I amused myself by writing tools to examine the translation files that Innovative's software used.

V and I got married. She went back to school full-time to study animation at the Academy of Art University in San Francisco. I bounced around between different departments at Innovative for the next 4 years, writing more tools and improving as a programmer. I was active on Perlmonks at this time- partly because I still needed to look outside my peers to grow as a programmer, and partly because I had a lot of slack time in my schedule.

Eventually I found a job posting on Craig's List that was exactly what I needed: a startup looking for a Perl developer. They didn't care whether I had a degree in computer science- they just wanted me to submit some code to solve some sample problems they posted.

I interviewed, and AirWave hired me. After I'd been there for two years, V got a job offer with an animation studio located in New York state. We moved, and for some reason my manager kept me on. A few months later that reason became clear: AirWave was purchased by Aruba Networks.

So we've been here in White Plains, NY since 2007. And I still work for the same team that hired me, doing the same work that I enjoy.

Now that I've got the dry recitation of my profersonal timeline out of the way, maybe I'll be able to post something more interesting.

Thanks for reading. Eleven years in eleven paragraphs: whew.

Thursday, January 3, 2008

What if we don't come back?

Back in December 2007 I said to Venece that I wanted to start sailing around the world by the time I'm 40. That was 7 years away. We were in Honolulu for the marathon. 7 years, I think, will be enough time to do what we need. Professionally, she's just at the start of her new career.

"You know what scares me about this?" I asked her in the kitchen one day. "What if we don't want to come back? That's what scares me. How about you- what scares you?" What if I end up not wanting to go, she said, and you do. That's what scares me.

It's such a selfish thing, a dream. If it were a separate entity- if it existed outside of you- it would demand all of your effort, all of your attention. It would haunt you by day and night, an aching tooth in your mind.