usable in any place a human can be used

20100331

micro-optimization

[caption id="attachment_818" align="alignright" width="277" caption="Yea, I know it\'s on fire, but check it, I almost got Freebird down pat."]nero fiddling as rome burns[/caption]

As all good developers should know, one of the cardinal sins of software development is premature optimization. Premature optimization is bad for a whole host of reasons. But there is another set of optimizations that are in the same realm of bad, micro-optimizations.


I recall learning at some point that in C and C++ it is more efficient to use the pre-increment operator rather than the post-increment operator. Why is this the case, well it's because of the minor difference in behavior between the following two snippets.


[cpp]
int source = 10;
int destination = 0;

destination = ++source;

printf("Destination: %d", destination); //Prints "Destination: 11"
[/cpp]

Compare with this snippet


[cpp]
int source = 10;
int destination = 0;

destination = source++;

printf("Destination: %d", destination); //Prints "Destination: 10"
[/cpp]

WHA!? This is actually exactly what we would expect, pre-increment increments the value BEFORE assignment while post-increment increments the value AFTER assignment. What does this all mean, well basically that if you use post-increment you are executing more instructions, because the compiler has to keep the old value around to return to the assignment. That means that unless you are assigning the value and require the particular behavior that post-increment gives you, you can generate faster code by using the pre-increment operator (this may be handled by compiler optimizations these days).


All of the for-loops that you've written for(int i = 0; i < something; i++) are identical to and SLOWER than for(int i = 0; i < something; ++i). NOOOOO!!!!! Don't worry though, because this is a micro-optimization, its something to not care about, because in reality that one or two extra machine instructions isn't your bottleneck. Micro-optimizations are all those tricks that make code faster that in the vast majority of cases (although not all cases) don't really amount to any actual noticeable performance gain. A new processor can do something in the magnitude of 100,000 MIPS (Millions of Instructions Per Second). Every second it does 100,000,000,000 Instructions, that is 100 billion instructions. every. single. second. Changing from post- to pre- increment saves 1 or 2 instructions, so for every time that gets executed you have saved a 100th of a nanosecond.


Micro-optimizations are rarely worth the hassle, and, as with premature optimization, the solution is to benchmark and trace where your actual bottlenecks are and go about solving those. It doesn't matter if you're screaming through your increments saving a whole nanosecond if your crappy no index having table is taking a whole minute to read because you are doing a table-scan.


But wait, there's more. Micro-optimization, like everything in programming, can be directly applied to life in general. I work with a person who will spend 5 minutes discussing how to save 30 seconds, this is another incarnation of the micro-optimization. It's that shortcut you take home that actually takes longer, or some everyday voodoo that is draining your time without paying you back, or that client that provides you with 2% of your income but eats up 40% of your effort. Micro-optimizations abound all around us, in the little picture they seem ok, but in the big picture they are nonsense. Take a fresh look at the things and obligations around you and examine them for micro-optimizations, see if the things you do make sense in the big picture.

20100318

kids writing code

[caption id="attachment_810" align="alignright" width="311" caption="you doody head you forgot to clean up your EventStruct!"]3 children at a computer[/caption]

Last night I went out to get some dinner and as I sat in the drive-through waiting for the unbridled joy that is Cain's chicken I listened to the radio. WOSU's All Sides had a piece about child poverty and mentoring. It was interesting and thought provoking, one of the guests said something that rang true and made me think. (Paraphrasing because the audio is currently unavailable) He started to realize that the kids were excited to have him come talk to the class every week, not because they were interested in his stories about the Post Office, but because they wanted to know that someone cared about them. It was a powerful thing to remember, that children need to know that someone cares for them, and that not all children are that lucky.


In writing this blog one of my favorite memories is doing the research to write the teaching post. It reminded me of the heady days of my youth spending hours inside of the amazingly good QBasic help file trying to get something to work, stumbling and bumbling, put beaming with pride and a giddy happiness when I finally got the program to work. These days the amount of programming languages geared towards teaching have only expanded, and systems like Alice put LOGO's turtle graphics to shame (although I still love that LISP-laden turtle).


