Author Archives: Lou Franco

Learning 80’s style programming today

There is an ongoing lament among programmers of a certain age that there are no entry-level programming environments for young kids and teenagers to learn on. Since I am of that age, I understand exactly what they mean, but I don’t agree that there are no choices.

Today, on Hacker News, this four-year old article by David Brin in Salon (Why Johnny Cant Code) made the first page. It’s a good read and an accurate overview of the debate— namely, computers from the 80’s came with BASIC, which was simple enough for anyone to pick up and learn how to program, and now, we don’t have an equivalent. Here’s a passage about the difference:

The “scripting” languages that serve as entry-level tools for today’s aspiring programmers — like Perl and Python — don’t make this experience accessible to students in the same way. BASIC was close enough to the algorithm that you could actually follow the reasoning of the machine as it made choices and followed logical pathways.

Luckily, I keep a Commodore 64 Programmer’s Reference Guide on my work bookshelf for nostalgic reasons. Here’s one of the first BASIC programs they list:

10 PRINT "YOUR NAME":INPUT N$
20 PRINT "HELLO," N$

Here it is in Python:

n = raw_input("YOUR NAME ")
print "HELLO, " + n

The Python version doesn’t have line numbers and doesn’t need you to use dollar signs to designate string values. I can’t imagine that anyone who could learn the first one would have any real problem with the second.

But the author is concerned with coding math problems like statistics.  Something where you can follow the logic. Here’s a BASIC program on page 20:

5 PRINT ""
10 PRINT "MONTHLY INCOME" : INPUT IN
20 PRINT
30 PRINT "EXPENSE CATEGORY 1" : INPUT E1$
40 PRINT "EXPENSE AMOUNT" : INPUT E1
50 PRINT
60 PRINT "EXPENSE CATEGORY 2" : INPUT E2$
70 PRINT "EXPENSE AMOUNT" : INPUT E2
80 PRINT
90 PRINT "EXPENSE CATEGORY 3" : INPUT E3$
100 PRINT "EXPENSE AMOUNT" : INPUT E3
110 PRINT "-----"
120 E=E1+E2+E3
130 EP=E/IN
140 PRINT "MONTHLY INCOME: $"IN
150 PRINT "TOTAL EXPENSES: $"E
160 PRINT "BALANCE EQUALS: $"IN-E
170 PRINT
180 PRINT E1$"="(E1/E)*100"% OF TOTAL EXPENSES" 
190 PRINT E2$"="(E2/E)*100"% OF TOTAL EXPENSES"
200 PRINT E3$"="(E3/E)*100"% OF TOTAL EXPENSES" 
210 PRINT 
220 PRINT "YOUR EXPENSES="EP*100"% OF TOTAL INCOME"
230 FOR X=1 TO 5000:NEXT:PRINT
240 PRINT "REPEAT? (Y/N)":INPUT Y$:IF Y$="Y" THEN 5
250 PRINT "-----":END

This example has looping, conditionals, and math. The reverse heart clears the screen (platform specific), line 230 is a delay, and line 240 uses a conditional goto for a loop.

Here it is in python (I tried to keep it as close as possible, also using a platform specific clear screen which will work on the Mac and Linux):

import os
import time

while True:
    os.system("clear")
    IN=float(raw_input("MONTHLY INCOME"))
    print ""
    E1CAT=raw_input("EXPENSE CATEGORY 1")
    E1=float(raw_input("EXPENSE AMOUNT"))
    print ""
    E2CAT=raw_input("EXPENSE CATEGORY 2")
    E2=float(raw_input("EXPENSE AMOUNT"))
    print ""
    E3CAT=raw_input("EXPENSE CATEGORY 3")
    E3=float(raw_input("EXPENSE AMOUNT"))
    os.system("clear")
    E=E1+E2+E3
    EP=E/IN
    print "MONTHLY INCOME: $",IN
    print "TOTAL EXPENSES: $",E
    print "BALANCE EQUALS: $",IN-E
    print ""
    print E1CAT,"=",(E1/E)*100,"% OF TOTAL EXPENSES"     
    print E2CAT,"=",(E2/E)*100,"% OF TOTAL EXPENSES"
    print E3CAT,"=",(E3/E)*100,"% OF TOTAL EXPENSES"     
    print ""     
    print "YOUR EXPENSES=",EP*100,"% OF YOUR INCOME"
    time.sleep(5)
    print ""
    Y=raw_input("REPEAT? (Y OR N)")
    if Y=="N": break
