Friday, August 15, 2014

Geek a Week

In 2010, an artist named Len Peralta started a daring project he called Geek a Week. His goal was to interview 52 different geeks and draw a trading card for each of them. He would release these cards one per week for a year. He would also often release the interview with the geek as a podcast. After the success of the first year (or season, as he refers to them) he went on to do other Geek a Week seasons, although they were not all as long as the first one.

One of the interesting things about this project is Len's definition of "geek". The set is not composed of a bunch of computer programmers or comic book nerds (although those are present in the set). Instead, Len equates geek with passion. These are all people that are passionate about something. It might be computer programming. It might be music. It might be movies or comic books or bird watching. It makes for a very eclectic and interesting set of people to hear interviews with. Among the geeks are well known people such as Neil Gaiman, Kevin Smith and Stan Lee. There are also lesser-known, but equally geeky, people like Ben Acker and Ben Blacker, Paul and Storm and The Doubleclicks.

I discovered Geek a Week when John Scalzi was interviewed (Geek #4 from the original set). I haven't missed an interview since. Every time I listen to one of the interviews, I think of what my answers to his questions would be. I'm never going to be one of Len's official Geek a Week interviews, but here's me pretending to talk to him.

Len: Welcome to the Geek a Week interview. This should take about 20 minutes [A.J.'s note: he says this to everyone, but most interviews then go 40-60 minutes. I'm not sure why he still says it...]. Don't feel like you have to rush your answers, I'd rather this be a good conversation. So, if you're ready I'm ready.
A.J.: Let's do it.

L: A.J., you have been chosen as a Geek a Week. How does that make you feel?
A: Dude! This is awesome. Someday there will be a Geek a Week reunion at ComicCon and I'll be there on stage with the other geeks. It's the only way that I'll ever have something in common with Neil Gaiman and Kevin Smith.

L: What is the secret to your success?
A: I like to learn a little of everything. While I was going to BYU, I talked to a guy that said he didn't know a lot about any one thing, but he knew a little about everything. At the time he sounded arrogant, but in retrospect, I've decided it's a good way to live. No matter what you're doing, learn a little bit about it. Once you've learned a little about some topic, if you need to know more, you're in a good position to do so. You can also carry on conversations about just about everything if you know just enough to get into the conversation. Then you'll know enough to know what questions to ask next and keep the conversation going. For example, I'm not a golfer. I've played exactly once and I was really bad. But I sat on my wife's grandfather's couch for three days watching the US Open with him. I knew enough of the game to understand what I was watching and carry on a conversation with him about it.

The same goes for computer programming. Whenever possible, I like to learn a little bit about new languages or programs. Maybe not enough to build a full-sized, serious project, but enough to know the some of the pros and cons of the languages. I expose myself to new languages or technology enough to be able to pull them out of my back pocket, as it were, when I need them.

L: If you had to stop what you're doing - take up a totally different career, what would it be?
A: If I had to earn a living, I'd like to teach. Of course, the only thing that I know well enough to teach is computer programming. I think I'd really like to try being a high school or trade school computer programming teacher. I think that could be cool.

If I could assume that I have enough money to survive, I think I'd like to try my hand at either writing. Once upon a time (say 3rd through 8th grade or so) I really enjoyed creative writing assignments in school. Looking back at it, it looks like I was pointing myself towards a career as a writer. I think that in the other leg of the Trousers of Time, I went into writing instead of computer programming. I wonder if I can do it.

Another thing I'd like to try, if I didn't have to worry about paying bills, is film making. I love watching movies and I've always wanted to try making them. I spent high school doing two thing: acting in drama club plays and competitions, or going to the movies. I loved acting, but I want to try directing. I have a friend that makes movies and I've done one or two with him. It's a lot of fun being in front of the camera, but I really want to try being behind it, too.

L: This is my Barbra Walters question. What trait do you most value in others?
A: Pleasantness. I like it when people are just pleasant. When you're checking out at the grocery store or at a restaurant, a friendly smile and a little small-talk go a long way. When my wife and I were on our honeymoon in London, we were talking to the waitress in a restaurant where we were having dinner. We told her that we were on our honeymoon and asked what sites we should see. She gave us a few ideas and then wrote a nice note on our receipt. I probably still have that receipt around somewhere. She was really friendly and pleasant and my wife and I agreed that she made the day better.

L: Here are the more geeky questions of the interview. What geeky book, movie or TV show had the most influence on you?
A: Ok. I grew up on geeky TV and movies. I remember watching Voltron, Transformers, Star Trek, Buck Rogers, Back to the Future and other things like that when I was a kid. I don't remember a day of my life when I didn't know who Luke Skywalker was. My whole family was excited when Star Trek: TNG started. I had a good, geeky upbringing. None of those are the answer though.

The answer I wanted to give to this question for a long time was Babylon 5. I knew the show existed when it originally aired, but I only watched one or two episodes. It didn't do much for me. Then about 6-7 years ago, my brother-in-law convinced me to watch his DVDs of it. I was hooked. I love the huge story arc and the fact that at the end of an episode things have changed. Star Trek started to annoy me because most episodes involve going back to the status quo. But Babylon 5 isn't actually the answer to the question, either.

Here's a story for you: When I was in the third grade (so I would have been 8, almost 9) my teacher apparently sent a letter home to my parents saying that I either couldn't or just wouldn't read. This confused them because I learned to read when I was 4. My dad sat me down and gave me a long lecture about reading that I don't remember. He asked why I wouldn't read and, apparently, all I would say was "I dunno". Then he had a sudden idea and he told me about a book called The Hobbit. Like I said, I grew up on sci-fi and fantasy movies and TV. The idea of a story of wizards and a dragon really appealed to me. The very next day, two significant things happened. First, my teacher assigned us to write a story. I don't remember exactly what the story was supposed to be about, but my story involved swords, glowing rings, orcs and Gandalf. Yup. At years old, I wrote my first fan fiction - before I'd even seen a copy of the book. Then, later that day, my class went to the school library. I went straight to the librarian and asked if they had The Hobbit. She pulled it off the shelf and handed it to me. It took me about a month to read, but I finished it. Then I went to that librarian (whose name I can't remember) and asked her what I should read next. She pointed me to The Lion, the Witch and the Wardrobe. Then A Wrinkle in Time. Since then, I've gone through a steady stream of big fantasy or science fiction books. But I've also learned to read other things too, but those are the genres I always come back to. That one conversation with my dad absolutely changed me.