This started the old gears turning in my head, and although this thought is pre-pre-alpha, I thought I would get some feedback and just jot down what I'm thinking. What if there were an after school program for elementary school aged children where IT professionals donated their time and talent to helping kids learn how to program. Children need mentoring, the IT community has a wealth of talented and caring people, let's put these two things together and see if we can do some good. The logistics of this are a little daunting, but I want to lay out the reasons why now is the right time for just such a program.


Programming is the new literacy. Don't believe me, here is an article entitled Programming is the new literacy. As we move forward into an increasingly wired future, programming, scripting, mark-up, are going to become skills that are normal to have. Children are already more "plugged-in" then ever before, the benefits of understanding the machine they've been using since they were in diapers is apparent. As the information economy continues its march into the 21st century, people will need these skills. From a simple formula in an Excel Spreadsheet to whipping up a ruby script to do batch processing, these will become the differentiators of tomorrow, helping people achieve.


Hardware has never been more accessible. Moore's Law is a thing of beauty, I just bought a more than capable HP refurb for $150 to act as a media server. OLPC has shown that putting affordable computers into children's hands is possible, and it looks more and more likely that school districts in the Industrialized Nations will be following suit in the next decade or so. Companies routinely donate their old computers which means that if $150 is too much (which it is for a lot of low income families) then you can get a donated computer free. Children can also access computers at libraries and schools for free.


Software has never been more accessible. The number of languages specifically targeting teaching has only been growing. If you haven't already, go read the teaching post, it is a round-up of just a handful of the neat and nifty software meant to help kids learn to program. The learning curve has never been gentler, you can go from a learning language like Hackity Hack (which is based off of Ruby) to the full Ruby language fairly easily, and from there you can explore the whole world of Ruby development from Rails to Unicorn and back again.


Programming is about more than computers. Although the immediate goal of learning to program is to instruct a computer in how to perform a given task, the side benefits are immense. Programming teaches children a structured way to solve problems, learning about control structures teaches the ideas of Boolean Logic, writing formulae increases and reinforces the understanding of mathematics. Programming is also empowering, being able to sit down at a keyboard with nothing more than your wits and a good idea and turn it into something real is an amazing feeling for a child. Programs let children learn and explore, make mistakes and figure out how to solve them, with gentle encouragement and careful guidance a child can turn their ideas into reality, and that's a powerful lesson.


Where to go from here? I'm not exactly sure, the logistics of setting something like this up are a little out of my league. For right now this is just a good idea, I'm at step 3 of the idea ladder. Leave a comment, let me know what you think, if you are a parent, would this kind of program interest you? If you are an IT professional, would you volunteer at such an organization? If you are a business owner, would you support such an organization? If you are a child, would you like to learn to program?


I'm not sure where this idea will go from here, but I'm excited to find out.

20100317

let me google that for you

[caption id="attachment_805" align="alignleft" width="300" caption="I wonder what Google\'s legal team thinks of this website"]let me google that for you[/caption]

I was recently given the task of writing a Windows Service in Managed C++ (or C++/CLI I can't quite figure out what it's actually called). Having had 3.5 years of C++ experience from college and basic literacy I started clicking around in Visual Studio like a blind man searching for a nickle. Everything was going great until I got to the code it generated... there were ^'s and gcnew's and all kinds of craziness. It looked like the Standard Template Library and C# had gotten together with a bottle of tequila, the next day C++ was knocked up and throwing up carets all over the place. This was not the C++ I had learned back in college on our quaint little Unix box editing code in pico, this was some new monster that vaguely resembled an old friend. Undaunted I clicked this link and began the journey on the road of enlightenment. Right now I have a Windows Service that builds and hopefully over the next few days I can confirm that it actually works.


This got me to thinking about the vast wealth of information sitting literally at our fingertips. I recalled the phone call I had with my mom over the weekend that went something like this.



