Thursday, May 29, 2008

The Demise of the Desktop ... Not

Predicting the pending demise of the desktop seems to be quite popular. In the very near future, we are told, all our apps will be on the net, and all our files will reside on massive, but benevolently run servers. Our computers won't in fact need a hard drive at all, just a connection.

Frankly I don't see this happening for a number of reasons.

  • My Laptop is offline most of the time. I mostly use it on the train and don't have wireless broadband. In any case I doubt it would work too reliably sitting in aluminum clad train under high voltage cables.
  • At home my download limit per month is about 300MB and is about right for my usage. frankly I couldn't afford to access online apps all the time.
  • I don't trust the benevolent administrators of huge online file servers to keep my files confidential if it ever comes to the crunch. If large chunks of the worlds data are in one place then it becomes easy for governments to mandate the removal of 'harmful' material.
There are still a lot of development hours being poured into desktop environments, Gnome and KDE, as well as dozens of others, are active projects. Clearly the developers working on them see a future for the desktop, otherwise why would they bother? The grand Idea of the centralised file store has flopped a number of times, as Joel argues in Architecture astronauts take over.

And in a corporate environment there is another host of problems with thin client, issues of Privacy regulations and Commercial secrets. An interesting fact comes up in this artilce on The Daily WTF. Switching a corporate environment to thin client increases infrastructure costs. Suddenly your junior desktop support staff who know how to run Norton Utilities just don't cut it any more, instead they need more servers and more system administrators.

Personally I like my Desktop applications and I use them all the time. My laptop is set up how I want it and not how Google wants it. Even when I do use my firfox it is usually to read pages I've saved for off line viewing using the scrapbook plug in. And importantly the files that detail how I'll achieve world domination are tucked away in a computer that can't be hacked without physical access (one of these days I must encrypt them).

White space

I came across an interesting blog post the other this morning: Python Indentation considered boneheaded I like meaningful indentation. Because I find it easier to think that way. I had coded in other languages for quite some time before discovering python.

This means that I have probably spent weeks of accumulated time going back and adding semicolons to statements because I forgot to terminate them the first time round.

As for using python on larger projects. Well the answer is internal standards. If you try to contribute to C projects like GTK they come out and say things about standards right up front.
If you submit a patch and it doesn't meet the coding standards then we are going to reject it out of hand. Its quite a reasonable position to take.

Moreover a good editor will support a whitespace delimited language. My examples are from vim, though I assume that Emacs can do similar things as well (no need for another editor flame war).
  • Auto indentation sticks consistent indents on my lines.
  • Editor can highlight lines that mix tabs and spaces in their indents.
  • Files can carry a special comment which defines indentation rules.
  • If all else fails you can switch to a mode where whitespace characters are rendered so they are visible.
In my day jobs all the code is python. The code base is quite large and has probably had over twenty developers working on it over the last nine years. For reasons which are lost to history we use tabs only in all the files, and it works. Some developers do seem to feel strongly about the tabs vs spaces debate. Before starting here I used spaces, but when it comes done to it I really don't have a preference. About the only Thing I will attest to is that you should not mix the two approaches in the one file.

I had to write some java a while back, only a small simple problem, and after python I found it unbelivably hard. I realise this is largely personal preference, but iit felt like the syntax was fighting against me rather than helping me.

At the end of the day a good syntax is one which you don't notice. Foe me being a visual person seeing well indented code gives me a quick graps of what the code is supposed to do. One of my egocentricities in this regard is that I prefer:

if foo:
# do something else
if foo:
# do something else
Python will behave the same way in both cases, however for me the first option is more explicit. as I can see that we have an else branch without having to reach the code. If the body of the if is long enough it could be easy to miss that pesky return statement.

Wednesday, May 28, 2008

Pico Lisp

In my continuing search for a language to play with, other than python, I came accross Pico Lisp the other day. A very intriguing lisp dialect for several reasons:
  • Fully interpreted and yet faster then compiled lisp in some usecases
  • Persistent storage (essentially an object database)
  • built in Prolog.
  • built in web server and support for online applications.
  • No floating point numbers ?
That last point seems a little curious. but then i got to thinking how many applications out there really need floating point numbers? Well there are really a lot of applications that don't. In my day job I deal with online payments. No floating point numbers here, just express things as cents and be done with it.

Using floating point in financial circles is in general a big no-no, people get a lttle tucky when your working with money and make rounding errors. Also its a little hard to do anything with a fraction of a cent.

Graphics. Well yes and no. Fixed precision might be quite good enough. Heck there's a 3d flight simulator application to prove it even. The Documentation claims it can be easily extended with C, including writing C functions inline, unfortunately exactly how this is done, or what the limitations are, is not explained. Once I get onto the mailing list I plan to ask.

First impressions are that this is a very small, neat and yet still useful language. Time will tell if I can do something interesting with it though.

Tuesday, May 27, 2008

Bad Karma

I'm really going away from what I intended on this blog but ...

Sharon Stone's Karma comment has to be the dumbest thing any celebrity has said this year.