L: Now this is a two-part question: Are you more of a video game person or a D&D Person?
A: In theory, I really like D&D. The middle school that I went to (7th and 8th grade) was a magnet program that was geared towards advanced computer, math and science classes. In other words, I was at a school that was largely filled with people into the same nerdy stuff I was. Role-playing was big there. My friend Donovan introduced me to Paranoia and other games. We played some then, but never any huge campaigns. Mostly single shot adventures that could be finished in 4-6 hours. My friend Rick and I got into some other role-playing games, too. Oddly, D&D wasn't one of them. I got a bunch of the books but we never really played. Sitting in my office closet, I have rule books for 2nd edition D&D, Paranoia, Middle Earth roleplaying, White Wolf's Vampire and Warewolf, and maybe others.

As much as I like pen and paper role-playing, I've done more video game role-playing. My earliest geeky memory is playing Wizardry on with my dad late one night somewhere are 1983-84. I've been into computer games since. Heck, I got into computer programming so that I could make games. I could go on about my history with computer games, too, but I think I'll just say that I'm more of a video game player.

L: If you were to choose two super powers or attributes for yourself, what would you choose?
A: [Note: I liked this question better in the first couple of Geek a Week seasons when it was more apparent that the super powers were for real life and not what people would choose for a video game.] Ok. The first one of these is really easy. I want the ability to find things. I spend so much of my time looking for things. You have kids, Len, you know how often they lose things. Shoes. Keys. Their favorite blanket or toy or whatever. I really want to be able to say to myself "Where is this thing?" and I'd know how to find it. The way I've always imagined this is sort of like Detective Mode in Arkham Asylum. My vision goes mostly dark, but I can see the thing I want through solid objects. It's still fully-lit. If it's not actually in my field of vision, I can feel the direction the thing is in, so I can work my way towards it. I'd never have to waste time hunting for things again. It would be wonderful.

