Signs you’ve gone too far teaching your kid to code

You’re a parent of a brand new snuggly-size manifestation of humanity and you couldn’t be more excited! You’ve called friends, family, and even told the gas station attendant. There’s no greater moment, but when do you introduce the child to your way of life? When should you explain how awesome writing code can be? Is it slightly after the first diaper change? Do you wait until baby’s first steps? Is it too late once they’ve learned to crawl??? When you start the lesson how do you know if you’ve gone too far???

Hi, I’m Cliff. You’re here because you have young kids at home. You might be thinking, like I once did, how cool would it be to get them into this fantastic field of software engineering. I had the true life experience of schooling a 7 year old in the art of coding. I was using Scratch at the time. It’s an app that teaches young kids to code using colorful little puzzle pieces and a cat that you can animate. It was so much fun yet so limited. I found myself going into source to make modifications while I was teaching. I felt the need to support pointers, robust opcodes and other things. I was also frustrated with the lack of an interactive debugger. When making the cat play in the grass lead to my pulling up Smalltalk tutorials I knew I had crossed some line. I just didn’t know which. How do you know you’ve gone too far with your little one? Here are some of my examples. Some are contrived, many true. Others are slightly exaggerated.

You know you’ve gone too far when…

  1. Baby’s first “hello world” ends with a segfault.
  2. The keyboard and monitor are both angled away from her and toward your general direction.
  3. You start pondering how to check puzzle pieces into Subversion or Github.
  4. Bed time has come but you’re still explaining the significance of bit-masking.
  5. Stacking all those puzzle pieces together is a dumb way to do it, you need a callback!
  6. Your explanation of the merits of event based coding outweighs the kid’s desire make the kitty walk.
  7. A while loop is a stoopid way to do it, you need a callback!
  8. She should stop whining and focus on getting the unit test to turn green!
  9. If she would just stop recording her voice and let you show her how to actually code something…
  10. Using a “wait” is a stoopid way to do it, you need a callback!
  11. You could make the ball move left instead of right if the dumb IDE editor only had an interactive debugger!
  12. You just figured out how to step through source in Scratch
  13. Someone has to remind her that we just made a callback for that function…
  14. A Gradle plugin sounds like a good idea.
  15. She needs to stop copying silly audio clips in the project and work through the scoring algorithm!
  16. See, wasn’t that fun? Look at the multi-module masterpiece she just made (without setting a finger on the keyboard)!
  17. We just have 4 more levels to complete before the game is ready to ship. (After lesson 1)
  18. For the love of peanut butter!!! Why can’t she use the callback???
  19. “Yes dear, just 10 more minutes while we step through source…” becomes an unconscious reply.
  20. She asks you, “Daddy what’s a Jira and why do we have to file one?”
  21. A database just became an integral part of your app.
  22. You opened your first JDBC connection in Scratch.
  23. You’re celebrating because she just fixed the Jenkins build
  24. You explain to the wife how the tears only started when the address to the screen refresh routine became corrupted.
  25. Add some of your own in the comments below…

Xcode Local History

I found a hidden (gem) feature in Xcode today out of desperation. As I find myself bouncing from Intelli *Ahem* Android Studio to Xcode I often miss features from the former IDE. Hi, I’m Cliff. You’re here because you screwed up a source file and need to recover. Your project was probably completely functional but then you made some random edits and now you cannot figure out which change broke which thing. Don’t commit often? Then you probably have this problem frequently.

The way out lies in a hidden feature of Xcode, something we Java lovers have been spoiled by for years… Local History! That’s right, Xcode actually auto-saves revisions of your files as you work the same way Eclipse and the IntelliJ platforms do. The only wrinkle is that while Xcode does maintain a local history there is no history viewer in the IDE. The trick is to open the source file in TextEdit then click “File -> Revert to -> Browse all revisions” from the menu bar. You will be dropped into a Time Machine like interface for the current file where you can cycle back through the various edits. This interface, though more dramatic than what you find in the Jetbrains suite of tools is not as functional. For example, you cannot see a record of when tests passed or failed, only time stamps. Also, lacking a hot-key trigger, it requires 3-4 steps to coordinate. You must right click inside the source file in Xcode, choose “Reveal In Finder”, drag/drop the file into he TextEdit icon in the dock, optionally open TextEdit if you don’t have it pinned, then do the file menu dance. Still it is an incredibly useful tool which just might save my bacon today since I changed something and can’t figure out what it was.

Got that job at GE!

I just started at GE and here they go with this brand new ad campaign! It’s so timely and SO true…