Mom: They asked me at work to archive some files by burning them to a CD.
Me: Oh, how'd that go?
Mom: Well I had to use a Mac, and I don't know those so I asked for help.
Me: Makes sense.
Mom: The only person who knew how to do it said to use Toast, but that wasn't installed. :(
Me: What did you do?
Mom: Well I thought, how hard can this be, googled it, and followed the tutorial, it was really simple.
Me: You've just taken your first step on the road to geekdom, congratulations.

The dirty little secret is that for anyone that's good with computers, unless you ask them a question directly in their area of expertise, they might have some vague notion but will more than likely just end up Googling it. "My computer crashed and the BSOD said STOP CODE 0xA70000084, what does that mean?" What you will hear on the other end of the phone is me biding my time while I type "STOP CODE 0xA70000084" into Google and look for the answer. Because, and this may surprise everyone who is not a computer person, having a CS or MSI degree does not mean that you programmed Windows. There is a world of stuff for us programmers to try to hold in our brains, and every error code shooting out of Redmond is low on the totem poll.


If all us nerds are just Googling things, then why don't normal people do it. We know that everyone Googles stuff: "Naked ladies", "Hot naked ladies", "Other naked ladies I haven't already seen", "How to erase your browsing history", etc. Why don't non-technical people think about typing that perfectly searchable error code into that happy little textbox? There are a litany of reasons from laziness to sloth, but I think the one that most people fall into is intimidation.


Google is power!!! You ask it a question and you get a list of a gajillion results. Don't believe me, I'm going to search for blue screen of death and it returns 9,710,000 results in less than half a second. If you are a non-technical person that is a sea of information, its even worse for technical problems, as the most relevant links are normally some discussion board with a thread 900 replies deep, the solution normally some incantation you chant over the motherboard while spraying the monitor with goat's blood. For the technical doing things like digging around in the System32 directory and clicking around is everyday no big deal stuff. For the non-technical, who normally have the "I hid this for your protection, don't touch these files or your computer will explode" screens still on, it can be a terrifying leap of faith.


[caption id="attachment_806" align="alignleft" width="300" caption="for a normal user this is like a grizzly bear with chainsaw arms"]system32 scare screen[/caption]

The thing that we can do to encourage our non-technical friends and families is to teach them to fish. Normally we just want to give them a fish and get on with our lives. When you take the time to explain how resilient a computer is and how easy it is to find the information, after a while they will come around to solving their own problems. And it's like sweet sexy meth when they do. Try to remember what it was like to have that thrill for the first time of being able to command the computer to do your bidding, once they get a taste they will want more, which may actually end up being more work for you, but it's the good kind of work that furthers another's understanding of the world.


Drop some lmgtfy love on your loved ones, help them help themselves, introduce them to the intoxication of solving their own technical problems. Once people realize that computers do what we tell them and not the other way around, the world will be a much better place.

20100316

ideas

[caption id="attachment_800" align="alignright" width="234" caption="In the future, we will rule this world!"]chimpanzee in classic thinker pose[/caption]

Ideas are interesting things, we have them all the time, we dismiss them frequently, and we value them heartily. Some people don't like to talk about their ideas, don't want people to steal their million dollar brain baby, and I can respect that, but a million dollar idea with zero execution is worth nothing.


Ideas, like misery, love company, if I tell you an idea your brain will immediately start thinking about it, having its own ideas and interpretations. Then you tell me your ideas that my ideas caused and I get more ideas and so on and so forth, this is the basis of a conversation. That our ideas can grow and change organically, that we can piggy back off of each other, this is the basis of our society. But let's get out of the woods of the abstract and into the city of concrete.


What I want to talk about today are those entrepreneurial ideas that we all have from time to time. Those things that you are certain will make you rich and famous, or the ideas that leap back into our minds when we see some new thing, a worldwide pornography distribution network, Tim Berners-Lee stole my idea! What should you do with these ideas, how should you handle them, and why and what and huh.