The second is a little bit tougher. I think I want telekinesis. I want to move things with my mind. The door to our basement is at the bottom of the stairs and it's supposed to stay closed. My kids forget to close it a lot and I don't want to walk down the stairs just to close it. I'd rather stand at the top of the stairs and close it mentally. Yes. I am just that lazy.

L: Would you use these powers for good or evil? Or for selfish or selfless reasons?
A: For the most part, I would use these powers for me. So I guess that's selfish. I want those particular powers to make my own like easier. On the other hand, there's a business model hiding behind finding things. I could charge for that particular service. I've also thought, those, that it would be a nice power to have to help law enforcement. It would make finding stolen goods or kidnapping victims easier. I think I'd be willing to do some of that pro bono. So it's not all selfish. Just mostly.

L: Who or what would you consider your nemesis?
A: My children. Absolutely. Again, you've got kids, Len. I'm sure you understand this. I spend so much of my time cleaning up after them or finding things for them. I think those kids inhale oxygen and exhale mess. It's like the saying: "cleaning a house with kids in it is like brushing your teeth while eating Oreos". That's my house. On the other hand, they're tons of fun when they're not destroying things.

L: A lot of the geeks I talk to wear their heart on their sleeves as far as their geekiness goes, but is there anything that you secretly geek out about? Something you don't tell people about but you are a huge fan of?
A: It took me a little while to think of the answer to this one, too. Finally I figured it out. Chick flicks. I'm kind of a sucker for good romantic comedies and TV shows. Among my favorite movies of all time are While You Were Sleeping and What's Up Doc? Both of those are basically chick flicks. My wife also got me into TV shows like Grey's Anatomy and Parenthood. They're actually good shows. Who knew? Meanwhile, I can't get my wife into Agents of Shield...

L: It's the end of the world. What geeky item would you choose to save and keep with your as you explore the Mad Max-like terrain?
A: If I can have something imaginary, I'd like a light saber. Not only are they incredibly cool, it would be very useful to fend off the gasoline-hunting, leather-wearing freaks (this is Mad Max, after all). I think you could also use it as a fire starter or as a heat source in general if needed.

If I had to chose something real that I actually own, then I want my Icehouse Pyramids. Or Looney Pyramids. Whatever they're called now. They'll always be Icehouse to me. It's a set of small pyramids, about an inch and a half tall, made of plastic or wood (I have some of each). They're mostly used to play games like Icehouse, Martian Chess, Volcano, IceTowers and lots of others. I keep them in a nice, draw-string bag so they'd be easy to transport. I could use them to play games when I get bored, or to break the ice with other travelers that I meet. If worst came to worst, I could attach them to something to make a weapon. They are pretty sharp, after all. But I'd rather not have to do that.

L: Here are some rapid-fire questions: How would you kill a zombie?
A: With whatever is closest to hand. If I can get my hands on some sort of gun, shotgun, pistol, whatever, it would be best, I think. I'm not a great shot, but if I've got a zombie coming after me, I think I could learn and improve quickly.

L: Mac or PC?
A: PC. Mostly because of inertia, though. I've been using PCs for pretty much my whole life. I have very little Mac experience. I did use a Mac for about a week when I started my new job, and there were some things about it that I really liked. And some things that annoyed the heck out of me. I think if I were to use a Mac for an extended period of time, I'd like them better than PCs. Right now though, I can get PCs to do what I want them to pretty easily.

