Sometimes they really are indistinguishable

“Any sufficiently advanced technology is indistinguishable from magic.”
Arthur C. Clarke

When a non-techie friend of mine moved to San Francisco, she overheard two guys talking next to her.

“What are you up to,” one of them asks?

The other replied, “Oh, I’m trying to learn Python.”

“Excuse me,” my friend interrupted them. “But I believe it’s called Parseltongue.”

(After living here for a while longer, she became very embarrassed. And though it wasn’t exactly what he meant, I still think Mr. Clarke would approve.)

On being a beginner (again)

Compiled from three separate discussions on IRC, twitter, and in person:

“Whatcha do with your time these days? Learning Rails? 😈”

I did pick up Objective-C again after an aborted attempt at learning Swift. Mostly I’m trying to catch up on the javascript frameworks that have come out since I stopped coding. Right now it’s AngularJS—I figure I can jury-rig React into it if performance becomes an issue.

On the non-programming side, I’ve been messing with Ansible because I just got tired of doing things by hand—and I never needed to learn this because I’ve always had operations engineers working with me.

The ripping on Rails thing is over with me because there’s no point in arguing over how to solve a solved problem—today, the web problem is the easy part. What I find strange is people still feel the need to defend Ruby on Rails. I mean who the fuck cares what your middle layer code is written in when everything is an API to something written in Javascript?

“I don’t like that everything is an API to something in Javascript. As a user, the Web feels slower and flakier than it used to.”

I don’t like that everything on the front-end is pushed toward a single-page application. The reason for this is that the DOM-based model of front-end javascript (e.g. jQuery) gets so taxing when the application gets big because you’re bolting feature-on-feature, library-on-library to get it to work as smoothly as you envision. At a certain point, a true MV(VM) javascript framework (e.g. AngularJS) gives you much more because it abstracts all that in a consistent manner.

As soon as you buy into one of these, you’re invested into a huge initial javascript payload which causes you to not want the user to leave the page to unload anything, which then forces you into an API-based model with HTML partials and a client-side route/sitemap and more crap in the payload until you have a single-page application.

And then pretty soon your website is like Flickr where I swear every tenth click I’ve got to reload the page because the UI became non-responsive and I’m deciding to open the app in my iPhone just to do something without that frustration. How fucked up is that?

But then I look at Bootstrap and I figure, I’d rather have a SPA than everything looking like it was designed by some Apple-loving hipster (and this coming from a person who has used and loved Apple products longer than they’ve been alive).

“I’ve always enjoyed your talks and lamented that you didn’t remain on the PHP speaking circuit.”

Maybe I’ll start speaking when I have something to say. Like I’ve said before, PHP solves the “web problem” very well, but the web-problem is not a hard problem anymore.

Remember, it’s been four years since I’ve done any UI programming so everything is new to me. Basically, I’m a newbie, and I don’t think anyone wants to hear from someone who doesn’t know what they’re talking about.

But I did notice this from managing engineers: the worst problem a coder can get into is fear of having to start over. You get good at what you’re good at and when things pass you by, you feel the need to protect what you have because its what you know.

That’s how I feel about Ruby on Rails and that’s how I feel about me and PHP.

So, I’m a beginner again.

Learning to curse

I forgot how much I hate the fickleness of writing software!

I finally gave up on Swift (for now). It’s a easy to pick up language because it resembles more a modern scripting language than a compiled one, and frees you up from historical artifacts like Smalltalk, C pointers, and reference counting. Plus you get awesome things like playgrounds:

Sure, it takes a little bit of chucking random “?”’s and “!”’s in your code before you get the hang of optionals, and I’d fear the performance of a basic structure like a b-tree written in Swift, but it interoperates with C and Objective-C so I don’t have to worry.

Or so I thought. Because of strong typing and the lack of built-in overloads, poorly documented character-based1 functions, here is how I inject a a random letter into a string:

let randomletter = "\(String(UnicodeScalar(65 + Int(arc4random_uniform(26)))))"

And then you find it doesn’t always release variables when you use optionals. create some optional simple objects, add them to an array reset everything and see what your NSLog() (e.g. println())) prints in your deinit:

e.g. BNRItem.swift:

import Cocoa
import Foundation

class BNRItem: NSObject, Printable {
    var itemName:String
    init(itemName name:String)
    {
        self.itemName = name
        super.init()
    }
    deinit {
        println("Destroyed \(self)")
    }
    class func randomItem() -> BNRItem
    {
        let randomAdjectiveList = ["Fluffy", "Rusty", "Shiny"]
        let randomNounList = ["Bear", "Spork", "Mac"]

        let adjectiveIndex = Int(arc4random_uniform(UInt32(randomAdjectiveList.count))) //arc4random() overflows Swift int
        let nounIndex = Int(arc4random_uniform(UInt32(randomNounList.count)))

