My evolution of style

I don’t write about programming as much as I do other topics, but if you look at number of hours spent on something in a day, programming comes out at the top of my list. My day job has me writing iPhone apps, and my night job does too.

One topic that is a source of endless discussion amongst programmers is that of programming style. Just like you can have MLA style, the AP Stylebook, and the like, so too do programmers have a style to their writing. What we have to realize is once the code is written, it will forever be maintained — which requires reading it. Thus, style is important to aid readability, and no one questions that.

But everyone wants to question what the style should be.

And of course, my way is the right way.

Background

I’ve been doing this long enough (I’m not a graybeard just because my beard is turning gray) to know there is no One True Way®. As long as you have some sort of consistent style and you produce readable code that’s appropriate for the context (because yes, certain programming languages and toolsets will bring about different styles), that’s essentially what matters. Yet, we still have people persisting their style is the one way that all code that a project involves must be written that way. Why? To what meaningful end does this address?

Style guides that merely propose cosmetic changes are useless and ego-driven, IMHO. But when the style has purpose and actually works to improve the code itself, has solid reasons behind the choices? That’s different.

When I started out, I didn’t have style. No one does. You eventually pick it up as you write more code. My first formal endeavor was working as a developer of a then-popular C++ Mac framework called PowerPlant. When I asked about coding style, the Grew Dow (creator) said “mine”. 🙂  Basically, PowerPlant was Greg’s baby and if I was going to write code for it to be included in the official distribution of it, I had to make my code look like his. This was a lot more than just where the curly braces went, but a lot of other form and function choices too. IIRC, Greg taught me this:

bool x = false;
if (SomeTest()) {
    x = true;
}
return x;

Compare to this:

bool x;
if (SomeTest()) {
    x = true;
}
else {
    x = false;
}
return x;

The first is more readable, more compact code, and generates better code too. The end result is the same. Go with the first.

This was a matter of style, but it produced better code.

Braces

Over the years my style has changed. In fact, one change happened within the past year, and I’m pretty happy with it. It concerns everyone’s favorite debate: curly braces!

I started out with:

if (foo)
{
  DoSomething();
}
else
{
  DoSomethingElse();
}

Because whitespace is good. Thus why I didn’t like:

if (foo) {
  DoSomething();
} else {
  DoSomethingElse();
}

Because while compact and nice on screen space, it wasn’t as good on the eye because the “else” wasn’t in a column with the “if” (for visual scanning, since we sometimes will process the code in “blurry” visual chunks, not necessarily processing the actual code), and depending upon the complexity of the code, readability wasn’t always best.

I flipped flopped around for a while on this, especially since Cocoa coding brings a lot of its own conventions to the mix, which for the most part are well-worth adopting especially since some are imposed on you in order to make things work. My current style?

if (foo) {
  DoSomething();
}
else {
  DoSomethingElse();
}

I find this works better because there’s better visual chunking of the data, better organization. It helps to keep the code compact, doesn’t waste too much space, but yet still keeps some whitespace around. It’s hard to get a feel for this style in small code snippets, but when you use it all day in various bits of code, it gets vetted and I’ve found this works quite well.

Of course, do-while is still potentially weird. 🙂

Pointers

I still debate this one.

I think it’s clearer to say:

NSString* string;

than

NSString *string;

Because to me, it’s making the type clear. That is, this is an NSString pointer. It makes sense too when you look at function/method arguments, be it C, C++, or Objective-C, because you declare return types as such and arguments do not always need a variable name, just the type. Thus:

- (NSString*)foo:(NSString*)s;

is legit and correct.

The only place I find this breaks down is if you wish to declare variables with a comma:

NSString* string1, *string2;

So you have to do that. But I also think it’s generally bad-form to declare with a comma, especially since it gets really messy looking with initialization, and in general you should initialize your variables (at declaration time).

Spaces

Another style change I made was spaces. Or rather, spaces vs. tabs.

I always used tabs. I preferred tabs. It made editing a lot easier. I did set my tabs to 4 spaces, but I still used tabs. I hated people that used spaces instead of tabs because it made editing hard.

When I came to my current day job, the server side was being done with Ruby (and Ruby on Rails). Those guys like spaces, and using 2 spaces per tab. And so, the clash began. The then-lead on things asked us to just switch to using spaces instead of tabs (tho we could stay at 4 per), and I just gave in because it was easier. Because that really was the problem: mixed setups.