L: Table-top gaming, console gaming, mobile gaming or none of the above?
A: This is an odd question, because the order I like these is the opposite order of how often I play them. I find myself playing games on my iPad (and on my phone when I had a smart phone) the most. That's just because they are the most convenient. On the other hand, I really like Hearthstone. I was excited about being about to play that when I got my iPad.

I really enjoy PC or console gaming, but I have a hard time finding time to play. Too many other things to do. Most of my gaming happens late at night, sitting in bed winding down. But if I can fire up my computer or Wii and play for a while, I really enjoy that.

I think that table-top gaming is the most fun of them all though. My wife and I used to invite friends over for dinner every Sunday and we'd always pull out games after dinner. Then, my kids got big enough to mess up the games we were playing and my friends all moved away anyway. So we don't play much any more. A couple of times a year though, we manage to get together with our good friends and there is always gaming. We like LooneyLabs games the most. Like Fluxx. We play lots and lots of Fluxx. Recently we discovered Choose One, which was hysterical. I thought it would result in embarrassing us (like Apples to Apples sometimes does). It did. But it also gave my friend an existential crisis over whether he really prefers chocolate or vanilla.

L: Marvel or DC?
A: Let's see. DC has Batman and Watchmen. Marvel has everything else. So, DC. Batman is just that cool.

L: Regarding the art for your card: I like to think of these cards as editorial-style portraits only in cartoon format. With that in mind, is there anything you'd personally like to say that will contibute to me drawing your card? How would you like me to draw you?
A: I'd really like to be a character from Babylon 5. If you can draw me looking like G'Kar, that would be awesome. If you can't do that, I'd like to be dressed like Captain Sheridan in the black uniform they wear in the later seasons. That would be unspeakably cool.

L: Do you have any other words of wisdom you've like to leave before we depart?
A: Hmmm.... I think I just have to go back to the secret of my success. Learn a little about everything. No matter where you are or what you're doing, learn something new. You never know when it will come in handy. And if nothing else, you can be known as the Walking Wikipedia.

L: That's the Geek a Week interview. Thanks. This was fun.
A: Yes, it was, Len. Thanks. This has been a blast.


So, here's my attempt at making the card I described. Please don't make fun of my lack of Photoshop skills. This really would have been better if Len had drawn it, but I'll just have to imagine that.


Note: The Geek a Week card design is copyright 2010 by Len Peralta. The picture of John Sheridan was taken by Chris Cuffaro. I really hope hope I haven't stepped on too many toes here.

Wednesday, July 30, 2014

Rules of Programming

Introduction

Since I started programming, I've discovered a handful of rules that guide how I program. I posted these on Google+ several months ago, but I want to go into more detail about them. These rules may not apply to all situations, but they have been very good guidelines for me through the years. 


Rule 1 - Make it work, then make it fast

I spent a year and a half or so in college working as a teaching assistant for the Algorithm Analysis class. One of the requirements for all programs that students wrote in that class was that they finish in a certain amount of time. Of course, the programs were still expected to return the correct results. If a program was supposed to sort 1000 numbers and their result only included 999, I gave them a lower grade. I can't count the number of times students came to me and asked why they got a low grade when their program ran in the time required. Every time, I had to explain that anybody can write a fast program. Their goal was to write a program that was both fast and correct. They would usually get a better grade if they were slow but correct.

I decided from that experience that the best way to write a program is to write a "baseline" version that will get the right answer. It may be slow, and it may be ugly, but it's right. Then you can take that program, start tweaking, adjusting and changing it until you have a program that still gets the right answer (compare the results to the baseline) and is now fast enough.

