Thursday, November 26, 2015

Thanksgiving Quest - Becoming Otherish - AKA becoming less selfish.

selfish - concerned with one's own profit or pleasure

It is really easy to be selfish, it comes naturally.  To a limited extent, it is a good thing -- it helps us survive.  But, mostly it's a bad thing (I won't attempt to explain why).  Unfortunately our society, (American consumer society) encourages selfish behavior.  The same society does still give lip service to the idea that selfishness is bad, but it really is only lip service.  So if one is not careful one can get really out of balance.  In examining my life, I realized, I was out of balance.  I want to right that balance.

otherish - concerned with other's profit or pleasure

Ok, I made up otherish. A quick look on internet, shows that I'm not the first to invent the word (of course I'm not, there are no new ideas!)  Yes, there is already the word selfless, but the word is flawed because it still has the word "self" in it.

I want to be more otherish.  To do that I've decided to mindfully do at least one thing every day that is   concerned with other's profit or pleasure.  

Day 1: Today I did two things in this category.

1. I picked up some trash outside the grocery store.

2. I bought 20 $5 McDonalds gift cards to give to beggars.  We often have beggars on street corners here in San Jose.  Many say that they don't need the money, or that they spend it on drugs and alcohol, but generally I avoid judging them and just give them a dollar.  After-all all of us would be beggars without a very large portion of chance, fortune or god's blessing (choose one - based on your personal philosophy or religious beliefs).  The McDonalds gift cards lets me give without worrying as much about being part of the problem.

I'll keep a supply of the cards in my car and in my wife's car so that it will be easy to give them out.

Note: I realize McDonalds is not the healthiest meal, but I suspect that it will be appreciated by those who receive it.  We will see.


Sunday, July 05, 2015

Tech Rocket vs. Code Academy vs. Khan Academy vs. Tynker vs. Code Studio

We wanted an online programming course for our 9 year old this summer.  Because we had done the iD Tech summer camp, Tech Rocket seemed like an obvious choice.  The price was reasonable ($29 per month) and it had really a lot of variety including: Unity, Python, C++, Minecraft modding, and even Photoshop tutorials.  It seemed perfect.

My son ran into some trouble on the Python lectures so I helped him.  What I saw in the curriculum was very disappointing.  Some of problems I could overlook, like the use of non-standard English (like saying "aks you a question" instead of "ask you a question") and the non-standard spelling (like spelling "lasers" with a 'z' - "lazers").  One of the bigger problems is that the videos aren't well suited to anyone with a laptop screen - you have to zoom the video to full screen and its still hard to see the text.  Perhaps the biggest flaw are the exercises themselves.  The students are meant to type the commands exactly - including the typos - in the system.  If they don't type it correctly they are shown a cryptic error message.  When they do type it right, they don't even get to run their program, it just moves to the next exercise.  The real fun in programming comes from being able to explore your own solutions, and in seeing how your 'mistakes' can subtly effect the outcome of the program.  Since it never allows you to run the program, you never get any of benefit of this experimental play.  Finally the courses don't let you repeat any exercises.  Once the system evaluates it as correct response it moves on with no way to redo it.  Until they fix these issues I can't recommend iD Tech's "Tech Rocket" program to anyone.  Thankfully there are other choices available.

Since my son had started with Python at Tech Rocket, I looked at other Python offerings.  The first I found was Code Academy.  I didn't do a full evaluation, but from the evaluation I did do, I could already tell it didn't suffer from the worst offense of Tech Rocket.  You can actually run your code (imagine that!).  And if your code doesn't match their expected input exactly, it seems to still work.  Code Academy doesn't have kid friendly themes (not that that is bad), and looks like it might be better suited for high school or higher.  Since I was looking for something for my nine year old son, I kept looking.  If I were trying to learn Python as an adult, I might try Code Academy.  Bonus: It appears to be free.