I recall back at Metrowerks, most people used tabs with 4 spaces per tabs. I think one guy liked 8 spaces per tab, and then there was another guy that liked 3. Yes… 3. That made his code really weird to look at when you opened it up in your editor, because things lined up really wonky. And so problems arose when you couldn’t really read someone’s code (back to that readability thing), and it was made worse when people with different tab settings edited the same file.

Basically, it became a huge mess once you left the ability to have a homogeneous environment and complete control over it.

Using spaces instead of tabs fixes most of that. You can’t fix if people use different substitution values (e.g. 2 per vs. 4 per), but you will still end up with consistent-looking code when you open it up in a different editor, because a space is a space.

But this made me realize why I resisted for so long.

Editors

Your choice of editor tool matters, and affects your style.

For example, with the spaces vs. tabs situation, I hated using spaces because if I hit tab too many times, now I have to backspace a LOT in order to delete all those spaces, instead of just a couple backspaces to undo what I did. Typing out code isn’t like typing out a letter or a blog post, because a lot of keystrokes can be for formatting and navigation around the code. So now to have to do all this extra work, it adds up in a day.

But now, I have an editor that is smart(er) about this situation. So if I have tabs actually be 4 spaces, I hit tab, the cursor “tabs in” but really 4 spaces were entered. And if I mess up and press delete, it will “untab” and delete the 4 spaces. Having an editor that is smart about such things really goes a long way, not just towards helping you write code, but helping you manage these sorts of style choices.

I would also add that the growth of screen size and resolution has helped a great deal. We aren’t using VT100 terminals limited to 24 rows and 80 columns, yet some people still cling to that standard. Why? Even our tiny mobile devices aren’t so limited. Granted, if you are in a particular environment that requires such constraints that’s one thing. But I primarily work on a 17″ MacBook Pro with a 1920×1200 screen; I used to work with 2-3 total monitors. We have the space, we should use it. Our eyes like to see a wide horizontal plane (thus why TV’s are widescreen and movies are wider not taller). Use that.

Thankfully Xcode is really getting better about these things. It’s taken a while, and it was really important for Xcode to be an awesome editor because the 3rd party editor road and integration/support was just not happening.

One thing that I’ve also given into is code completion. I didn’t like it because hey… what’s so hard about typing things out? Well, with some iOS/Cocoa API’s, it’s quite hard because the names can be VERY long and difficult to remember. So code completion has worked out to be a quite useful thing. But with that comes some imposition of style because someone had to decide how to insert that text. Xcode also allows some level of syntax-aware editing, where it can do things like auto-indent and the like. You have some control to pick and choose, and really once you tweak things to your liking the automation is nice. But again, there’s some level of imposition of style here that you cannot get around, especially if your choice isn’t represented in Xcode’s options.

Point is, your choice of editor can be a bane and a boon. In general, they should be there to help you write better code, more efficiently. But while doing so, it may require you to make some choices in your coding style. Don’t fight it, go with it. You might find some benefit to that stylistic approach. It’s worth the time to experiment with it, especially if it winds up improving your point of view, improving your code, or just giving you solid reasons and experience behind your rejection of that approach.

Editor Customization

And so, if the editor app matters, hopefully you can customize it to suit your needs.

I can touch-type, and I find it much faster to use keystrokes than to stop and utilize the mouse – I don’t have to (re)move (then replace) my hands. I know many people that use laptops as their primary computer, but hook up external keyboards and mice to it. To an extent I understand this, but again it’s about having good tools. If you use the keypad a fair deal, the loss of it on a laptop keyboard is a detriment. If your laptop’s pointing device merely moves the cursor on screen, an external mouse may work better for you (especially that scrollwheel). But I’m happy my MacBook Pro’s trackpad supports gestures, and I use them constantly to allow me to more easily move about not just my source code, but my whole computer. Taking advantage of Spaces (well, Mission Control – having multiple Desktops) is a big boon because I can put my communication (email, web, IM/chat) on one Desktop, Xcode on another, etc.. Gestures are useful.

Granted, I cannot customize the gestures so much as I can customize keyboard keystrokes. But thankfully I can and use that to help me efficient access the commands I use most.

Another customization has been the use of editor color. I like the solarized project for how it effectively syntax colors, but also is very easy on the eyes. Quite important when you’re staring at the screen all day.

