Tuesday, November 27, 2012

Programming Demystified

If you wish to achieve something, don't just believe you can do it.  Believe you have already done it.  Feel it, desire it, experience it as if it was already there.  And as if it was easy.  Then go do it.
Ever since I first experienced a computer in the 1970's I've wanted to a) understand how they work, and b) make computer apps.  Understanding how they work was easy, just take them apart!  (no reassembly plan required)  Making computer apps was the mystery.  How do I get the computer to write my name?

It also turned out to be easy:

It's version 4 and it comes only in green.

Oh, so everything between the quotes is reprinted on the screen?  Cool!  Very useful.  Can it do more?

Did you notice the massive amount of memory?

And we have a program! (which apparently recognizes my brother and sister)

This is actually quite an achievement, because it can do it all over again.  Just write "run" and it will print the same names once more.  It executes a program.  But only until you switch off the computer of course.  Then it's gone.

Incredibly, more than 30 years later this is still how we make computer programs!

This might explain why triangles are useful
Yes.  That's true.  We have more colors than the human eye can see, we have surround sound in three dimensions, we can write a text message in Japan and it instantly reaches our friend in Berlin, and any old desktop computer can draw millions of triangles in a fraction of a second.  And it doesn't disappear anymore when we switch off the phone or computer.  But we still make programs by writing a little bit of text, and then executing the program.  This is true for the word processor you use to write invoices, for games you play on the iPhone, and for whatever browser/reader you use to read blogs!

I've tried to make programs for just about any computing device I've come in contact with.  This has led to experiencing 30 or so programming languages/systems, and at least (!) 29 of them have been text based one way or another.  Write some text.  Then run it.  That's how we make computer programs.

Maybe equally weird, we also still build computers the same way as then.  Before the 1970's there was actually quite a bit of diversity in how we made computer programs and how we built computers.  Then we discovered the integrated circuit, and suddenly the whole world aligned itself, and started focusing on faster and more.  And smaller.  Much smaller.  And much faster.

Smaller and faster is no small achievement though.  To put it into perspective, an investor may be content if an investment grows by 10% every year.  The improvement rate of computers has been around 40% every year.  Consistently.  For the past 40 years, and still counting!  Computers can now write the names of millions of siblings in the same time as two siblings in 1980. (though we may not have millions of siblings)  When something improves consistently with 40% per year, this is such a massive improvement rate that new uses of computers eventually become available even without other significant breakthroughs.  Like mobile phones.  There's nothing significant in a phone that a computer in the 1990's or 80's couldn't do.  But having so many things integrated in a unit that almost disappears in a shirt pocket, that in itself allows us to start using computers in completely new ways.  Just from them being smaller and faster.

Of course, printing names on a green screen is exciting only for so long.  Today we want our programs to look (and sound) like this:

Built with wxWidgets, this is from Mac OSX.

And suddenly our programs need to be more complex.  And they don't run on all computers or phones or tablets anymore.

The program that prints the names of my brother and sister had an interesting feature.  It would run on most available computers at that time, not only the Commodore Pet that this example is from.  And it ran on contemporary computers for another 15 (or so) years.

But if we still build all computers by the same principles, why can't all programs run on all computers and tablets and phones?  In my opinion, this is a valid question that people tend to forget to ask.  Like I mentioned in the prologue, we've pretty much accepted that there need to be barriers.  What's more, the barriers aren't there for technical reasons.  Apps are more complex today, but there aren't really any technical barriers to make any app run on any device.  If you want to know why Halo doesn't run on Playstation it's not the technical department you should be calling!

I won't go into that any further in this post.  But in future posts I will explain why I don't consider there to be any technical barriers (some people may disagree with that).  And why porting wxWidgets is a Pretty Cool Thing.


//A

"There is no order of difficulty in miracles. One is not 'harder' or 'bigger' than another. They are all the same."
- A Course in Miracles, Helen Schucman


Friday, November 23, 2012

Picture the Goal

Everything is connected.  In mysterious ways.
Sometimes, a picture is the quickest way to describe what a project intends to achieve.  For this project it's super simple, four pictures tells the whole story.  Next week we learn how all apps, phones and tablets are built.  It's probably easier than you think.  There will also be dolphins.  And some triangles.

Ok, the basic idea is to get this:

Colored text, not so hard.

to produce this:

A couple of windows, not so hard.

but run on this:

More windows, still not hard.

because then it will also enable this:

Whoah, cool!  ;-)


How hard can it be?


//A

“If you don't know where you are going,
you'll end up someplace else.”
― Yogi Berra




Monday, November 19, 2012

Prologue

- Why do you want to climb Mount Everest?
- Because it's there
(George Mallory)

Once upon a time...

What is wxWidgets, and why would you want to port it? And what is porting anyway?

Few people would know.  Even fewer will actually do it.  But the world wouldn't be the same without it.

As I go through the process myself, I will attempt to explain it in a casual way that can be appreciated without a technical background.  There will be jokes and pretty pictures.  And you will (yes!) learn programming by following along.  Entertainment and utility, all in one package!  ;-)

Here's the issue:

  • When Angry Birds first came out you needed an iPhone to play it
  • If you want to play Halo you need an Xbox
  • Logic Pro (create digital music) is only on Mac
  • Lots of programs for Windows will not work on your tablet
  • And so on...

This is incredibly common.  You can't use x because you have to have y.  We've all experienced it.  We keep experiencing it, over and over.  It's in fact so common that we've come to accept it as part of normal life.  Often, we don't even realize that it could be any different.

But it can.

Mountains and ports

For now, let's say porting means making an app work on a new device.  Like a phone.  Or a gaming console.  Or a desktop computer.  Anything really.

With that introduction, wxWidgets will be a lot easier to understand.  But it really deserves its own blog post.  For now, let's just say wxWidgets makes it easier to put any app on any device.  Now you have the tools to understand what porting wxWidgets means.

Foothills of Himalaya in 2008
In the early 1920s, George Mallory took part in the first three British expeditions to Mount Everest.  He is famously credited with the response in the beginning of this post.  I find that quote appropriate to this project.  A complex porting project can be a difficult challenge.  It's a step into the unknown.  It's not guaranteed to succeed, and the rewards are unclear if you do.  It's not even completely clear why you would want to do it.  If you want to play Angry Birds, just go get that iPhone!


And yet, here I am, dead set on completing this project.  I can't easily explain why I want to do it.  The best explanation I can come up with is "because it's there."  Fortunately, that's all I need at the moment.

It is unknown whether George Mallory actually reached the top.  He and his climbing partner disappeared in 1924 during their attempt to make the first ascent to the top of the world.  They stayed missing until 1999, when their frozen bodies were found.

Luckily the consequences of a failed port are not quite as severe, but let's still hope it works out, ok?  ;-)


//Andreas
“Mountains should be climbed with as little effort as possible and without desire. The reality of your own nature should determine the speed. If you become restless, speed up. If you become winded, slow down. You climb the mountain in an equilibrium between restlessness and exhaustion. Then, when you're no longer thinking ahead, each footstep isn't just a means to an end but a unique event in itself. This leaf has jagged edges. This rock looks loose. From this place the snow is less visible, even though closer. These are things you should notice anyway. To live only for some future goal is shallow. It's the sides of the mountain which sustain life, not the top. Here's where things grow. But of course, without the top you can't have any sides. It's the top that defines the sides.”

― ROBERT PIRSIG