Having my nine year old learn Python wasn't the goal, the goal was for him to learn programming.  What about Khan Academy (KA)?  I tried it before and was very impressed.  They had a good and fun teaching style mixed with a great interactive environment.  The videos were easy to follow and easy to see, and are given by a well spoken enthusiastic teacher who's examples are silly enough to engross a nine year old.  Whenever you stop the video you can edit the code she has written and explore what effects that has on the program's outcome.  It resets the code if you start the video again reducing the risk of experimentation.  Although KA's curriculum requires typing, there are a number of convenient sliders you can use to change the code without typing.  The language KA uses is Javascript which is great too, since it's currently used all over the web and many jobs require it.  The amazing thing is, KA is committed to always being free.  I originally tried KA in 2012 with all three of my kids.  My only gripe about KA in 2012 was that there wasn't that much programming content.  They've added much more recently so this is no longer a concern for me.  If your kid is comfortable with typing this is a great choice.  If typing is still an issue, you may want to save KA for later. One more thing:  How independent is your child?  I found that KA was not as structured as my then 7 year old needed and he never completed the series, at 9 years old, he won't have a problem.

Tynker was another choice that I looked at.  Tynker costs money, It's actually quite a bit more expensive than Tech Rocket.  Instead of $29 a month it's $50 for each course (it looks like a motivated student could get through a course in as little as 3 days).   I'm more than happy to pay for good things, so this isn't a show-stopper for me, but you should know what you are getting into.  Tynker uses a drag-and-drop programming language that doesn't require any typing (very similar to MIT's Scratch).  Their lessons are geared towards kids (bonus), and allows kids to eventually transition to Javascript (great!).  They can target mobile devices with their code, and even do the lessons on an iPad.  This long list of features almost had me convinced this was the best option, but the execution wasn't as perfect.  It's not a big deal, but the intro "video" is almost completely silent.  Like I said, not a show-stopper (unless your child can't read), but it had less polish than KA and Code Studio (we'll discuss that one below) and both of those options are free.  The first lesson also didn't include enough instruction for many kids to finish it successfully (some options were available that weren't explained).   Tynker did allow kids to see the results of their mistakes (excellent) but sometimes would jump over important points.  In short, the curriculum was far better than Tech Rocket, but could really use more polish.

Finally I'd like to discuss Code Studio.  Their curriculum is excellent and free!  Not only is it geared towards kids, it includes art from big names in the industry like Disney's Frozen, Angry Birds, and Plants vs. Zombies (great for 9 year olds).  It uses a drag-and-drop language like Tynker and has all of it's advantages for students who struggle with typing.  It's also great for beginning programmers who can type, because they don't need to worry about syntax errors and can just focus on the code.  I was very pleased to see their video content is professional quality.  No sound quality issues, no issues whatsoever.  I was even happier to see that like Tynker, the lessons are structured so that there is no fixed way to complete an exercise, any solution that reaches the stated goal is acceptable (fabulous!). In a nutshell, Code Studio really knows how to make a quality well polished product that will appeal to kids.  They also know how to teach programming.

For my money, I would pick either Code Studio and/or Khan Academy (ok, I know, they are actually free - put I'd still pick them if they weren't).   In fact we are going to do both with my nine year old.  Once he finishes Code Studio (which he loves), we'll start back on Khan Academy.


Teaching Your Kid Computer Programming

My wife and I want our kids to learn programming. We think it's a great skill that everyone should have (it's also a great career choice). To that end I've been on the look out for years for the best way to teach this. Since I'm a professional programmer, with a real passion for the subject, I tried first teaching them myself. The challenge here was answering these questions: "What language do I teach them?", "What development environment should I introduce them to?" and "How do I structure the teaching?" (lesson plans, free-form, something in between).

