Monday, June 30, 2014

Swift First Impressions

Hiking the Pacific.
Earlier this month, Apple announced a new programming language, called Swift. It's designed to be fast, safe, modern, and interactive.

Swift is big news since it was unexpected. I haven't been this excited to learn a new programming language since Sun released Java in the mid-1990s.

Java and Swift both took about four years to develop. But, Swift is already more mature than Java 1.2 was two years after its initial release. Sun used to have an office down the block from the Apple Campus at Mariani One. When I started working at Apple, in 1998, we joked that we could hear the Java API's deprecating across the street in the Sun building. I do not imagine many Swift APIs deprecating anytime soon since they're based on, and bridged to, Cocoa's Objective-C APIs. (Coincidently, Java 1.2's codename was Playground which is the same name of Swift's interactive coding environment.)

Getting My Feet Wet

Last week I created a couple simple Cocoa Swift apps for both OS X and iPhone. It was a piece of cake. To this day, I still love that I can drag between my code and my UI in Interface Builder to link up ivars (outlets) and functions (actions).

I spent most of this past Saturday getting up to speed on Swift. I read the docs and watched a few tutorials including the Introduction to Swift, Intermediate Swift, and Swift Playgrounds videos from WWDC 2014. So, after hiking half a dozen miles along the Pacific, yesterday morning, I decided it was time to dig deep into Swift.

What to Code?

I wanted to write an algorithm requiring a fair amount of trial and error without much mental heavy lifting. For me, the answer was string parsing. I once spent a long time coding, testing, and debugging Java (Eclipse with the WOLips plugin for WebObjects) to parse SMS text messages for newspaper classified ads:
My Tweet Storm Swift Playground
Sell  (Item name)  ($Price)  (ZIP code)  (Item details)

For my first real Swift task I reverse engineered Dave Winer's Little Pork Chop algorithm which lets you send out a tweet storm. Basically, Little Pork Chop breaks up blocks of text longer than 140 characters into tweet size chunks.

Swift and Powerful

In a nutshell, Swift's Playground is worth its weight in gold. The Playground's interactivity is powerful. Typically, I write a few lines of code, compile it, and then run it. I would never recompile an app after writing every single new line of code. But that, effectively, is what Playground does for me. It kept me focused and my code clean. I caught my syntax and logic bugs in real time as it displayed my variables and loop counts. Even better was that my infinite loops were immediately visible in the sidebar. I can see myself writing all my algorithms in Swift's Playground before copying them to my projects.

Swift Playground Gotchas

On the flip side, it doesn't seem possible to step through code, so loops execute until they terminate. Once a loop completed I could see what happened by examining the value history or using Quick Look.
Quick Look into an array and then into each element.

Another wrinkle I encountered was trying to get the character at a string index. The best solution I came up with was fairly ugly:
var currentChar = String(Array(subTweet)[indexOfCurrentChar])
This might be due to the fact that an index into a string array element, which is usually equal to the number of bytes, doesn't hold true if you're using UTF encoding where each character may require multiple bytes. If that's the case, then I need to write my own String indexer. Please let me know if I'm off base.

Free Code

It took me about two and a half hours to code and debug my tweetstorm algorithm in the Swift Playground. Am I getting Swift? Yes, I most definitely am, but I'm probably still using old coding patterns while I learn the slick new modern Swift syntax.

One final piece of Swift beauty is that you can download my Tweetstorm Swift Playground and run it for yourself in Xcode6-Beta.

Thursday, June 26, 2014

'What’s the Big Deal About Outliners?'

Balboa Park, 7 AM: The perfect place to think about outliners and this blog post.

Two years ago, while having lunch with Dave Winer at Carnegie Deli, I embarrassingly confessed to him that I didn't fully understand outliners. He told me, "That's OK, you will."


While I'm a big fan of writing down tasks in flat to do lists, I never took the time to structure my to do lists into an outline. Since the beginning of last year, Dave has been working on a very interesting web based outliner that runs and stores your outline inside your web browser with the ability to also save it to your Dropbox. While saving data to Dropbox isn't a big deal, the ability to save data using a web browser's local storage feature seems underutilized by developers. The overlooked beauty of Fargo is that Dave's web based app can scale, big time. The Fargo web app is served up as a static HTML web page with dynamic Javascript (Node.js) so all the heavy "thinking" and storage is done in the client's browser. Since the outline is saved either locally or to Dropbox that means Dave doesn't have to worry about customer storage requirements if he gets a billion users, overnight.