All joking aside, this is one of THE best companies I’ve worked at. They’re doing big things and I get to be a part of it early on. None of the stuff is old fashioned, it’s all cutting edge tech, more so than I’ve seen at other places. (For those of you following me on Twitter I sent the wrong link to the #CodeNewbie chat… FAIL!)

MS Word Wins the Copy Paste Test

You want to grab the guts of a web page and save it for later. You don’t want the hyperlinks on the bottom, or the ads along the side. Just the important stuff right in the middle of the page. Click, drag the blue selection around the interesting part, right-click and copy to clipboard. You could paste into Word but you recall the recent install of Pages on your new Macbook Pro, the Apple equivalent of Microsoft Word. You quickly create a blank Pages document and paste but have disappointing results. Hi, I’m Cliff. You’re here because you wanna know which word processor would win in a Kung Fu fight between Word and Pages. I’m here to announce that Microsoft Word (as much as I LOVE Apple and Pages) puts the roundhouse on Pages in the copy/paste match. I kind of expected more from Pages, though I’e performed this test in the past with similar results.

The test goes like this. You copy some arbitrary web content, open a new document, paste the content, and hope things look similar to how they looked in your web browser. This is such a natural abuse of a word processor that MS Word almost never disappoints. The exception is the rare occasion when there is specialized Javascript and/or CSS involved that caters to a certain environment. Pages seems to get most of the formatting correct but ignores tables in copied content. Again this is not the first time I’ve attempted to copied a partial web page into Pages nor is it the only time I’ve had a disappointing outcome.

MS Word Table
Couchbase Network port table copied into Word

Pages Table
Couchbase Network port table copied into Pages

My experience with Pages vs. Word is different starting from “File New”. I don’t know why, but I feel more comfortable working with Pages. This may be why I keep trying to use it instead of Word. Apple concedes that Microsoft “knows” productivity in the latest iPad keynote and this example of how Word can simply “produce a copy of content” reinforces that sediment. Still, I am routing for the upcoming rival.

And the extra point!

Part 1.5 in my quest to code for the out-dated Kinect model 1473 on an outdated Macbook pro from Mid 2010: I was never, EVER able to get Processing to control the tilt of my Kinect sensor, but now it seems as if I have that working as well! Again, things do not match the documentation/instructions 100% but with enough experience you learn where to look to resolve your issues. I Googled for “kinect tilt libfreenect” which turned up a complaint from someone that they were getting an error when running the libfreenect-glview command.

upload_firmware: failed to find firmware file.

I noticed I was getting the same weird error when running the command to test my install. It turns out the error is explained in the bottom of the FAQ on the site:

I get the following error accessing microphones: upload_firmware: failed to find firmware file.

The Kinect audio system requires a firmware to be sent at runtime. It should be found in your installation (in share/libfreenect/audios.bin) but it might be absent. Run share/libfreenect/ to download the latest audio firmware file and move it to your installation.

Apparently you need the audio firmware in order to interact with anything more than the camera and depth sensor. There is a “” (FirmWareFetcher) Python script bundled in the libfreenect install that will fetch and install the driver for you. Running this command is not possible out of the box because it requires root privileges and is not executable. You have to run “sudo python /usr/local/Cellar/libfreenect/0.5.1/share/” (The location of the script may vary, this is its location when you install via Homebrew.) After the Python script downloads the Firmware it will crash while extracting because of case sensitivity in the path. It looks for all files under a root folder “$systemupdate” in the zip file but the file name as of the current firmware is “$SystemUpdate”. Opening the script and doing a find/replace “$systemupdate” with “$SystemUpdate” will fix the script so that it downloads and installs the driver correctly. After the install of the driver the audio and tilt devices should be operational both from native code and from the Processing wrapper.

Happy coding!

Random success story – black triangle!

Let’s say you’re plugging away at your Mac following a tutorial on getting started with Kinect 3D programming and you’re getting no where. No matter what you try you cannot get your screen to look like any of the examples as your Mac throws error after error. Hi, I’m Cliff. You’re here because you’re having a fight with your computer. You want it to draw fancy 3D imagery of your living room but it wants to remind you that it does not SEE the $99 piece of equipment that you overpaid for in 2013 just prior to the release of the newer fancier pricier identically functioning piece of equipment. I’m here because I just had a “black triangle” moment.

What does a triangle have to do with Kinect?
Anyone who has done anything with 3D programming has had at least one, what we call, “black triangle” moment. These are milestone moments where you accomplish the next big thing after spending at least an hour perusing random documentation. The term “black triangle” (coined by someone I can’t recall, my Google-fu is weak today…) comes from the typical “hello world” example you will find when learning 3D programming. Usually it involves a mild math and/or geometry lesson, along with a gentle introduction to a slew of new APIs and function calls that make little sense and it is finally climaxed by a black triangle painted on the screen of the device you are running your program on. In other words you do a whole lot of learning and work to get something really simple to show on the screen.

While the program seems trivial the door that opens as a result is huge. This is why software engineers tend to get excited over things that the average person finds ridiculous. I once tried to show my wife a needle bouncing from left to right on an analog audio app I was playing with to measure sound impulses. I digress.

My black triangle does not look triangular!
My black triangle does not look triangular!

I summoned you here today because I finally tackled an issue that consumed several weeks of my life back in 2013. I had trouble getting the Kinect model 1473 to work on OS X. This is because the OpenNI driver didn’t seem to agree with this slightly newer model of Kinect sensor. If you are playing with the Kinect you may have run across the issue as well. There are several models of Kinect sensors, the original one bundled with the Xbox 360 is the easiest to use. However the model released a few months later as a separately purchasable item (model 1473) changes somethings internally in hardware where the popular OpenNI driver can no longer detect. Then there is the Kinect sensor for the Xbox ONE, which I have yet to see/use.

My black triangle does not actually look triangular, but it’s just as exciting. I was able to get things working in just over an hour. I started by looking over all of the original tools I used in 2013 realizing none of them had changed much or received additional updates over the years. Then I finally took a leap of faith and arrived at the solution.

Getting Kinect model 1473 to work on OS X
The process is remarkably simple considering all the research I did years ago! I installed Homebrew then installed libfreenect. This entire process took about 3-5 minutes and uses only two commands.Installing Homebrew is one curl command, and installing the driver is one Homebrew command. The final step is to install the Shiffman wrapper for Processing. (You also need to install Processing itself if you haven’t done that.) This is as simple as going to “Sketch -> Import Library -> Add Library” from the menu and looking for “Open Kinect for Processing” After that I was ALMOST ready to start writing Kinect code again. There is one major issue, however.

The driver can only access the Kinect when run in a root process. I’ve logged an issue with the Open Kinect Github repo to ask about it, though the issue probably belongs on the site since that’s where the install instructions for OS X are lacking. (They explain how to use the Kinect as a normal user on Linux but not on OS X.) To work around the problem I had to launch Processing as a root user. I type “su” on the command line to switch to the root user account. Using Finder I right-click on show package contents and drill into the “Contents/MacOS” folder. I drag/drop the “Processing” executable from there into my terminal window and press enter in my terminal to run it. (Or you can just type the path in manually, “/Applications/”.) The first time you do this you’ll get a pop error with Processing complaining it can’t find the sketchbook folder. I had to make a “Documents” folder in the root user’s $HOME directory then I added a sym-link there to the “Processing” folder in my $HOME/Documents directory. only after all of that was I able to run Processing as root and get my Hello Kinect app to run. I also had to enable the root account in OS X to make it easy to add the missing sketchbook folder.

Finally, after all of the hassle I have success. In reality it should have been a simple 2 downloads, 2 installs, copy/paste a sketch and go. However things are never as straight-forward as they should be when you live in the world of computers.

Install software to make software that makes software

I’m watching my terminal as Homebrew installs during my latest episode of yak-shaving. I feel a strange urge to explore the Homebrew site, a step that has nothing to do with the reason why I’m here. Hi, I’m Cliff. You’re here as the result of an unfortunate chain of events. You probably started to wash laundry when you realized you were out of detergent. On your way out the door to get detergent you noticed the handle was slightly loose and decided it needed to be tightened. Somewhere between looking for the screwdriver to fix the door something prompted you to check your email, before long you found yourself on Facebook where my post caught your eye. That’s one possible reason why you’re here. I’m here because some four footed hoofed creature with too much hair demanded my attention.

Hairy four legged beast demanding attention
Hairy four legged beast demanding attention

Extreme Yak Shaving
Have you ever found yourself downloading an OpenGL & SDL framework while watching a tutorial when what you really needed to do was install a missing JDBC driver? Today I found myself in a similar situation where I merely wanted to change a dependency in my Android project. That got me thinking about dependency management on iOS, and hey I just learned about this cool project called CocoaPods. To install Cocoa Pods I need Ruby. I can’t install Ruby the old school way, I’m downloading RVM! RVM’s install directions use the gpg command which isn’t available on Mac OS X. I need Mac Ports or Homebrew to install the Linux package. NO!!! I refuse to get side tracked with Homebrew! I’ll skip the gpg step and just use the curl command to direct install without checking security signatures!! The RVM install completes and while I install Ruby I notice the shell is going out to Homebrew land to automate the install. Gosh, I haven’t looked into Homebrew in over a year… I should check out their webpage to see what’s new. It’s always good to get the latest scoop on long living tech like Homebrew. Yak shaving is the work of doing meta work in order to do actual work. Extreme yak shaving is the distraction that results from work of doing the meta work.

I am installing software (Homebrew) to install software (ruby) to install software (Cocoa Pods) which I’ll use to install my iOS software dependencies. I’m not even getting into the learning curve associated with this major distraction. Am I losing it? (Don’t act like it’s just me! Some of you are waiting on a Unity or gaming engine download right now because you ran out of toilet paper!) How do we get some many layers of abstraction between us and the work we actually intend to do? I’m thinking eventually things will swing in the other direction as they always do. Instead of using systems to manage the install of managers that install frameworks we use to build systems (which ultimately manage the install of managers that install…) we will obsess over slim code and vanilla iOS/Java. Languages like Go are already becoming mainstream I’m waiting for the idea to spill into mobile which has currently gone the way of EJB. Until then I’ll keep watching my progress bar fill while the next software installing software installs.