Every person will have their own way of handling the little lightning bolts that leap into their head but I want to take you through the path that I've found helpful for me.



  1. Write it down - I write down almost every business thought I have, no matter how far fetched, and no matter how overloaded with tasks I am. This seems a little silly, if you are actively working at one thing it can even feel disloyal to start thinking about something else, what am I a squirrel easily distracted by a shiny piece of tinfoil? No, in my opinion you can never have enough ideas in reserve. It doesn't take too much time to jot down enough information to be able to recall it later, and it doesn't mean you aren't serious about your current set of priorities. We would all like to think that everything we are working on will always work out, but you will never be sad that you have more ideas to fall back on.

  2. Percolate - Go do something else, even if you aren't actively thinking about something, after writing it down it will be floating around in your brain someplace. Great ideas refuse to fall to the wayside, if you find yourself coming back to something in your head more than a few times, move onto step 3.

  3. Talk it out - Share your idea with other people, sanity check it, see if they laugh at you. Don't get discouraged too easily though, great ideas can sound crazy and still be great ideas. After discussing it with a few people you can get a handle on how realistic it is and how excited you should be about your new idea.

  4. Prototype or Shelf - If you've made it to step 4 you have to look around and prioritize, it's easy to be swept up in the novelty of a new idea, but strive to objectively adjudicate whether or not you have the free time to move forward. If you do, grab some technology you are comfortable with and make a prototype, don't invest too much time or money. If not shelf the idea, keep a short list of things ready made to work on and add this idea to it.

  5. Focus Group Lite - If you made a prototype put it in front of some people, or float a pilot program. See how people react, sometimes an idea can sound great until you see it, then you realize some fundamental flaw. If this stage is good then move onto step 6.

  6. Jump in with both feet - Get cracking. If you have the time, passion, and indication that people could use your idea, go for it. It will be difficult and you will probably fail, but you will be better for it.


Ideas are nothing without execution, but they are still valuable. Make sure you save your ideas, bounce them off of other people, and if your gut and other people tell you to go for it, take the chance. You may not always succeed, but you will rarely be disappointed that you tried.

20100309

100th Post Review

[caption id="attachment_792" align="alignright" width="300" caption="smile for now, soon I will devour you!"]monkey and tiger[/caption]

Here we are, my 100th Post! I'm going to give you an unprecedented look behind the scenes of ihumanable.com to see the magic that is my technology blog.


This blog started on October 2nd, 2009 (158 days ago). I have had a great time writing and have more or less kept up with my goal of blogging every weekday. I want to recap the numbers so far, talk about the best parts of the last 158 days, and talk about where I plan on taking this blog in the future.


By the numbers



  • Posts: 100

  • Comments: 440 (239 rejected as spam)

  • Subscribers: 183

  • Visits: 32,395

  • Pageviews: 46,664

  • Most viewed post: hustle


Best of the blog


It is hard to sum up what has been my best experience so far blogging. This blog has always served as a dumping ground for my day to day thoughts about developing software and exploring the fantastic world of technology all around us. One of the best outcomes of this blog is getting to know other bloggers, people who you may not always agree with but that are friendly and thought-provoking. Some of the great bloggers that I've had the pleasure of communicating with more through my blog have been:



I have had a few of my blog posts go viral mostly through the amazing community at Hacker News where I occasionally submit a post. My biggest honor by far though was having hustle featured in Lifehacker. It came as a big surprise to me, I got some pingbacks and before I knew it my server was feeling the squeeze, but thankfully (and with a little help from SuperCache) it stayed up.


If I had to pick my all time favorite post though, it would be one of my snarkiest, rantiest, and at least in my humble opinion, funniest posts to date. Making a sandwich, it's not a very funny title, but if you haven't read it, click through, it will at least make you smile.


This blog has been a great source of strength and a fantastic point of release for me over the last few months. I have used it to share my triumphs as well as my despair. It has been my megaphone, my confessional, and my soapbox. This has been the home of my baby and has sparked numerous discussions and debates that have made me a better person.


Into the future