Plugins are useful too, and this comes more directly back to my discussion of style. I found a useful plugin, VVDocumenter-Xcode. This is a simple Xcode plugin that with a simple keystroke inserts basic formatting for appledoc-style documentation (and I’m going to modify this for Xcode 5). Just like the endless debate about comments in code, there’s debate about how much documentation one should have. I am not always good about complete documentation (you get into a groove with coding, documentation becomes a secondary concern, then you don’t have time to go back), but a plugin like this makes it much easier. Furthermore, with some advances in Xcode 5, there’s even more incentive to document in a particular structure. I cannot comment further yet as Xcode 5 is presently under NDA. Nevertheless, documentation and documentation style is an important consideration in your coding practice. Because again, style is about making readable and maintainable code.

The Style of No-Style

Styles tend to not only separate men – because they have their own doctrines and then the doctrine became the gospel truth that you cannot change. But if you do not have a style, if you just say: Well, here I am as a human being, how can I express myself totally and completely? Now, that way you won’t create a style, because style is a crystallization. That way, it’s a process of continuing growth.

– Bruce Lee

My style is my style. It is what allows me to most effectively communicate. It is what allows me to best express my thoughts, in code, in implementing a solution to a problem. For me to use your style would get in the way of my effective communication, so why should I do it?

I look at modern programming teams. Typically they are comprised of many people of different backgrounds, and often these days, ethnicities and origins. I say this because not everyone on the team might speak English the same as you or as well as you. Joe speaks with a southern accent and phrasing, and Young-soo speaks more in Engrish. If we forced “1 true way” of speaking upon Joe and Young-soo, if we made them all speak in British English (colloquialisms and all), how effective would that be for the team? We’d never think of doing such a thing, yet it’s precisely what we do when we impose “1 true style” of coding upon a whole team. Does that really lend to effective coding? to effective communication and expression?

Or can we accept that there’s at least enough of a style, enough of a standard in place that allows us to get the job done with each member expressing themselves as best as they can? Oh sure, if we find ways to help improve our communication, we should improve (e.g. allow your style to evolve). Just keep in mind what a coding style is to be for, and work towards enabling the team to effectively express themselves and write successful code.

If you have no particular style, if you need to find some way to improve the team’s workings, adopting style guides such as the NYTimes Objective-C Style Guide can be useful. Even if you don’t need such a guide, consider what the guide has because there may be a new twist or technique that allows you to improve your code. For example, reading that guide reminded me about Xcode’s expanded support for literals and how BOOL isn’t quite what you think. If we can write better code, if we can more fully express ourselves, style is a benefit. Just keep it in such perspective.

Circular Piracy

Game developer, Greenheart Games, created a game about creating games called Game Dev Tycoon. It’s a familiar game genre, a sort of “Sims” about being a software game developer. I haven’t played it, but it seems cool.

But what I thought was really cool? What they did to make a point about piracy:

In a curious social experiment, the developer deliberately uploaded a full, cracked version of its game to the most popular torrent trackers. The cracked version is nearly identical to the real thing except for one detail. As players spend a few hours playing and growing their own game dev company, they will start to see the following message, styled like any other in-game message:

“Boss, it seems that while many players play our new game, they steal it by downloading a cracked version rather than buying it legally. If players don’t buy the games they like, we will sooner or later go bankrupt.”

Slowly, the player’s in-game funds will dwindle, and every new game that they create has a high chance to be pirated until they eventually go bankrupt. There is no way to fight it, in an ironic twist, players of the cracked version of the game are doomed to constant failure due to rampant piracy.

I thought that was pretty clever. It’s an old argument and issue for sure, but I like that because they granted the realities of the game they were making and that they were making a game, they had an avenue to make a point and they chose to make that point. So why make that point?  From their own website:

Game Dev Tycoon was created by two brothers. They invested all their savings to start a company and develop the game. They truly enjoy tycoon and simulation games and after seeing many of the new social and pay-to-play games where buying coins is more important than good gameplay, they wanted to bring some true simulation games back. Their motto is less social, less ville, more game and they believed that there is a market for real simulation games but as independent game developers it’s difficult to survive and the reason why so many companies create pay-to-play or coin-driven games are because they make more money with them.

If you like the look of Game Dev Tycoon and you want to see more games like these then you should really think about buying a legal copy of the game. The price of the game is reasonable (7.99USD), you get legal copies for Mac, Windows and Linux, free service updates and you can even install the game on a couple of your personal computers.