Karma is supposed to return to whom ever generated, and I fail to see how school children in Sichuan have oppressed Tibet. Its clear to anyone that this is a natural disaster which has affected perfectly ordinary innocent people. They have nothing to do with setting government policy in Tibet.

Seeing images of collapsed schools with a childs hand sticking out of them brings tears to my eyes. I can't imagine what it must be like to shift through ruble looking for your child. For some starlet to suggest that its Karma ... I'm lost for words really ...

Even the Democrat Presidential hopefuls haven't managed a gaff this bad.

I'd call for a boycot of Stone's movies myself, but in all honest I've never been a fan so I probably wouldn't have rushed out to see them in any case.

Wednesday, May 14, 2008

The Horse and His Boy

In my recent reading I came across The Darkside of Narnia a critique by Philip Pullman. Here is an essay which has had raised some very heated responces. A common thread seems to be to say that If you think this than you musn't have read the books. I don't think this retort is justified, and it would be very poor form to publish such an essay without reading the matirial you are critiqueing.

I can't speak for Mr Pullman, but I have read the books (ok I didn't get to the end of the last one) and I have to agree with him. Let Us take 'The Horse and his boy', which until I read it a second time had been my favorite of the Narnia books. So here we go with some questions

Is it racist?
Very much so. The Calormenes are depicted as dark skinned, turban wearing and following a religion based quite clearly on Islam. Every single Calormenian male depicted is a shrewed dishonest and evil. so much so that Shasta cannot conceive of anyone being charitable and honest. The only female Calormenian (other than Aravis) is portrayed as a twit who is interested in nothing other than cloths and parties. I believe in the last book Susan is condemned for having smiler interests.

Mean while all the honorable Humans are White, and Aslan fearing.

Are there literary shortcuts?
Rule number one of fiction is show don't tell. Lewis tells constantly. Aravis tells the start of her journey. Later one of the Narina's describes to Shasta exactly how to get to Narnia. Note he is not doing this deliberately, and any inteligent person would not divulge this information in enemy teritory, but he does so simply because the story demands it.

Rule number two: the Author should not speak directly to the reader. Lewis does this a few times as well, once to compare to contrast Calormenian story telling and Essay writing (as taught to the assumed audience) and again to urge his audience to also read "The Lion the Witch and the wardrobe", In case they have not done so already.

Rule number three: the Protagonists should not rely on the Caverly to save the day. Well the Story is driven by Aslan roaring. He herds the children together, and protects them form wild animals, and guides them every step of the way.

At the end of the day the evil are punished, the good (those who accept Aslan's will) are rewarded, and in true cristian fasion the Proud horse becomes humble. Instead of the expected growing attraction between the protagonists they get married in the future for the sake of convenience. While there would be no call to make that the main focus of things, some subtle hints of romance would not have been out of place, holding hands even.

All in all there is no character development over and above the intended moral lessons. So Pullmans critique is spot on. Narnia really is nothing more than thinly disguised preaching from the pulpit. The plots may be good but there is nothing holding them up.

Wednesday, May 07, 2008

What Erlang is bad at

Recently I wanted to write a program which would take sections from a texmacs document and run them through the style command. And then process the results to get a particular set of statistics.

This includes some additional crunching on what style produces. As it was my language of the month as it where I thought I'll do it in Erlang, but after spending a train trip searching the documentation I found that making system calls in a subshell is not somthing that erlang can do at all easily. I certainly couldn't find a way which did not involve writing a c wrapper around in any case.

So it was back to python for this one and a usable script done in about an hour. Lessons learned: Erlang is not a good language for quick and dirty scripts. I'm not saying that it can't be but the standard library dosn't seem to support such a use case.

An aquantence who is also programmer told me once that he is also tempted to look at Erlang now and then, but he can never seem to find a project that he really wants to implement in it. More often then not he ends up in exactly this position "Man this would be so much simpler in Python" and so that is what he uses.

I think I have a new point to add to my list of what makes a good language:

"Can be used to solve small problems easily"

In this regard anything which requires copious poilerplate or is missing simple ways to interact with standard in and out looses instantly.

Thursday, May 01, 2008

Virtual Machines

In the recent debate about weather or not languages should ship with there own virtual machines, or use an established one. I'm with diversity here. Put simply different languages have different needs. Just because the JVM is good for java it doesn't follow that it will be good for Erlang. And Erlang is sufficently different to warrant it's own vm.

  1. An Erlang vm can assume that memory will not be modified. I expect his has a big impact on how you manage memory
  2. An Erlang vm requires tail recursion optimization. if you don't have this your code will be slow and use up more stack space.
  3. Every Erlang process has a message queue. Most VM's will not provide a message queue out of the box.
A lot of the same things also apply to Haskell, you can't expect a functional language to work optimally on a vm designed for procedural languages. the code optimizations and memory management strategy needed is radically different. In this I'm quite in agreement with the following post:

Making it stick.: Huh?: "The fact that it runs on its own interpreter, bad."