After 100 posts, is there anything left to say? Of course there is, I plan on continuing this blog for as long as people still want to read it, and probably a good while past that as well. I recently attended codemash and the one thing I remember most was sitting at a table blathering away like normal and my good friend Jose says, "I didn't understand how you could blog everyday, but now that I've spent a few days with you I understand completely." Suffice it to say, I have a lot to say and I can't wait to start saying it. I'm not sure what I will fall in love with next, but rest assured you will be kept fully informed.


Takeaway


[caption id="attachment_795" align="alignleft" width="300" caption="the blogspot version of ihumanable.com... humble beginnings"]blogspot version of ihumanable[/caption]

Here is what I want you to take away from all of this. I started this experiment in social media with a simple free blogspot blog and a twitter account. I scaled out to this WordPress install on my own domain after I got a bit of a following. Then I just wrote, and I kept writing, and I promoted what I thought was important or particularly good, and you can too. For years I wanted to blog and just kept putting it off, one excuse or another would pop up. Then one day I decided to do it, and I made a deal with myself that I would blog every weekday, and I kept that promise (with a few extenuating exceptions).


There is no time like the present, if you have something to say, fire up a free blog and start typing. At first you may just be talking to yourself, but over time people will listen, people will comment, people will come to understand you and the things that are important to you in a way that they never could otherwise. There is no reason to hold out now, go out there and make a mark, you may be barking at the moon but it's better then staying quiet and wishing you had later.


Thank you to everyone that has taken this ride with me so far, the last 100 posts have forever changed the person that I am, and I'm excited to see where the next 100 will take me.

20100308

settling in

[caption id="attachment_787" align="alignright" width="209" caption="No, no, not you Hugh Laurie"]House surrounded by prescription bottles[/caption]

Here is a rare post, something not bitching and not about technology. Let's say that this is a meta-post, a kind of explanation for why my posting has slowed down the last week and some personal news. First to address the slow down. Last week I had the luxury of experiencing business travel for a whole week!. Now to the grizzled road warriors out there who do this all the time I will come off as a whiny little boy, but I didn't have the time (nor the internet connection thank you very much Merrillville Courtyard) to do much blogging with the 10 hours of meetings daily. Don't worry though I have some good thoughts ruminating from the experience.


Secondly I have just moved into my *fanfare goes here* new house with my lovely girlfriend Heather. Having these two events juxtaposed was a bit stressful and difficult, but we pulled through. Trying to merge all of our stuff together and get everything in order is a bit trickier than just git merge matt heather. Its very much worth it though as we now have a lovely little home to call our own and my dog has a backyard to play in instead of tearing up my apartment.


This is going to be a short one today, I've been keeping busy working my 9 to 5, my side projects, traveling and blogging and releasing point-releases of Prosper. Tomorrow I will post my 100th POST!!!. I hope to make it a good one, it will be full of numbers and analytics, lessons learned, people met, and the story of how my inability to shut up has turned into a somewhat successful blog. I hope you will all enjoy it, but you'll have to wait for tomorrow.

20100302

macgyver

[caption id="attachment_781" align="alignright" width="216" caption="All I need are these everyday objects — a toothpick, some liquor, a gun with no bullets, bullets, and three of my MacGyver writers. "]McGyver[/caption]

So it's come to this, a blog meme post. Every so often in the hallowed world of writing content for free to be distributed to people that you don't know for no particular reason other than hearing your fingers clickity-clack, you meet someone else doing the same thing and they challenge you. Considering that this is a hobby built upon the sturdy foundation of honor, glory, and red bull, you must rise to meet this challenge, and write a themed blog post. David Stein started this and it continued to Brent Ozar who has called out my name in the darkness, to answer the call to write about: My MacGyver Moment.


Now I've written about my favorite MacGyver Moment before in a previous post toolmaker, the time that I wrote an automated PL/SQL to T-SQL translation program. In that post though the MacGyver moment played a small roll and didn't get the attention it deserved, so I will go into its history and explain it in greater detail.


The seed is planted