os.system("clear")

So, we have to introduce the concept of import and string to float conversion needs to be explicit, but is this much more difficult? I can tell you that flipping through the C64 programmer’s reference, it doesn’t try to coddle you (it wasn’t written for kids).

The first real program is:

10 OPEN 2,8,6,"0:STOCK FOLIO,S,W"
20 OPEN 1,1,2,"CHECKBOOK"
30 OPEN 3,4

This is under a heading, EXAMPLE OF ACTUAL STATEMENTS in the introduction, which is on the third page of text after the table of contents. To be fair, the syntax of OPEN is briefly discussed, but is this really the best first program?

The one real difference is that a C64 boots into BASIC and you can start typing a program as soon as it’s up. On a Mac, you have to understand how to make text files, open a Terminal, and run python.  After that hurdle, it’s very similar. On Windows, you need to install python.

I think a lot of the nostalgia of what it was like to program these old machines just doesn’t match what it was really like.  The included documentation wasn’t necessarily kid friendly, but there were other sources of information (I had a ton of Compute! magazines and other books).

If you are a beginner, please check out Learn Python the Hard Way. It doesn’t assume that you know anything—it covers getting python installed (not necessary on a Mac) and how to use a text editor. I think it closely matches the kind of experience I and other older programmers remember having in BASIC.

Trainers for Programmers

Anyone who is interested in teaching programming to novices or non-programmers should check out what Zed Shaw is doing:

I’ve had an idea for an introductory book on programming that follows the model of “trainer” books for learning a musical instrument. Most of these books are organized like this:

  1. There’s a bunch of exercises.
  2. Each exercise is 1 or 2 pages.
  3. There’s only a little bit of prose.
  4. You do each exercise exactly, then move on.

The results are at Learn Python the Hard Way.

Favorite iPad apps

Here are some of my favorite iPad apps so far:

WordPress: If you have a WordPress site, this is pretty essential. The iPhone version is pretty good too, but obviously the iPad is perfect for this. I’ve found the WordPress admin to be wonky on Mobile Safari, so this is the best way to edit a WordPress site on iPhone OS.

MaxJournal: This app is a great example of an iPad app — it does one thing and it does it well. It looks great, has elegant date navigation, and strips a journal down to the bare bones. It needs a password feature, but apparently, the feature is done and waiting for approval. The developer is very responsive to feedback, which is a good sign.

Kindle: Kind of obvious. The advantage over iBooks is that the books you buy are available on the iPhone or your Mac or PC (some books have a limit, I hit that with one of my books)

Tweetdeck: Free and supports lists and other custom filters, which are essential for reading Twitter.

NewsRack: RSS reader that syncs with Google Reader. Well done, stable, with some nice touches.

And the disappointments:

CraigPhone: This is an iPad version of Craigslist. Tons of bugs. The app has an apology right on it (they put it in the AppStore without testing it on a real device). It’s free, so I guess that’s ok. Something about the interface just feels wrong though — I suspect that they are using HTML views with some JavaScript drawing parts of the UI.

Tweetdeck: It’s the only usable twitter client for me, but it is crashtastic. Tweet-boom, tweet-boom — move a column, buh-bye. Anyway, it’s free and I assume that they are working on it — they need to check out my post about debugging memory crashes on the iPhone and it probably wouldn’t hurt to run a Build and Analyze once and a while.

NYT Editor’s Choice: First, you can’t find this app by searching the store for “NYTimes” or “NY Times” because they named it with NYT. And, you don’t get the whole paper? But, I do if I go to the website? I don’t get that — just charge me.

No Google apps or Facebook: Pretty surprised that these big players with great apps are absent from the AppStore on day one. Google made GMail work great on an iPad, though — if they had done the same with Reader, I might not have bought an app.

Amazon KDK Beta Program is Open for Applications

Amazon has opened their KDK Beta program. Amazon also published a KDK FAQ. As suspected, it’s Java ME based with a custom API for the Kindle:

[It will] provide UI components, JSON and XML parsers, HTTP and HTTPS networking, secure storage, and other features. Other APIs like audio and dictionary access will be available in a future release of the KDK.

Development will be possible in an Java environment, but it appears that Eclipse will be supported more directly.

