Saturday, November 30, 2013

What was it like to learn how to code?

About a year and a half ago, I seriously started learning how to code.  I had no formal training, but had picked up some programming knowledge since graduating from undergrad.  Now in business school, I had the idea that I could program a game instead of a normal summer internship.  I'd learn more about technology, put my previous gaming experience to use, and might even make a few dollars.

I remember visiting a friend's gaming startup.  One of the engineers asked me what I planned to do over the summer.  I - hesitantly, I'm sure - answered that I was going to create my own simple tactical RPG. But oh, by the way, I didn't even know how to code.  I was learning as I went along.  He looked at me like I was crazy.

But the thing is - I did it!  I built Solarian Tactics on a shoestring budget and actually shipped something.  This summer, I released a sequel of sorts, Sol Heroes, based on my learnings from the first experience.  Tens of thousands of people have played my games.  And while it's nothing compared to what we would have considered a success when I was at Playfish, sometimes I am still shocked to think that more people have touched this product I made than I will probably get to know in my entire life.

So how does it feel to have my year and half of coding experience?

Mostly it feels like I am doing something wrong.
I always have this nagging feeling that I am doing something wrong.  In the beginning, I had some amazingly ignorant comments in my code like //What is an instance variable?

But even now, I sometimes worry that the entire architecture of my game is fundamentally screwed up or that I have misunderstood something all this time.

When someone asks me how I wrote the artificial intelligence for my game, I still chuckle to myself.  To me, I felt like I wrote some horribly inefficient code and plugged in some probably stupid variables, not something that I can dare call an "AI algorithm."

I fought a lot more with libraries than I expected
I used an open source framework, Cocos2D, to help run my game.  There were a lot of questions I had that I couldn't easily find the answer for - could I use Cocos2D with storyboards? Does it make sense to use CCBatchNode when I just have 10 sprites?  I was simultaneously shocked that the documentation could be so bad, and amazingly thankful that someone took the time to make the framework available to me free of charge.

There was a time when Sol Heroes was crashing more than once a day for each user it had. Someone left a review of my app with the title "Terrible Coding" and I felt my users had finally figured me out.  The issues turned out to be related to how I misunderstood Cocos2D.  And I felt I spent days searching Google and Stack Overflow for my obscure error.  It didn't feel productive at all - I wasn't writing any code and I also wasn't learning something useful about the library.  I just went down different rabbit holes hoping the problem went away.  I finally fixed that particular problem - and I'll leave this graph here since I'm damn proud of it - but it was painful.

It was times when I could just write code that I felt most productive - for example, ironically, the "AI Algorithm" that I created.

I'm afraid of updating anything
In this last year, I learned to be afraid when updating anything (I suspect "real programmers" would not feel this way).   For example, I updated my iPhone to iOS 7 when it came out.  This simple change led to a series of pain.  First, I realized that I could no longer test my game on my phone through Xcode.  I had to update Xcode.  So I went ahead and tried to do that.  I realized I had to pay $20 for the Mountain Lion upgrade to my Mac OS before I could update Xcode.  I paid and upgraded to Mountain Lion.  Now, I updated to Xcode 5.  Unfortunately, Xcode 5 is really meant to only work with iOS 7.  My whole games UI was based on iOS 6.  So I had to look up some clever ways to support both iOS 6 and 7 on StackOverflow.  Okay, now that I did that, I realized iOS 7 displays fonts differently than iOS 6, so I needed a solution to that... and it went on and on.

It's satisfying to ship something
Despite all of these hiccups, I had a great time making these games.  It was satisfying to have an idea of what feature I want to make and then just be able to make it.  I could see feedback from users, good or bad, once it was released.  It is fun to open up my iPhone and show people what I made.

If I step back, it was satisfying not just release games, but to take on a big technical challenge like learning how to code a game without any experience.  A part of me never thought I could actually actually do it (though I obviously decided to try!).  And I think I demystified for myself a lot of what it means to program something.

Overall, I expect in the future I'll be less afraid to tackle new technical challenges.

Wednesday, November 20, 2013

How successful is NASA's COTS program?

Cots?  Are those beds?
COTS stands for the Commercial Orbital Transportation Services program.  NASA needs to regularly resupply the international space station (those astronauts need to eat).  The USA previously did this with the Shuttle program until it was cancelled following the Columbia disaster. As a result, NASA created the COTS program in 2006 to fund commercial firms with good proposals for the 'routine' resupply of the international space station.

The program is now complete with the SpaceX Dragon and Orbital Sciences' Cygnus graduating from the program by demonstrating they can deliver supplies to the space station.

COTS by the numbers
The Shuttle, it pains me to say, turned out to be extremely expensive.  Over the lifetime of the program, each launch cost about $1.5 billion.  It cost around $20,000 to put a pound into orbit.  In comparison, NASA's total investment in the COTS program is around $800 MM, less than a single shuttle flight.  Now, SpaceX is delivering cargo to orbit for about a tenth of what the Shuttle was, around $2000 per pound ($56.5 MM per trip).

Some might point out that the comparison is unfair since the Space Shuttle carried 5-7 astronauts to the international space station, which obviously need more life support than a bunch of cargo.  Plus, the Shuttle has more storage capacity than SpaceX's Falcon 9.  That's all true.  But we can add all of that up.