If you don’t care about all of this and just want to get a cracked and illegal version then we can’t do anything about that, but if years down the track you wonder why there are no games like these anymore and all you get to play is pay-to-play and social games designed to suck money out of your pockets then the reason will stare back at you in the mirror.

I’ve been writing software for 20-some years. I complete understand. I mean, I dealt with piracy before Napster and torrents. I do sympathize with any artist and person that wishes to make their living on “digital data”, be it software, music, movies, books, whatever — something that’s easy to copy and distribute. I sympathize because that’s how I earn my living and feed my family! I don’t sympathize with the way “Big Media” has gone about trying to enforce things because I learned long ago that pirates will always pirate and good people eventually will pay up, so long as they understand and are given reasonable terms. Since I have limited resources (time, money, energy), I can either work to make my product better or fight the people that I’ll never win over anyways; so why not please those willing to be my customers? Draconian DRM that hampers and just pisses off your legit customers isn’t the right way to go (witness: SimCity 2013’s rollout).

What it really takes to improve this situation is for the public to be educated.

The Klug brothers are right: if you want good things, you have to support those willing to make good things. If you like games like this, support them so they can keep making these things that you like. It’s pretty simple. It doesn’t matter if it’s your favorite music artist, movie studio, game developer, book author… whomever and whatever. These people have worked hard to produce something, something that you now enjoy and has made your life better. Is it fair for you to take and not give anything in return? Would you appreciate someone doing this with the fruits of your labor? Is the way we should get people to pay by forcing them with ugly DRM and shitty experiences (think about this next time you try to play a Blu-Ray and are forced to sit through FBI Warnings)? is that high quality? is that how you want things to be in life? Or would you rather be willing participant in the process and support those that make your life better?

Which way do you want it?

 

Realizing your potential, as a developer

Maybe that I’m a graybeard programmer means I’ve finally realized my potential as a programmer.

I’m reading this list of “10 Reasons Why You’re Failing to Realize Your Potential as a Developer“, and I’m just nodding my head the whole time. I’m going to add my own comments to the author’s “10 reasons”, so you should read the original article first.

1.  You’re too afraid of failure to learn new tools / languages / frameworks.

I’m not sure it’s fear of failure as to why people don’t want to learn other stuff. It may be as simple as having a comfort zone and wanting to stay there. It may be that they have a cushy job and want to keep it (maybe fear of losing job). There may be business reasons.

He’s right tho, that people are afraid of throwing away all those years of investment in X. The reality is, you are and you aren’t. You may well throw out a specific set of languages or frameworks, but so what? After you’ve learned enough languages, another is “just another language”. After you’ve learned enough frameworks, it’s “just another framework”. A lot of the concepts and approaches carry over, and it’s those things that matter more. You have a larger set of experience to draw from to solve a problem, to create an architecture, to see a flaw or a risk before it becomes too costly. Those things are far more important than you silly language wars.

It’s good to learn more languages, to learn more frameworks. The more you know, the  more cool stuff you can do, and ultimately the more valuable you can be. That said, be sure to acquire depth in those areas. Having a list of languages a mile long doesn’t mean much if you can’t actually be useful in those languages can can’t speak to the depth of what they offer.

2. You won’t push your commits until the feature is “done.” (It’s never done!)

I think this is “fear of what others think” or “fear of judgment” or “fear of criticism”. That people won’t think you’re a god, or that you’re stupid for how you’ve done things. This is a reasonable fear. We’re human, we have egos. The geek and programmer are held up as some sort of wicked smart superman and the exception is taken to be the rule. It also doesn’t help that there’s often someone on the team that doesn’t know the meaning of the word “tact” or even “polite” when looking at someone else’s code. We basically always think the guy before us was a moron and can’t believe they wrote such stupid code!

Screw it.

You will write stupid code. You will write imperfect code. Your code will have bugs. You are human. You are learning. You will do the best you can at the time you can with what resources you have. I find this is where comments are useful because they can expose the hidden “why” behind something. Maybe you have to write an ugly hack, but at least the comment can explain why you had to do it (because we had to ship right now else lose a multi-million dollar contract and the company would have closed up and none of this would have mattered then). It may not excuse the choice of hack, but at least it becomes understandable.

Just commit, often and early. In the long run it will suit you better because you’ll need to roll back or have a good checkpoint, so your workflow is better served by doing that. And in the end it really doesn’t matter WHEN you commit your code, because we’re always going to think it’s wrong and wonder what moron wrote it. 😉