The first two question were so much simpler when I was a kid. The answer was obviously the language called BASIC (Beginner's All-Purpose Symbolic Instruction Code). Every computer used to come with a BASIC interpreter built-in (and little else). My brother and I used to go to the computer department at our local K-mart and write a simple basic program on their Commodore-64's and Vic-20's that would cover the display with "Don't Buy K-mart Junk!" (When K-mart filed for bankruptcy in 2002 I felt a huge pang of regret). We would get computer magazines monthly with pages and pages of computer programs ready for you type in.

It wasn't so simple anymore. Computer's don't automatically start-up to a command prompt ready for you to enter your programs. There are now so many to choose from, but they all so much more complicated for the beginner. Because of my own experience with BASIC I thought it might be nice to start with a command line language. I thought "maybe I should teach them Perl on the unix command line?" If you try this you may run into some of the same challenges I did. I wanted something where they could use a modern text editor to edit the code, but then you need to make the file executable for them, and you need to add the ever cryptic #!/usr/bin/perl to the first line, not the simplicity I was looking for and that isn't even touching the language. Another thought was to teach them a language that they could create something that resembled a game. Since I'm an Apple fan Objective-C and Swift came to mind.

I ended up trying to teach Perl along with Python, Javascript, Swift, Objective-C, and Logo over the course of about 9 years. Some of these worked better than others, but mostly they failed. This was for a number of reasons: in some cases I started too early (before they could read well), they typed too slow (it was painful for both of us), they struggled with the environment (there are a lot of assumptions in the modern IDE), and the languages had a lot of terms that needed explaining (like why do I write int and float for numbers). Honestly though, the biggest problem was that I didn't have enough consistent time to spend with them on it. As much as it pained me to admit, they needed something they could do mostly on their own (or for someone else to be their teacher). I could definitely supplement their learning, or help them get unstuck, but I wasn't going to be able to teach them everything.

Programming summer camps are a great for this. In the San Francisco bay area where we live, we have several different organizations that offer these. One of the biggest is iD Tech. We've had mixed success with them. Our daughter got really a lot out of their Alexa Café. The camp was well organized and lots of fun. Most importantly she came home truly energized about programming! Before the camp she had declared that she didn't have an interest in the subject and didn't think she could learn it (so much for all of my education attempts). Afterwards she was spending lots of her free time writing code including using it to complete creative assignments at school. Here's a really cool thing she made for her English class in 8th grade. This summer we sent her to another iD Tech camp (Game programming in Unity). This camp had a lot more problems. The online curriculum they had developed in-house was so buggy that they had to scrap it and go to a fall-back plan. It's nice that they had a fallback, not great that they had to use it. The instructors although very nice and friendly couldn't help my daughter get unstuck on her projects. I spent my nights that week helping her get unstuck. Don't get me wrong, this was great bonding time with my daughter that I wouldn't trade, I just think that since we paid them more than $1000 for the week, they should be able to help an absolute beginner get unstuck. Later this summer our oldest son is going to a camp to learn Arduino, I'm hoping they do a better job at his camp.

What about online resources to help learn programming? Well, it turns out there are a bunch of options here. Many more than were available in 2006 when I first started this with my kids. My next blog post will compare some of the ones we looked at for our 9 year old son. I hope it helps you.

Programming - A Great Career Choice

My favorite hobby is programming computers - because it's really fun! I have been very fortunate to get paid to do my hobby for the past 20 years. During that time I've worked for about a dozen different companies, sometimes as a contractor, sometimes as a full time employee, and for about 7 years I ran my own company. Each change was by my choice, and on my terms. Although I'd like to think of my skills as amazing, the truth is you don't have to be amazing to get work in this field. The world, as a whole, needs more programmers, many more programmers! You may be worried about the coming robocalypse and what that will do to your job prospects (as you should), but this is one of the few jobs that should fair reasonably well. Jobs in this field are extremely flexible about where you live, and what hours you keep. And it's really easy to get started - all you need is access to a computer and the internet (or a good book). To sum up, programming is fun, and you can make a good living from it. If you aren't sure what you want to be when you grow up (or are interested in changing that choice), I'd give computer programming a serious look.

BTW: You'll often hear a lot of different names for computer programmer, here's a short list: Computer Programmer, Coder, Hacker, Software Engineer, Computer Scientist

Wednesday, July 06, 2011

Crossword Forge QuickLook Plugin

While at WWDC there was a lab helping people develop QuickLook plugins. I had often felt that Crossword Forge would really benefit from this plugin. Users would be able to simply press the spacebar and get a look at their puzzle. I attended the lab and got started on my plugin. A relatively short time later I had a plugin that would display the title and puzzle grid. It took into account styling of the title, backdrop pictures, right to left languages, puzzle masks and a lot of other small but important details of the file format. It wasn't 100% complete but it was complete enough to work on the next step. I needed to make sure it worked in the real world. Up to now I had been running the plugin directly in Xcode using the command line tool "qlmanage". I needed it to run, just like a user expects, when I pressed the space bar in the finder on any .cwz document.
It turns out there are 3 ways (at least) to install a QuickLook plugin. I could install it in /System/Library/QuickLook/, ~/Library/QuickLook/, or I could install it directly in my app itself in the subdirectory /Contents/Library/QuickLook/. For me the last option was the best since Crossword Forge did not have a separate installer, I didn't need to worry about adding the plugin to the above mentioned directories. I didn't have to worry about authentication, and it also meant that the end user wouldn't be asked to install it (another option but a tech support nightmare).
With the plugin installed, in my app, I figured it would just work, unfortunately it did not. It turns out I was missing 2 very important steps. First I had to update my info.plist file in 2 places. I had to add a LSItemContentTypes item to my CFBundleDocumentTypes. This has to match the plugins value for this. In my case it equals com.solrobots.crosswordforge.cwz. I also had to add a separate entry for UTExportedTypeDeclarations in my info.plist. (One gotcha here is in relation to the UTTypeTagSpecification, Apple's docs say to use the com.apple.ostype tag but Apple's own Garage Band has a hyphen in that same key. Its written as com.apple.os-type . I'm not certain which is correct, but I'm going with the hyphen version for now, which seems to work).
After all of this, it still wasn't working. I had all the pieces in place, I just had to debug it.
My first check was to make sure that QuickLook manager knew about my plugin. I called "qlmanage -m plugins" and sure enough my new plugin was loaded into the system. Next I tried to find out what the system thought was the file type. I used the tool "mdls" for this. Unfortunately it was not assigning the right UTI to my file. I checked and re-checked my info.plist, restarted the finder, restarted the system, nothing seemed to work. Finally I found "lsregister -dump" (you'll have to specify the full path to this tool), which gave me a few clues. Launch Services was getting the UTI but it was a duplicate entry and it wasn't trusted. I needed a way to update the Launch Services database. The easiest way to do this is to change the applications mod date "touch appName.app", and then duplicate one of my .cwz files in the Finder. One more thing: before you change the mod date of your app, don't forget to put it in your Applications Folder. It won't update properly unless it's there.

Wednesday, June 08, 2011

Apple's New Campus - Coming 2015


When I saw the news about Apple's new campus, I thought wow! That looks awesome. The folks that get to work there are going to have the best office space in the world. I also thought that it looked a lot like a giant iPod click wheel. So I couldn't help myself - I had to mock it up in Photoshop. I call it iPod Jumbo. What do you think?

Friday, October 15, 2010

Boost C++ Threads - MinGW & Mac OS X Universal Binaries

I ran across a cool set of C++ frameworks called Boost. They provide loads of stuff that you just take for granted in other languages like RegEx and thread support, but is not part of the C++ standard (at least not yet - apparently large parts of the Boost libraries are on track for adding to the official standard). My current interest in Boost is for its more advanced threading (I had a working implementation using pthreads but those have an inelegant interface which makes the code harder to maintain). Although much of Boost doesn't need to be compiled into a separate libraries (their magic uses C++ templates that are defined in header files), the threads implementation does need to be compiled to a binary. This is where I ran into some trouble (and some hair pulling).
Turns out there are unique problems with the Mac and Windows build, so I will detail them separately. I hope that some of this will help someone else (or help me in the future, if I forget :)
Mac Challenges:
To get Boost there are two main options. Download pre-compiled binaries or compile them yourself. The pre-compiled route is really only available for Windows, so for the Mac I had to compile it myself. This wasn't too hard. The documentation has nice step by step directions that will, if followed correctly, produce library files (two for each library - one ending in .a and one ending in .dylib -.a is a static library that will compile into your code, where-as the dylib is meant to a stand-alone file that is linked at runtime (although this can be hidden by including it in the final app package). I needed the static variant for my project). The directions tell you to change your search paths and libraries paths to include the headers for boost and the new libraries that you just created. From there it should just work. But it didn't for me. Instead I got cryptic linker errors (linker errors are always cryptic) that I eventually figured out meant that the libraries I built didn't include a PowerPC variant. Since this particular project was setup to run on PowerPC and Intel macs, it won't compile. Now Boost will compile for PowerPC the problem is that the compile scripts are automatically only configured for the system that you are currently running. So I suppose I could have dug up an old Mac (PowerPC), installed the developer tools on it, re-installed boost which would have produced the PowerPC binary I was looking for, that didn't occur to me (even it did I would have avoided it at all costs - what a mess). I knew that my machine could compile to both architectures, in fact it does it all the time. So it was just a matter of setting the scripts up correctly. Unfortunately, there were no easy to use instructions for this. Instead I was left trying to piece together different blog posts that were tangentially related. One I came across mentioned using MacPorts to get the Boost libraries. I was heartened to see that MacPorts had a "Universal" variant (Universal is the term used by Apple to indicate multiple architectures in one library.) It usually means PowerPC and Intel, exactly what I needed. MacPorts unfortunately had its own learning curve, it took hours too build Boost (mostly because I couldn't specify that I just needed threads), and turned out their "Universal" option meant includes 32bit and 64bit Intel. Although technically correct use of the term "Universal" in Apple parlance, it isn't what I needed. Further including the MacPort binaries caused conflicts with other libraries that are provided by the OS and were building just fine. In the end I had to purge my project of all external references to the MacPorts build (probably going to do an uninstall of MacPorts later). Back to the drawing board. I finally ran across an excellent script online that was doing mostly the same thing that I wanted. It was designed to build 4 binary variants of Boost (32 & 64 bit variants of the Intel and PowerPC libraries) and then stitch them together using "lipo" (an Apple developed command line tool designed for creating "universal" aka "fat" binaries - hence the name lipo). The script did the first part beautifully but didn't quite work for the second part (the file names had changed slightly from boost version 1.4 and 1.44 and it caused it to choke). No matter "lipo" is pretty easy to use manually (and in my case preferrable, because I didn't want all four parts). The command I used was.
lipo -create build/libPPC32/libboost_thread-xgcc40-mt.a build/libIntel32/libboost_thread-xgcc40-mt.a -output build/lib/libboost_thread.a
. You can use man lipo to get an idea of how to use it. After you are done you can use lipo -info to find out if it got all the right architectures (this is how I know why the MacPorts universal wasn't working). I then just dragged the newly created "Universal" library into Xcode and it worked!!! Now I only had to get the windows version working.

Windows:
My windows compiler is MinGW. I use it because it gets the job done and its free. Its a nice little compiler but not terribly easy to use (I guess I can't complain, it's free after-all). The cool thing about MinGW is that Boost comes included. No compilation necessary. Unfortunately every time I tried to use Boost I would get very cryptic linker errors (those linker errors again :) like the following:
undefined reference to '_imp___ZN5boost6thread20hardware_concurrencyEv'

Everything I tried to fix this failed (and I tried a lot of stuff, and was at it for hours). Finally I had to ask someone for help (I don't like asking for help until I've exhausted my resources - I guess I don't want to waste other people's time, and I don't want to look stupid - ah Vanity). Truth is, there are very few people I can ask for stuff like this, and expect to get an answer. I found a great website of a "Stephan T. Lavavej' who looked like he just might be able to help. He had built his own distribution of MinGW which included the latest version of Boost (just the sort of guy that would at least know what I was talking about). Indeed! He was most helpful. He sent me the following:
Due to changes in Boost 1.44.0 and mingw-runtime 3.18, you'll need to pass
-DBOOST_THREAD_USE_LIB to g++ and define

namespace boost {
void tss_cleanup_implemented() { }
}

in one of your source files.

Do I really understand it? Heck No! But adding both of these unmangled the namespace. Now I was getting much more manageable linker errors like this:
undefined reference to 'boost::thread::hardware_concurrency()'

It was now just a simple matter of adding the right library to my make file to resolve these (I had done this earlier as well but it had no effect until the name mangling was resolved). I added:
-lboost_thread

the library itself is called libboost_thread.a but you drop the "lib" and the ".a" . The -l is a flag to the compiler to link against that library.
Thanks again to Stephen Lavavej of nuwen.net for his insightful email and helpful website and to Manfred Schwind of mani.de for his excellent script for building PPC versions of Boost. I would also like to thank anyone that has ever asked a question about Boost or responded to one, It feels like I read just about every one ;) and they all helped to improve my understanding and push me a little further along.
Now that I've got it compiling I just need to build something useful with it. I guess that is what next week is for :).

Saturday, March 07, 2009

Bad design for Apple Online Store

I apologize in advance for ranting, but maybe, just maybe it can help in some small way. Yesterday I tried to buy a Developer membership at Apple.com. I have an account at the Apple Online store, it is the same account I use for iTunes, iChat etc. Apple calls this login an AppleID, and in theory it's a great idea. It means that I don't have to remember a different name and password for each Apple related account, they are all tied together. Parts of the system are even designed intelligently so that your email address doesn't have to be the same as your login id. This is actually essential since your AppleID may have been set up with an email address that you no longer have. Unfortunately all of Apple's systems aren't designed this intelligently. The Apple online store requires that your AppleID and your email address be the exact same thing. This means that either you need to create a new AppleID just for use with the Apple Store or you need to forgo getting email confirmations for purchases at the store. You may be able to live without email confirmations, but the real trouble comes when the product itself is shipped by email, as is the case for developer memberships. My developer program activation code was sent to an email address that doesn't exist.

Have I lost my $540? I hope not. I called Apple about the problem and although they weren't able to help me, they assured me that I would get the email within 24 hours. They didn't know what they were talking about since I still have not received the email. Unfortunately it's the weekend so all of the developer support people are at home, and everyone else is apparently not qualified to help.

Hopefully they will sort it out on Monday. Until then, I'm fit to be tied.

Saturday, November 15, 2008

Adam's Game

I recently tried my hand at building a game for my two and a half year old son. The idea came to me when at the hospital, and it looked like he might have pneumonia yet again (he's had it several times this year). While sitting with him on the hospital bed, I wanted to keep his mind off all the poking doctors (and to keep him busy), and so downloaded Preschool Adventure for 99ç to my iPhone. It's a great game for his age group. I was impressed by how easy it was for my 2 and a half year old to play. Because it just involved pointing (no mouse involved on the iPhone). 
Before trying it, I honestly didn't think that I would ever feel comfortable letting him play with my phone. Afterwards I couldn't help but think about games I could make for his age group. Although designed for grown-ups, Apple has managed to build an almost perfect toy for two year olds (Perhaps they can make the next version with drool guards :) ). My first venture into this arena is Adam's Game. The game simply presents three panels and vocally asks the child to touch one of them e.g. "touch the hat". The game rewards you if you get it right by cheering, and getting several right in a row, gives an even better reward. The game lets you customize with your own pictures and sounds as well. Adam likes the game, and frequently asks to play it when I'm doing testing (He hears me playing it). Several other parents have written good reviews for it on iTunes, so it appears to have broad appeal. If you want to try it, and you have an iPhone, or an iPod Touch, here's a link to Adam's Game on the iTunes store.