In practice, I've also found that trying to write a program that is designed for speed causes me trouble because I'm trying to juggle too many things in my head at once. With every line of code I have to ask myself "Is this getting me closer to the correct result?" and "How will this affect my speed?". When I can separate those two questions and write the code in two passes (first for accuracy then for speed) I end up with a much better result.

Rule 2 - A working solution is a solution, even if you did it the "wrong" way

This rule is really sort of an extension of Rule 1. Almost anything you can do in a computer program can be done a dozen different ways. When you are first learning a new language or library, or just doing something or the first time, it's likely that you'll do it in a weird, inefficient way. For example, maybe you write a complex algorithm because you didn't realize that the library has it built-in. There's nothing wrong with that. You wrote a program that works. That's the key. As long as your solution gets the right answer, you did it right. You can be happy and celebrate that. You can release that version of your program. It's a good solution.

Rule 3 - Do it the wrong way until you learn the right way

Now we're moving on from Rule 2. Once you have developed a way to solve a problem (no matter how ugly), keep using it whenever that problem comes up. There's nothing wrong with that. Of course, the day will come that you find a better way to do it. It may be that you found that command that was hidden in the library. Or maybe you just thought of a better way to write the code. Programmers have at least two major reactions to this situation:

First, you may say that you spent so much time on your first solution that you don't want to have wasted all that time and you don't use the new solution. Frankly, this seems stupid to me. Your time wasn't wasted. You solved the problem the best way you could. You had a perfectly valid, working solution. Now, you just need to realize that you've learned something new. That's a good thing. A programmer that isn't learning new things is stuck in a rut and will be bored, stagnant and pretty soon obsolete.

Second, you decide that your solution has had its time to shine, but now it needs to be put out to pasture. You start using the new method immediately and every time you come across the problem again, you use the new solution. I think this is the right way to go. When you do this you will be continually learning and growing. You will be improving your skills and keeping up with the times.

Rule 4 - Once you learn the right way, be willing to go back and throw out your old "wrong" code

So, once you've moved on from your old solution to a new one, what do you do to your old code? Well, that depends. If it ran just fine before and doesn't need other updates, leave it alone. You can drive yourself insane going back to old code and constantly improving it. You'll never develop anything new. On the other hand, if it's important code that could really be improved by having the new solution implemented into it, feel free to go back and fix it. You may find yourself tearing out code that you slaved over. It's a weird feeling watching 15 or 20 lines of code that you worked so hard to figure out turn into a single call into a library. Nobody wants their work to go to waste, but remember that your old code wasn't a waste. I think we can all agree that, typically, changing from version 1.0 to 2.0 is a good thing. That's what you're doing with your code. You're upgrading it. You don't owe it anything. Your old code has served its purpose and is ready to be replaced. If you're sentimental about it, print it out and hang it on your wall. But if it can be improved, do it and release it.

Rule 5 - Write your code assuming that when you come back to it, you won't remember anything

Something funny happens to code that I leave alone for a long time. Even when I'm the guy that wrote it, I look at it and can't remember exactly how it all works. It's like it changes without me staring at it. I know that it's all in my head. The code isn't changing, I just don't remember it. But it sure feels like the code changed while I wasn't looking. To combat this, I write comments. Lots of them. I recommend that you do the same.

Now, I don't comment every single line. I've known guys that do that and I don't think it's worth the effort. Too much time to format it and maintain it. Instead, I write a comment at the start of a block telling me what that block of code is supposed to do. For example, I might have a comment before a for() loop that says "Find the requested client in the list". I now know what that loop is trying to do. If there's an individual line that is doing something that may not be totally apparent, I'll put a comment on that line, too. My comments tend to read sort of like a high-level view of what my code is doing, with occasional low-level details thrown in.