3. You know just enough to be dangerous.

I’ll just say you need to read and understand, before you do.

Sometimes you have to “do” in order to fully understand. If so, take time on the side to write a small project that allows you to fully explore and come to understand it. Often tho, a little sample project isn’t enough and you just have to drop it into the larger more complex context to really grok it. But then this goes back to #2, where you should commit often and early, so we can follow what happened and unwind it when something bad happens.

4. Analysis paralysis.

This is a tough one, and one that only comes with time and experience. Plus, it’s different for each person.

You cannot sit there and analyze all day, but you must analyze and research some. If you don’t understand what you’re doing, then you only know enough to be dangerous and we come back to point #3. Or you risk going in half-baked and everything gets fucked worse than before.

But you also cannot sit there and just analyze it to death. Sometimes you just have to dive in. But then it goes back to #2. Commit often. Heck, make a branch, maybe a branch of that branch, whatever you have to do. Sometimes getting in there and poking at it is the only way.

There’s a balance to be had, and ultimately you just have to find it. Never lose sight of the fact you have to ship, because you need to make money, because you need to get paid and pay bills and such. So if nothing else, let that be a motivator to keep going, just don’t rush it.

5. You don’t invest in your tools or development process.

This is a pretty good one.

I’ll just add that scripting has been one of the things that has helped me. Eventually I’ll recognize a task that I perform often (enough) and takes (enough) time. I’ll also see the task is one that tends to be the same thing over and over, or maybe almost the same with just some small variation of input. That sounds like a perfect candidate for automation! So maybe it takes me a day or two to come up with a script or other mechanism to automate it. Fine. But now it’s a simple execution of the script and viola, the thing is done. Or the thing can churn in the background without my tending to it, and I can go tend to other things. In the end, I get more done in less time.

How does the saying go? “Efficiency is intelligent laziness.”

6. You’re too embarrassed to ask for help.

Don’t be. You don’t know it all.

On the same token, don’t be an asshole when someone comes to you for help. If someone comes to you for help, they are in need and believed you to be the best person to aid them. Help them, and don’t be a dick about it. And yes, that includes things like LMGTFY, or just saying “RTFM” or “did you use the search feature” or other shit like that. There are ways to help people become more self-sufficient, but being condescending isn’t one of them.

7. You don’t know how to make it easy for other programmers to work with your code.

Your code will outlive you. As well, once you have written code, it will have to be maintained… often by you, and chances are 6 months from now you won’t remember what the hell you were thinking when you wrote it.

Write clear code, clean code. Yes sometimes architectures have to be obtuse or complex. So document them. Explain them to others. Be sure to share the knowledge.

8. You don’t know how to read someone else’s code (or don’t want to.)

This goes back to #7, that you should make it easier for people to read your code. In fact, it goes back to #2, because you should be pushing your code to others and soliciting their feedback. Code review is good.

Granted, we shouldn’t get hung up on coding styles and coding standards, because someone’s will always be different from yours. So you need to learn how to read their “dialect” and forge ahead.

9. You can’t code from the end-user’s point of view (you think too small.)

This this this, so very much THIS.