        let randomName = "\(randomAdjectiveList[adjectiveIndex]) \(randomNounList[nounIndex])"
        return BNRItem(itemName: randomName);
    }
   override var description:String {
        return "\(itemName)"
    }

and main.swift:

import Foundation

var items = BNRItem[]()

var backpack:BNRItem? = BNRItem(itemName: "Backpack")
items.append(backpack!)
var calculator:BNRItem? = BNRItem(itemName: "Calculator")
items.append(calculator!)
backpack = nil
calculator = nil
items.append(BNRItem.randomItem())
items.append(BNRItem.randomItem())

for item in items {
    println(item)
}

// Destroy the mutable array object
println("Setting items to nil…")
items = []

creates 4 items, deletes three. Hello, memory leaks!

Then there are issues when you call C functions like CoreGraphics from Swift. My personal favorite is depending on if I restart Xcode before compiling, one of my apps compiles file or throws an error:

SetAppThreadPriority: setpriority failed with error 45

Great!

That’s not to say I won’t use it for the future. It’s just too frustrating for me to programming model (Cocoa Touch) in a language that I’m rusty at (Objective-C) in a new IDE (Xcode), translate to a language I don’t know (Swift), and not know if my errors are my own stupidity, or just the compiler is buggy.

Yes, someday Swift, and Swift playgrounds for learning the language, and perhaps even a mix of Swift and Objective-C in a iOS project, but I’m putting the language down for now until I learn Cocoa Touch.


  1. as opposed to string based functions 

Learning to smile

Learning to smile

I’ve been a manager for 2.5 years and I’ve been too long away from programming. There is something just so wonderful about being able to work again in a world where there is a right and a wrong.1

I decided to start to finally2 teach myself iOS development today for: first, because I’ve never done it before and second, because it’s an opportunity to learn a new language and re-learn an old one3 I haven’t done for over a decade.

We’ll see how it goes. I’m not optimistic.


  1. …and getting the feedback to know which is which! 
  2. This does not count. 
  3. If you call writing a median-based BPM counter for Mac OS X, “learning.” I think the jury is still out since Xcode, memory management, and the user-interface are so different now. 

Learning Programming Part 4: "Programming is Hard"

Previously: Part 1, Part 2, and Part 3.

Programming, it turns out, is hard.
Eloquent Javascript (and typical)

A few months ago, a girl expressed to me her frustrations about, in particular, the attitude expressed many engineers on her attempts to learn to programming.

“They act like learning programming is hard. They imply that if you haven’t been programming since you were seven, there’s no hope for you,” she explained.

I opined, “If someone can learn to program when they are seven, then it must not be that difficult.”

Think of all the things you couldn’t do when you were seven—programming is less difficult than all of those.

Learning Programming Part 3: C/C++ superiority

Previously, Part 1 and Part 2.

The other day, Marie pointed me to an interesting article where Jolie O’Dell decides to go back to school to get a computer science degree. She asked me what my thoughts were on some comments concerning the necessity of learning C/C++. I’ll paraphrase in order to avoid singling anyone out.

“Scripting languages create holes in proper programming. All a language, like PHP, will do is make you a PHP programmer, while a language like C or C++ will give you a fundamental understanding that can be applied to all languages and make you a better programmer no matter what the language. This is because these languages expose you to the way the computer really works (instead of abstraction): for instance, how a string is really created, or an array, or dynamic memory allocation. If you learn PHP, you will never bother to learn the low-level reality.”

The above is a munge of many commenters’ discussions.

What do you think of the above statement?
Continue reading my reply after the jump.

Who puts the P in LAMP?

Received this yesterday:

So I’m thinking of starting a new web project and was wondering if I could seek your advice. My tendency is to use PHP since that’s what I know and have used most in the past. Though, after talking to a lot of folks (namely Googlers…go figure), I’ve been encouraged to instead choose Python.

Seeing as you’re my favorite PHP Terrorist I was wondering if you have any specific thoughts on the subject.

I still need to write another article on Python, but the short answer is I think if it’s web, PHP is probably the better choice.

“PHP is the shortest point between two distances on the web.”
—Me, tongue-tied at a talk

However there are some mitigating factors to consider:Continue reading about Python vs. PHP for web after the jump

1500 Lines of Code

Original article posted to PHP Advent 2009, Click to jump to discussion. Happy Holidays to you and yours!

Even the best of us can only write 1500 lines of code a day, so we need to make those lines count.

There were so many great articles in PHP Advent this year, that I couldn’t think of a good topic—I like to believe my peers stole all the good ideas this year… 🙂
Continue reading about Read about 1500 lines of code after the jump

Learning Programming Part 2: Programming Frameworks

A selection of programming language textbooks ...
Image via Wikipedia

(Full disclaimer: I work at Automattic and am a speaker at PHP conferences.)

A couple days ago, Gina Trapani posted an interesting article on learning to program.

This reminds me that some people may take the wrong points away in my last article on the subject, the priority shouldn’t be what language you should learn, but rather, what is going to get you motivated to learn. PHP is a popular language because it naturally invites “immersion” style learning, not because it makes a good teaching language—which it doesn’t. That is, assuming the thing you are immersing in is “building a website”. As I like to say:

PHP is the shortest distance between two points on the web.

In the comments, I wrote:

After [the first] chapter, I’d say [PHP and MySQL Development]offers the most “immersion” gratification (at the least cost) than any other language’s textbook. The chapters are easy and by the end of it you have an eStore written and working from scratch. What do you get at the end of the Learning Python book? And how easy was each subsequent chapter? I’d say much less and much harder.

[Unfortunately,] it’s that first chapter that does the first timer in.

Continue reading about More about learning web programming after the jump.