Another tool to writing readable code is formatting. I'm not going to tell you whether to use spaces or tabs or whether opening braces belong on their own line. I have my opinions about these, but there's a bigger thing to discuss here. Consistent formatting will make your code much more readable. The key word there is "consistent". Pick your favorite formatting rules and stick to them. Make sure that everyone in your team follows the same conventions. All of the code in a project should follow the same conventions. If some files are formatted one way, and some are formatted another, then the project becomes harder to understand. Have your team pick formatting rules, and then formalize them. Write them down, create an Eclipse formatter file, something. But everyone on the team needs to know the rules and stick to them.

Rule 6 - Keep your code in a version control system

One of the most important tools I use while programming is a version control system. Again, I don't want to tell you which one is the best, but you want to find one that works for you. A good version control system helps for a number of reasons.

First, you can always look through the history to see what you (or members of your team) changed. These logs can help remind you of what the code does.

Second, it will help you save code in case you do something really strange or disastrous and need to roll back. I also use it to write debug code. (This trick works best with a distributed system like Mercurial or Git.) I make sure that the broken code is saved in the version control system. Then I can add print statements or whatever else I need to find and fix the bug. Then, once I've found the bug and know how to fix it, I revert back to the original, broken code and put the fix in. This lets me scatter debug statements liberally throughout the code without requiring me to go back and find them all when I'm done with them.

Third, if your code repository is stored off-site (or at least off of your local machine) then you have a really nice back up solution already in place. I think we can all agree on the importance of those. I put the repositories for my personal projects in DropBox. That way they are backed up and available to me from just about any computer.

Conclusion

So, there are my major rules of programming. There may be times when they don't apply. You might need to think about speed from the very beginning of a project. That's fine. But in 99% of the code that I've written over the years, these have worked for me.

What rules do you have? Anything you'd like to share? Let me know. I'm curious. And I'm always looking for ways to improve.

Friday, July 18, 2014

Introductions

Let me introduce myself. My name is A.J. I'm a computer programmer, technology enthusiast and general, all-around geek. For a long time I've wanted a place to share thoughts related to technology, computers, etc. I also use Twitter, Facebook and Google+. Part of this experiment will be to see how I can use all of these platforms together.

Let's start with my thoughts on these platforms:

Twitter
I have a hard time seeing how Twitter can used for anything really meaningful. It's a way to share simple thoughts, but you can't have real conversation. The most fun I've had with it is usually listening in on silly conversations between other people. This is a good way to share links, but it's not a good way to curate them. My Twitter stream changes fast enough that unless I follow the link when I first see it, I may never find it again. I've started misusing the Favorite button in Twitter to be a sort of bookmark. When there are posts that I want to come back to, I favorite them. I usually unfavorite them later, after I've checked them out more closely. This throws off Twitter's statistics, but it works for me.

Facebook
I have two main uses for Facebook: keeping up with friends and family and getting news. The local TV stations are very good at posting links to their top stories on Facebook. This is also where I post thoughts, stories or pictures about my family. I tend to not post those to public forums (you're not going to hear much about my kids here, for example). Facebook has also been a good way to keep in touch, to some degree, with old friends from High School, or even earlier.

Google+
This is the part where I can hear you rolling your eyes (seriously, I know that sound). Yes. I use Google+. It is, by far, my favorite of these three services. I would love nothing more than to dump Facebook and use Google+ instead. Why don't I? All my friends are over on Facebook. Unless a giant, mass migration can be arranged, that's probably not going to change. So why do I like it so much? First of all, I like the interface. It's clean, pretty and it seems like everyone else is trying to copy them these days. Second, I actually like the way contacts are grouped into Circles. Sure, it's a bit of maintenance, but I set up a half-dozen or so circles when I started and I haven't felt a need to change them much. Third, I think the Communities feature is very cool and leads to some excellent conversation (depending on the community, of course). Fourth, it's photo editing and sharing features are FANTASTIC. I had my phone set to automatically send pictures to G+ and then they were really easy to share from there.

Blogger
Here we are. Pros? Cons? I don't know yet. Keep checking with me and I'll let you know how it stacks up to the other information-sharing services that I use.

ShareThis