[caption id="attachment_782" align="alignleft" width="300" caption="This is how MacGyver would solve most of his problems in the future."]jack o'neill shooting a p90[/caption]

It was my last semester in college, I had finished up all the required course work and just needed to take some 400-level electives to finish off my degree. I looked through the catalog and found a course that looked interesting, "Language Design and Implementation." The course seemed exciting for a few reasons, the professor had worked as a professional compiler writer for years and was a decided brilliant and fun teacher, the course work included building a compiler, and compiling source code was a part of the development chain that I had a theoretical understanding of but was still somewhat of a blackbox. I signed up for the course, it was fun, it was hard, I built a compiler (for a made up language called LITTLE targeting the JVM), and I learned a lot. I learned about parsers, tokenizers, compiler optimizations, bootstrapping, and a hundred other interesting concepts. The value that I took away from the course was a litany of problem solving techniques and an appreciation for what runs under the gcc hood.


The problem


My company sold some software. Doesn't seem like a problem at first, in fact, it's how the company does all those little things like pay my salary, so it's actually a good thing. The problem was that the software was written to run on an Oracle backend and we sold it to an organization that only had a SQL Server backend. There we sit looking at a mountain of PL/SQL code that does everything from execute a simple search to closing out and actualizing a fiscal year. 60,000 LoC representing tens of man-years of effort. Take this and put it in an extremely aggressive timeframe for porting and limited resources... suddenly the problem is easy to understand.


Bubblegum, paperclips, and string functions


60,000 lines of PL/SQL needed to become T-SQL, looks like compiling code to me. I knew my source language and my target language, time to write up a parser, tokenizer, emitter, etc. Then I noticed something while scanning through the PL/SQL, the problem domain was constrained, although PL/SQL can be constructed in a number of permutations all syntactically different, this was not the case. This PL/SQL was very uniform in construction, I didn't need all the pieces parts of an actual compiler. I didn't need to tokenizer and parse into abstract syntax trees for emission into the target language, I could just cheat, there were only 3-4 syntactic structures present in the source file.


I began writing the translator, after quieting that part of my brain that was telling me I was wasting time, just trying to avoid the unpleasant task of translating this by hand. Hackity hack hack, code is complete, hack up some nifty progress bars, run run run... translation complete! I looked at it, not quite perfect but I would estimate that the success rate on translation was around 99%.


The lesson


Sometimes hacking up a kludge to transmogrify data is the best course of action. Shutting up the part of your brain that doubts your ability, or the part telling you to do something the "right way" is the best way forward. Learning something for no other reason than that it seems interesting can provide you with the tools necessary to solve thorny problems down the road. Sometimes you really can defuse the bomb with a rubber band, #2 pencil, and thumbtack.

20100301

prosper 0.8

[caption id="attachment_248" align="alignright" width="128" caption="prosper"]prosper logo[/caption]

As the "pay the bills" work has gotten more fast and furious these last couple of months, Prosper development has started getting less and less priority. Today though I would like to announce that Propser v0.8 is officially ready for consumption. This is still a pre-1.0 release so its use in your multi-million dollar project should wait a while still.


Prosper is currently very stable and its stability is increasing as Unit Tests are being written, ferreting out many tiny bugs. Right now the MySQL and SQL Server adapters are the most heavily tested adapters, but full test coverage is a priority before the 1.0 release.


There are a lot of new things to be excited about, a new AREL inspired way to handle result sets by making the query object itself iterable. This new semantic way of working separates processing from execution and provides a nice new way to interact with the data backend. Support has been added for the GROUP BY and HAVING SQL clauses.


Prosper has a new home http://prosper-lib.com which will be getting a snazzy new design just as soon as I free up a couple of hours to make one. I have worked with the incredibly talented Ashley Kruso to get a new logo designed for Prosper.


Big thanks to Ian Potter who provided bug reports and even some nifty patches that have been incorporated into this release. It's your turn to go forth, play with Prosper, and submit to me feedback. Happy PHPing.