What the iPad needs to be your only computer

There’s been a lot of talk about how the iPad will be used by people that aren’t experts in computers. This article makes a good case that Grandmas and Technophobes will love the iPad:

The darndest thing happened in the last five days and I was fortunate to be privy to it. Apple has gotten people excited about computing. But this time, it’s not nerds or geeks and certainly not IT industry analysts. It’s everyone else. I had a curious set of three conversations this week. One with a grandma, one with a technophobe and the third with a self-proclaimed luddite.

And this article explains the difference in computing habits between the Gen Xers that came of age during the PC revolution and the generation before and after us.

The reason I’m starting to think the Old World is ultimately doomed is because we are bracketed on both sides by the New World, and those people being born today, post-iPhone and post-iPad, will never know (and probably not care) about how things used to work. Just as nobody today cares about floppies, and nobody has to care about manual transmissions if they don’t want to.

Both of these articles make a great case, and although, I need a regular computer to do development, I would like everything else to migrate to an iPad.

I started to use Macs again after ten years when I got a digital camera. I read the instructions for the Windows software it came with and then just plugged it into a Mac I inherited — it just worked. Since then, I’ve used a Mac for everything except my job (.NET SDK development).

Which brings me to my first problem with the iPad — how do I connect my digital camera? Steve Jobs talked about how great the iPad would be for photos, but how do they get on the iPad to begin with? Undoubtedly, this will be solved, but it’s a problem that will make the iPad useless for a lot of people if this is their only computer.

Secondly, I don’t take a lot of pictures and almost no video and I have about 10-15 GB of photos (and 20-25 GB of music). 64 GB is just completely inadequate if this is going to be the only place to store them. For the iPhone, synching gives me downsampled photos and music if I want to save space, but I can’t do that to my primary copy. I’m sure iPads will get to bigger sizes, but I’m also sure that we’ll need more too.

Even if the iPad had a terabyte, I really need some off device storage — iPads can be lost, which would be bad, but not as bad as losing all of my data. It’s unclear how the iPad can be backed up if it’s your only computer.

I know that these problems will be solved eventually, but right now — it’s not really possible for the iPad to work without a host computer — if it’s like the iPhone, it depends on synching too much.

I’m not sure what the solution will be, but I have a Time Capsule — if the iPad had Time Machine, and if the Time Capsule could suck the images off my digital camera (perhaps using the iPad as the UI), then I’d be most of the way there.

How the iPad will affect the Kindle

Amazon has no hope of competing with Apple to be the best general computing tablet platform, so trying to match the iPad feature for feature will drive up their cost and still leave them with an inferior product. The two other stable competitive positions are either to go cheap or to go niche.

In his 1980 classic Competitive Strategy: Techniques for Analysing Industries and Competitors, Porter simplifies the scheme by reducing it down to the three best strategies. They are cost leadership, differentiation, and market segmentation (or focus). Market segmentation is narrow in scope while both cost leadership and differentiation are relatively broad in market scope.

This will be hard for Amazon because, before the iPad, they were clearly the differentiated premium market-leader, but now that market has been subsumed. The only hope for Kindle is to become the cost-leader and to let third-party developers turn the Kindle into cheap niche devices.

Once the KDK is available, we’ll see the top end come down to about $400. Amazon can do this because they’re set to make money from their free 3G, in the form of subscription applications. I’m sure a significant component of the $489 price is to offset the expected 3G use that isn’t offset by book sales.

This strategy is more in line with Amazon’s online retail strategy. They currently compete on price and let third-party stores focus on niche markets. Even though Porter cautions against trying to have two strategies, it can be overcome if different business units focus on each strategy independently — what could be more independent than a third-party.

Hoping the Amazon KDK is Java based

The speculation on the KDK is that it’s going to be Java based, and I hope that’s right. We know for sure that it runs Linux, and that there’s a JVM and obfuscated jars on the device. According to what I’ve read, there’s no perl or python or anything like that on it, so the only options will be C/C++ or Java. For the sake of the ecosystem, Amazon will need to pick Java and probably will run third-party code in a some kind of sandboxed environment.