We must always remember who we are coding this for. When I write a script (#5), I’m usually writing it for myself so if it’s quick and dirty, that’s fine. So long as I can make it go that’s all that matters. If it fails along the way, that’s OK because I can fix it. But if I was to make that same “automated task solution” work for someone else, I’d probably have to make it cleaner, clearer, I might have to put a GUI on it, make it more robust in the face of failure, etc..  It’s the same basic solution, but because of the audience the specifics and the end product are different.

We do not reside in an ivory tower. We must realize that we are generally not the audience and our take on things isn’t often the way it should be done. It was one then when I worked for Metrowerks, being a developer writing tools for developers, so often we could use our assumptions and biases and turn out the right features and approaches. But when I wrote Spring Cleaning and was writing an app to make life easier for non-tech-savvy people, that affected everything and directed how even things as simple as error messages must be written.

But also, don’t let this get you arrogant. I often hear that the customer doesn’t know what they want and so we must give it to them. Actually, customers often do understand what they want, but they have a hard time articulating what they want and may not know how to articulate it. But often they will know it when they see it. Thus it becomes OUR job not as a programmer but as a designer, as an architect, to learn how to draw this out of the end user. To step back, to see the larger trends, the directions, and the problems faced by our end users and then see how we can solve them to give them a solution that not only gives them what they want but in a way that’s better than they expected.

This isn’t easy, and it’s nothing a novice can do. But it’s a position for the novice to strive for.

10. You aren’t able to judge the business value of any programming task.

I will never forget Doug D.. Doug was a manager I had early on in my career. I was this idealistic programmer that enjoyed my ivory tower. I wanted to write perfect code, and do great things as a programmer.  Doug helped me realize that while that’s all good, there’s business to think about. It’s simple. Money has to be made. There has to be money to pay my salary, to keep the lights on, to pay my salary, to put Mountain Dew in the fridge, to pay my salary, to keep the business floating so we can keep our ivory tower alive and going to even bother with any of this code. If there’s no money, none of this stuff matters and our ivory tower of ideal programming goes away. So you have to look at the business side of things. You have to keep perspective. And sometimes yes, you have to not do something, you have to leave some task, adjust priorities, or even sometimes take a hack approach instead of a clean architecture. There’s just realities of business. Many times it may lead to ugly things that are more painful to recover from down the road, but that’s life… at least you stuck around long enough to have that longer road instead of having to pull up stakes miles and years back to find a new home.

Nothing will be perfect. We have to find balance and constantly juggle priorities.

Just don’t forget to grow and have fun along the way. 🙂

Commitments and Priorities

I saw the above image posted to the DangerouslyHardcore Facebook page. In case the image goes away it says:

Commitment means staying loyal to what you said you were going to do long after the mood you said it in has left you.

Very true.

I’ve had a bunch of things rolling in my head for a while, and seeing the above image/text along with something that happened in Wife’s life a few days ago… it changed my priorities regarding my commitments.

I had committed to being more involved in shooting competitions, like IDPA. That’s going down the priority ladder.

I had committed to working on a new iPhone app. This commitment was made some time ago, work started, but has been treading water for too many months. This is going up the priority ladder.

I only have so much time and energy. The app went down the ladder because after staring at the computer all day and busting my ass all week for the day job, I just didn’t have the desire to look at the computer any more. I was (am) drained. Other things went up the priority ladder because they were not-computer things. They gave me something else to do, something else to occupy my mind and energy. Plus they were things that needed attention.

Well… the lack of app commitment also strikes a little closer because this particular app project is very personal. It’s something I’m doing with Wife, and it means a lot to her. That I haven’t been able to give it the attention it’s due is not right, and I feel horrible. It’d be one thing to not honor the commitment to myself, or to anyone else. But to not honor this commitment to my wife? That’s not right, and that hurts me deeply. It wasn’t not honored out of malice or anything bad, just exhaustion. I need to do something about it.

And in some regard, the mood for the app has left me. It’s mostly because I’ve been away, had too many false restarts, and it’s just hard to get motivated yet yet yet again. But I know once I truly get back into it, I’ll roll along alright. I need to rediscover my commitment, and see it through.

So, since much of my “free time” is on the weekends, that means I need to spend it working on this app.

That means shooting matches is out, for now. I don’t expect the app will take me all year to do, so I reckon later this year I should be able to make it out to matches. As well, so long as I keep dry firing at home and regularly shooting, like when I go out to KRT to teach, that’s alright. I mean, if I can run through a few magazines, run a few drills, assess state of things, then go home and dry fire to bring up the skill, then go back and shoot to measure progress, really, that’s OK. That will hold me for now. That I’m just shooting live at least once a month is well, about what shooting competition would be. Granted, there isn’t any of the pressure or environment, but this is the trade-off for now while I live up to my more important commitment. I just have to keep up with dry fire and ensuring I put at least a mag or two through the gun (for myself, with purpose) when I go out to teach.

I’m not abandoning my commitment to shooting competition, just changing course a bit. I have to, because Wife is more important. 🙂  And hopefully it brings other commitments back, like more regular dry fire and practice.

I can only look at this as a good thing, as long as I remain committed. 🙂

WordPress fail

I downloaded the WordPress iOS app update.

Installed. Oh hey, this “Notifications” thing is new. Let’s go see.

Crash.

*sigh*

Relaunch the app.

Oh cool. They have some mechanism that autodetects the crash and looks like it can send the crash report…. oh the app just crashed again.

HA!

And now it’s caught in an endless crash loop. Launch app, crash detector comes up for a couple seconds, then the app crashes. Lather, rinse, repeat.

Just awesome. 🙂

 

Smart guns? Dumb idea.

So, Jeremy Shane thinks the solution to the problem is to “make guns smart”: (h/t Shawn)

While the debate rages on, it’s worth thinking out of the box for a moment. What if we could design guns to be smarter and safer — with hardware and software? The right technology could neutralize the killing capability of an assault weapon, even in a madman’s hands.

After reading Mr. Shane’s article, I’m not sure how much he knows about guns or software, but it comes off like he doesn’t know much. I’m a firearms instructor and have been a software developer for over 20 years, so I know a few things about both realms. Given that, while I applaud Mr. Shane’s imagination, I can say his ideas are best left to the imagination, as realization of them will not lead to the end goals he desires.

The root of the problem is that guns are “dumb.” Pull the trigger and they discharge bullets mindlessly, regardless of who is doing the aiming or where they are aimed. Guns should “know” not to fire in schools, churches, hospitals or malls. They should sense when they are being aimed at a child, or at a person when no other guns are nearby.

Most useful tools are dumb. We don’t have “smart” hammers, smart screwdrivers, smart knives, smart binoculars, smart blenders, smart cars… well, granted some things are starting to try to move that way, but most things understand that those “smart” devices can really only operate in dumb environments. No computer can process information as fast and as well as the human brain, can make the “instant” decisions that sometimes are necessary. The “touchier” the environment, the more humans are still needed. Even with all the safety technology being brought into cars, we still haven’t eliminated the driver because there are just some things the car cannot do and only a human can.

Should guns “know” not to fire into schools or churches or hospitals or malls? I don’t know… what if there’s an active shooter in a school or church or mall (since that’s where most such events have happened)? Wouldn’t you want the good guys to have guns that can work in those environments?

They should sense being aimed at a child. How would that work? Define “child”, as some sort of optical device would perceive them? I mean, I know some young teenagers that are larger than adults, some adults that cast child-like silhouettes. Mr. Shane also says “Sensory data can be used by built-in software to disable firing if the gun is pointed at a child or someone holding a child.”. Or someone holding a child… So a gun shouldn’t be functional if pointed at the person kidnapping your child?

You see, these are subjective decisions. How exactly can software make the sort of decision necessary? And even if it can, it takes time, time that may not be present as a horrible event is unfolding.

If you wish to have software attempt to make these subjective decisions, we have to remember that software is imperfect. It’s written by humans — who are imperfect — and software has bugs. It may not be robust enough. It may not be sound enough. It may hold bias of the programmer. I mean, for all my care and concern at writing bug-free code in my decades of programming, it’s impossible to write bug-free code. Do you want YOUR bug to be responsible for someone’s death? That it might not fire when you need it to fire, or that it fires when you don’t want it to fire? And then, who bears the responsibility for such a mistake?

Couldn’t gun software be hacked? Perhaps, but the risk can be reduced by open-sourcing code, requiring software patch downloads, and notifying gun makers or law enforcement if software is disabled. Open-sourcing code is not foolproof, but it will build a community of lawful gun owners and code writers who value safety and Second Amendment rights. Enabling two-way communication between guns and their original makers will help guns to be tracked beyond the initial sale, putting greater long-term responsibility on gun makers.

Nice thought, but open source code is still not bug-free and still can have horrible things happen. And there’s nothing here to address “software hacks”, but boy… what about viruses? what about social engineering? hardware hacks (I mean, why not just disassemble the gun and disable or replace the mechanism)? It’s not like DRM has really stopped piracy. It’s not like iPhone’s don’t keep getting jailbroken. There’s so many other things that can happen and be made to go wrong, to bypass, or to even force malfunctions. Wouldn’t it just be dandy if some virus was let loose that caused all these guns to rapidly empty their magazines at some coordinated time of day… all around the world… *shudder*.

There have been groups that have attempted such “smart guns”, and all have failed. Not only because the system itself doesn’t really work out, but because no one is willing to buy said “smart” systems. There’s no police nor military group that would want to buy such a thing, because they operate in environments where you may need to shoot multiple rounds in a school at a person holding a child. They understand these “smart” systems are anything but, and are too risky and prone to failure, and not worth risking their lives over. So you may say, only sell “dumb guns” to police and military. Realize then that still means such guns would be in circulation, and thus bad people will still get a hold of them. Of course, if you know anything about weapons fashioned and found in prisons, bad people will get weapons without your “smart restrictions” if they really want them. Even if somehow that’s all there is, there are going to be other “dumb” ways to cause mass destruction; look at Timothy McVeigh. So all these “smart” weapons would do is abridge and hamper law-abiding good citizens. Why do you want to do that?

You see, a well-made gun is actually a very simple mechanical system; it’s a simple machine. Once you start to add all of these things on it, start trying to add GPS, sensory data, target discernment, you start making for a massively complex system. And with any complex system, it starts to become… well… complex. Difficult. And prone to mistakes.

If truly you value life, should it be held to a system that can be massively complex and prone to mistakes? For all your attribution to car technology, Mr. Shane, consider how many recalls happen every year. A car is a massively complex system, and while it may work most of the time, you know all too well that cars break down and fail us. Thankfully most of the time car breakdowns don’t have life hanging in the balance. But when good guys need their guns, for certain lives are hanging in the balance — do we really want the risk of breakdown when preserving life is most critical?

It’s a nice thought, but technology cannot save us. Fixing our cultural and social norms and behaviors is at the root of solving this problem.

PracticeDeck 1.1.1 is now available

The DR Performance PracticeDeck for iOS 1.1.1 (or PracticeDeck for short) is now live in the App Store.

It’s a simple update, bringing iOS 6 and iPhone 5 compatibility. It also raises the minimum OS version to iOS 5.

Click/tap here to download it.

A year since we’ve said goodbye

A friend pointed me to the Apple website, because 1 year ago today, Steve Jobs passed away. Apple changed their home page today to post a video (linked here, but no idea how long this link will remain, or if it’ll move to a more permanent home eventually), a tribute and remembrance of Steve Jobs.

Yeah… it choked me up a bit.

I didn’t know Steve at all, but my first computer was an Apple //e, and the day I saw a Mac… it changed my life. I’ve spent over 20 years writing Mac and now iOS software professionally, so yeah… Apple has a place in my life.

At the end of the video you hear Steve say:

It’s technology married with liberal arts, married with the humanities, that yields us the result that makes our heart sing.

That’s what people tend to not get.

Sure, iPhone is behind Android in a lot of respects. In fact, in many respects Mac has been behind the PC/Windows. But in many other respects, Apple has completely lead the way in both the desktop Mac and mobile iPhone world (and let’s not forget the music iPod world either). And the biggest leader is Apple make products people want to have, that people yearn to have. Who lines up for the midnight release of any product? What other customers find opening the box to be a religious experience? that a product, a service, a brand creates such intense devotion… to plastic and silicon?

There’s an aesthetic.

I see Android devices all day at my day job, and I just can’t like them. Same with Windows vs. Mac. Oh sure, I can totally appreciate the technology going into them, both the hardware and the OS. I think there’s actually a lot of cool stuff about Android as an OS. But it just doesn’t sing to me. It doesn’t move me. I don’t look at it as a joy that I like to look at for hours every day, which is what I have to do. If I have to stare at something for a long time, I like it to be pleasing to the eyes (like my wife), and somehow stir my soul (like my wife).

To some people, they don’t care. These things don’t matter to them. And that’s OK. To some it’s pure utilitarian, or they don’t know any different or don’t care. And that’s fine. That’s them.

Me?

Well, speaking of Steve… if you consider his background with typography and how that influenced the development of Mac. Just the other day I read about a new programmer’s font, the article mentioned a few, I downloaded and tried them out, and settled on Source Code Pro. It’s a beautiful font. It’s a lot nicer on the eyes, and when you’re staring at code all day long well… the shape and placement and count of pixels really starts to matter. And you probably don’t realize it, until you start to care and do something about it… like change it. But there’s the joy of Apple. They spend so much time fussing and caring about every little pixel, every little detail. The intent? To just work. In some respects, it should be remarkable; “Any sufficiently advanced technology is indistinguishable from magic.” But really in most respects it should be unremarkable. It should just work, it should not get in our way, it should not impede the flow of our work, it should enable and empower us… and we don’t really notice nor understand why. And even something as simple as a font can do this. Does that matter? Yes it does. And Steve knew that. Many people don’t know, don’t care, or aren’t aware… and that’s fine for them.

Not me.

Think different.

Happy Programmer’s Day

Happy Programmer’s Day to my fellow programmers!

Oh wait… you mean it was yesterday? Ah that’s right… leap year. So that means this is an “off-by-one” error. How appropriate. 🙂