Little Porkchop and Happy Friends

Alcazar Garden and the California Tower
Two weeks ago, Dave launched Little Porkchop which lets Twitter users send out a tweetstorm. As I played with it, Dave hinted that he had something bigger on the horizon. That "something bigger" came a couple days ago when he released Happy Friends.

Happy Friends is an outliner that let's you embed a Twitter user's feeds into an outline. And, since it's an outline, you can indent, outdent, and rearrange Twitter users while archiving individual tweets. Twitter and Facebook are very flat formats consisting of a post with comments threaded to it. Happy Friends, on the other hand, turns a flat Twitter feed into a mailbox style reader. Once again, the beauty of Happy Friends is it can scale to the moon and back without any load on Dave's servers.

So, after all of Dave's arm waving, I'm starting to get it. Slow and steady wins the race.

Thursday, June 19, 2014

Aero Glass Augmenting the Cockpit with Google Glass

From time to time we see true technological innovation. As I've said before, innovation is anything that can reduce the cost of a transaction, either in terms of time or money. Revolutionary technology doesn't necessarily need to be disruptive, but, ideally, if a new technology (i.e. iPhone) can replace multiple, older, technologies, (camera, iPod, phone, maps, etc), then it's a game changer.

At last night's San Diego Startup Week VC after-party, I had a long talk with the VP of business development at Aero Glass ( I had a clear idea of the augmented reality benefits of using Google Glass as a HUD in the cockpit. But, I didn't fully grasp the checklist benefits until I watched their demo video. Pilots, quite literally, live and die by their checklists. If I forget to turn on my carb heat when landing on a cold humid day I could get ice built up in the engine. Also, a surprisingly common mistake made by private pilots is that they forget to put down their landing gear, even with an audio alarm beeping in their ear. Most importantly, during an emergency, a checklist displayed on a personal HUD will keep the pilot focused.

The Aero Glass features in this video, below, will become very common place in the cockpit. It's just a matter of when; and, from the looks of it, it'll be very soon since Aero Glass will be attending "Oshkosh" in six weeks. Their business will definitely get some attention there.

Tuesday, June 10, 2014

Facebook Tracking and Privacy Concerns

Facebook is tracking me and I didn't realize it.

My drive to and from the Grand Del Mar.
I was looking at my Facebook activity log and I clicked on "Include Only Me activity." That displayed my Facebook activity, which only I could see, including places I had been and how long I'd been there each day. The level of detail is surprising. Yesterday, Facebook showed my journey from home to Tech Coffee and then my drive and three hour stay at the Grand Del Mar's Club M.

Stop Following Me

Facebook provides instructions for turning it off, but, you'd need to realize it's turned on in the first place. It seems this tracking feature is turned on and off via the mobile app, but the Location History map is displayed on the website.

Forewarned is forearmed.

Author: Joe Moreno

Live Indians, Dead Puppies, and
Fake Sea-Monkeys

When I was a kid I bought a Native American stone arrowhead at a Boy Scout event.

One Saturday afternoon I was sitting next to the shed in my backyard where we kept our trashcans when I found the arrowhead in the dirt. I thought my mother dropped it on the way to the trash thinking it was just a rock in my bedroom. I picked up the arrowhead and went to put it where it belonged when I discovered that the original arrowhead I'd purchased was right where it belonged in my room.

The arrowhead I found in my backyard was a real life archeological discovery from hundreds of years ago.

While my arrowheads are long gone this brought back a memory of when my namesake cousin found a dead puppy in Brooklyn when he was a kid and created his own archeological piece of history. He and his friends took the dead dog down an alley to a construction site and gave the pup a proper burial.

It turns out that the building being built was a public library and the construction workers later uncovered the bones of the dead dog. When the library opened, they had a contest for kids to write about what they thought the bones were. My cousin, Joe, was a sharp kid. He wrote about what had happened. He figured he was a shoo–in with his unfair advantage.

Did my cousin win? Nope, he wasn't even close. The kid who won wrote about how the dinosaurs roamed the earth hundreds of millions of years ago while wearing eyeglasses and taking vitamins.

As a kid, we learn, quickly, about truth in advertising and to never let the facts get in the way of telling a good story. Whether it's the pair of x-ray glasses we bought which really don't see through things or the sea-monkeys which don't look anything like the comic book ad. Everyone loves a good story.