To me the best thing about it being Java based is that I will finally have a JVM that I care about targeting. One of my big problems with Java is that there’s no place the JVM runs where something else doesn’t run better or that I just like more. For web apps, I prefer python based frameworks, and for Windows apps, you have to use .NET or Win32 with C/C++. On a Mac, Objective C is the obvious choice. Java is a good choice on a lot of mobile devices, but I haven’t cared about them, until now.

And the main reason I want a JVM to target is because it gives me a practical reason to use clojure. I know it might not work out, and of course, I’ll be writing Java at first to learn the API, but I’m hoping I can transition to clojure eventually, or at least use a hybrid.

In 2008, Rich Hickey came to speak in Northampton, and I prepared by learning and blogging about clojure for the 20 days preceding it. Since then, I’ve been on a lookout for a JVM that I wanted to target. The closest I’ve come is the Google AppEngine, but I still liked python and Django style better. It may turn out that the KDK just works better with Java, but clojure has shown that it’s pretty good at driving OO frameworks like Swing, so I think it will work just fine.

Why I think Amazon app store will be a be a better deal for developers

Amazon, clearly feeling the heat from the Apple device coming out in two days, is making some moves with Kindle. In the space of a few weeks, they have altered the publisher/Amazon splitannounced an SDK, and are offering a money-back guarantee for frequent book buyers [links via daringfireball.net].

Amazon has a real chance to win the hearts of developers because of few key differences between their offering and Apple’s.

  1. Because of the free 3G, Amazon needs to have a class of apps that are subscription based. This may seem like a downside, but if you can keep the monthly cost low, this gives an Amazon app something that has been missing from the Apple AppStore: Recurring Revenue
  2. Amazon is a clear leader and innovator in e-commerce — specifically cross-selling. I think it’s very likely that Amazon will be able to surface apps all over their store. Make an app that helps people choose a digital camera, and it may be promoted on every camera page.
  3. The Kindle will be one-third to one-half the price of the Apple device, which makes it very attractive to do a large rollout to a mobile workforce. Insurance adjusters, delivery truck drivers, on-site construction, etc. need to read documents — they don’t need an iPod, fart apps, or games.
  4. The Kindle will probably always be smaller, lighter, and use less power — Apple could surprise me here, but the Kindle is so low-powered, it’s unlikely that they can’t keep up.
  5. Hardware keyboard — Apple could clearly innovate here — I’m guessing with an external bluetooth keyboard. If so, that adds bulk, weight and sucks battery.
  6. The e-ink display — no color is a downside, but the e-ink can be read outside — again, think outdoor, mobile workforce.
  7. Amazon’s Kindle DRM and book deleting are cause for concern, but if they have any sense, they will learn from Apple’s experience with AppStore rejections and loosen up. It doesn’t appear that they will from my first looks at the KDK.

Subscription apps + good enough for business will be a big win for developers. Business apps don’t go for $0.99 — the equivalent might turn out to be $5/month for something simple, and businesses won’t blink. Better than the up-front price is that you get a predictable income stream that isn’t subject to the whim of the top 25 lists.

This isn’t to say that Kindle will beat Apple in any quantifiable way (number of apps, number of downloads, number of customers, etc), but I think that the kinds of stories of real businesses being built on the Kindle store will be quite different from the lottery that the iPhone app market appears to be.

Amazon Kindle SDK (KDK): First looks

Last week, Amazon announced that they will be releasing an SDK for creating Kindle Apps. I know that three days before the big Apple Tablet/Slate/Canvas announcement, I’m supposed to be getting ready to tabletize my app, but the idea of developing for the Kindle is looking kind of interesting.

Given that the beta isn’t out yet — there isn’t a lot of information about the KDK yet. However, there have been some successful hacks of the Kindle and Amazon was forced by the GPL to publish their modifications, so we do know some things:

  1. The Kindle runs Linux
  2. Kindle GUI’s are written in Java
  3. There will be three models of apps, free, one-time purchase, and subscription. The first two will have a monthly bandwidth cap of 100KB/user.
  4. Advertising is listed as something you can’t do — perhaps they mean an app that only advertises, but even so, why not? Mobile advertising is large part of the app ecosystem, so I assume in-app advertising will be allowed.
  5. A generic reader is not allowed — again, does this mean a PDF reader wouldn’t be allowed? I can see Amazon not wanting the 3G being used to buy from other stores, but why not let me read content I get from other means (or from subscription apps).

The brevity of the developer guidelines is welcome, but I hope they elaborate on them in the near future.