NASA currently pays Russia $70 MM to get each astronaut to the ISS.  So say you pay Russia to fly 7 astronauts (7 x 70 MM or 490 MM) to the ISS and then fly two SpaceX Falcon 9 for supplies (2 * 56.5 MM or 113 MM).  That adds up to $603 MM.  If Shuttle costs truly are $1.5 B, that's nearly $900 MM in savings each flight.


If COTS' goal was to reduce the cost NASA pays to get supplies to the ISS, it has been hugely successful.

Wednesday, November 13, 2013

Book Review: Apollo

"When they said, "Let's go to the moon" - hell, everybody didn't stand around saying, "What am I supposed to do" or "Send me a directive," or "What's the procedure for going to the moon?"

I'd highly recommend Apollo by Charles Murray and Catherine Bly Fox.  It was humorous, informative, and surprisingly suspenseful.  Like with my review of The Making of the Atomic Bomb, I'll record what impressed me about the book:

The Influence of the Cold War
Prior to reading the book, I thought Eisenhower didn't like the space program, but JFK was excited about it.  It turns out JFK was not excited at all in the beginning of his term. Wiesner, President’s Science Advisory Committee in Washington, hated the idea of manned space exploration, pointing out that it was orders of magnitude more expensive than unmanned exploration.  The science benefit couldn't justify the cost.

What changed everything was the Russians putting a man into space first. Even after reading the book, it is hard to imagine the Cold War environment and how strong public pressures must have been on the White House to make JFK go from viewing manned spaceflight as unimportant to a number one priority. This dramatic change (which would cause the government to increase the budget of NASA 10x in the course of 4 years) happened less than 2 months after the Russians put a man into space.

I wonder -  would anything have the same effect on the US public?  What if China landed on the moon?  On Mars?

Incredible Speed
To land a man on the moon 8 years after JFK's speech, NASA had to move fast.  "In those days, you could do things with a half-page memo," one employee recalled. Look at the month by month timeline that kicked off after JFK gave his moon speech:
  • July - specifications for spacecraft hardware were completed; RFPs sent out
  • August - Spaceport site selected and land acquired
  • September - Production facility for rockets selected; land for Houston (of "Houston we have a problem" fame) acquired
  • October - Rocket test facility land acquired
  • November - Command and service module contract awarded
  • December - First stage of Saturn contract awarded
Mission control was created when Chris Kraft went up to someone and said, "There needs to be someone in charge of the flights while they're actually going on and I'd like to be that person."  On how soft or hard the lunar surface might be, Cadwell Johnson recalled that the scientific community just couldn't agree, "So Owen and I got together and we said, 'It's got to be like Arizona! The moon has just got to be like Arizona! Can't be nothin' else'"

Once in a lifetime...
The book is filled with examples of people that felt that the Apollo program was special.  For example, Bill Tindall "had the exuberance of a seven-year old on his way to the circus." "It's just incredible that we'd get paid to do what we're doing!" he'd exclaim.  The authors point out that "for the last half of the 1960s, NASA seemed to be getting the best of both worlds - superb management without bureaucratic paralysis."  And it's worth repeating that the people of the Apollo program accomplished their seemingly impossible goal that JFK had given them.


Overall it seems the feeling of a clear goal and national pride was enough to push the Apollo team to work harder and longer (many described the experience as a blur) without the financial incentives.  Perhaps it was this feeling of teamwork that led those in Mission Control who had the power to assign themselves to the most exciting and historic part of the job (the Apollo 11 lunar descent) instead assigned others, and a dozen other examples that led to success.

So my final takeaway from the book is that it was exciting and great to read in much more depth about something I'd always cared about.  But it was a bit depressing as well because the NASA of the Apollo program doesn't sound like the NASA of today.  

Wednesday, November 6, 2013

In a car in the year 21XX

"Do you believe people used to drive these things?"

"What're you going on again about?"

"These cars.  Humans used to have to physically drive these cars around themselves."

"I mean it's not a big deal is it, you just tell the car where to go."

"It is a huge deal!  It's so primitive.  Let me tell you, they basically let children drive these things and guess what - they'd crash into things.  Tens of thousands of deaths per year! Traffic accidents used to be the leading cause of death for people 15-24 years old."

"That's horrible.  Why even let them drive at all?"

"I mean what else are you going to do?  They've got to learn how to drive sometime right.  Pretty much everyone learned how to drive."

"I suppose so..."

"And you know what's worse?  People used to get drunk, drive these cars around, and kill people."

"Are you serious?  Now that's just stupid!"

"But is it really - how many bars are within walking distance of our place?"

"Well, zero I suppose."

"And do you like going to a bar every once in a while."

"I do."

"There you have it!  You're stuck now, aren't you?  You would go to a bar, grab a drink or two, then operate this deadly machine back home.  The law even said you could have a couple of drinks before driving since you weren't too impeded."

"Gosh."

"That's not even saying where you'd put the damn thing when you got your drinks."

"The car?  You'd own one of these?"

"Damn right you would.  It can't drive itself so it sure as hell can't pick up Aunt Millie and take her to where she needs to go after it drops us off.  So you'd have to find a place to park in this congested city, grab your drinks, then drive it back to your home."

"Why put it in your house?  What the hell's it going to do there?"

"Nothing!  It used to just sit there useless.  The average American drove their cars maybe 1-2 hours each day.  So the other 22 hours it would just sit there like a piece of brick."

"That's so inefficient."

"Damn right it is."

...

"Geez well I'm glad they figured out this car stuff since then."

---

Thanks to Hillary and Jonathan for the idea