Python Programming, news on the Voidspace Python Projects and all things techie.

First Impressions of the Macbook Pro and Mac OS X

emoticon:mirrormask I promised you my first impressions of using a Mac laptop. It was a bit long for a blog entry, so I've written it up.

The Macbook Pro running Parallels

I have recently started using an Apple Macbook Pro laptop on my daily commute and for developing. Having only ever used Windows it was quite a switch. This article records my first impressions of the Apple laptop and the Mac OS X operating system.

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-08-09 22:50:32 | |


EditArea Syntax Highlighting Javascript Code Editor

emoticon:new_document Whilst looking for ways to improve my 'Resolver in the Browser' I discovered EditArea.

This is a Javascript replacement for the <textarea>...</textarea> tag, a syntax highlighting code editor with lots of features.

The features include Python syntax highlighting and it works very well.

The EditArea Javascript Code editor

It also provides a 'goto line' line dialog, full screen editing, a find and replace dialog, undo and replace and so on. It is very easy to configure and program with (not a drop-in replacement for textarea but a reasonably sane API) and makes an excellent addition to my application. Smile

I've quite enjoyed the bit of Javascript programming I've done for 'Resolver in the Browser'. It's a quirky little language and makes you do a lot that is already built-in to Python, but it has a lot going for it (excluding weak typing and performance of course). Although Javascript has no native concept of namespaces they are easy to provide using an object as a namespace. I would like to practise writing structured applications in Javascript but don't have the time at the moment.

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-08-08 21:37:45 | |

Categories: ,

Ruby is Hard

emoticon:nightmare Ola Bini, one of the core developers of JRuby, has posted a blog entry about some of the intricacies of Ruby:

Ruby is Hard

I actually have nothing against Ruby, in fact it is doing a very good job of popularising dynamic languages. Plus the fact that Andrzej (a new blog entry is overdue Andrzej!) likes it means that it can't be all bad. Wink

If it wasn't for the fact that I'm itching for a good excuse to explore some of the Python web frameworks I might even be tempted to learn it.

Ola's entry worries me though. His example code is:

class Foo
 attr_accessor :bar
  def initialize(value)
   bar = value

In this code, the meaning of bar = value is dependent both on the context (of being an attribute accessor) and on the casing of the variable name. Apparently this can bite even experienced Ruby-ers. The fix (kinda ironically) is to use self to make bar an instance rather than a local variable.

Now every language has its quirks (and Python is no exception), but it seems like a clear example of both why an explicit self is a good idea and making casing semantically significant is a bad idea.

To be honest though, I'm slightly swayed by the argument that programmers should be allowed to attach methods to the built-in types if they want to. I still think that doing it is a bad idea, but making it impossible does seem to go against the Python philosophy of giving programmers as much rope as they want (to hang themselves with or otherwise). I also like the fact that with Ruby (allegedly [1]) you can catch the use of undefined variables with method_missing. With Python's equivalent (__getattr__) you can only catch access to missing methods and attributes. This feature makes for more expressive DSLs.

In Python (from 2.4 I believe) you can achieve the same effect by exec'ing code in the context of a custom object that will dynamically provide variables when asked. This requires keeping code as strings or compiled code objects though, so does not lend itself to creating frameworks with.

Another nice feature is being able to use exclamation and question marks in method names. This makes for some nicely expressive method names, and naming is everything...

[1]Andrzej made me promise not to quote him on this...

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-08-08 20:54:55 | |

Categories: ,

Resolver in the Browser with Silverlight (a Preview)

emoticon:cards As part of the Silverlight talks I'll be giving at PyCon and Mix I'm writing a version of Resolver that runs in the browser.

The user interface is Javascript using the ExtJS grid. The spreadsheet engine is written in Python (IronPython of course).

Resolver in the Browser with IronPython and Silverlight

I had to use a few tricks to get the grid to do what I wanted. When you enter edit mode in a cell I dynamically swap out the value to be edited. It needs to be the formula rather than the displayed value. If you leave edit mode without making a change, you don't get the 'afteredit' event which I need to swap the displayed value back in, so I had to work around this. Plus reloading the results after an edit loses the selection (the data must be reloaded because changing a single cell could change the displayed value in any cell that depends on the one you have edited). I'm sure there are better ways of achieving some of the things I've done, but sometime I'll post the code for you to vilify.

This application is written with less than 500 lines of Python, perhaps a couple of hundred lines of Javascript and around a hundred lines of C# that allows the Python and Javascript to talk to each other. The core Python engine was based on a mini prototype that was built to test grids when Resolver was a young application. It took very little modification to get it to work with this application and made my life a lot easier!

Despite being small, it is basically a full spreadsheet engine. One nice touch is the output pane. I divert standard output so that print statements in the code go to the output pane. Very useful for debugging!

Entering values or formulae in cells generates Python code (in the correct order) which is executed to generate the results. You can enter arbitrary code in the user code pane which is executed before the generated code. You can use .NET objects or define functions here which can be used in formulae, you can also set cells from code.

Tasks left are to make it look prettier (!) and to add a front end that accesses a server side web application for loading and saving spreadsheets. This will use some of Silverlight's AJAX capabilities. Christian showed me how to get a simple Pylons application started. It was astonishingly easy and will be ideal for my needs.

The only remaining issue (of about ten minutes ago anyway) is that it interacts badly with one of my Firefox extensions and crashes Firefox. I have a VM image where it runs fine with Firefox, but not on my main machine.

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-08-06 22:17:56 | |

Categories: , , ,

Python in London Banking

emoticon:ghostradio I got contacted by a headhunter asking if I was interested in a job as a 'front office developer' for a London hedge fund. The position commands a lot more than I am currently on (in excess of £100K with bonus), but there are various reasons why I don't want the job (plus reasons why they might not want me). Basically it boils down to the fact that I am really enjoying my job and learning a lot, and I figure that a situation like that is worth a lot. Additionally the job description notes that it involves working with traders who are "demanding users". There are more appropriate adjectives than demanding... Smile

Anyway, there is a lot that is interesting about this job.

  • Their production systems are in C#, Python and Lisp
  • The required experience is in any of the top three object oriented languages - Java, C# or C++. Python experience is not a requirement

I regularly hear about London banks, and hedge funds, that use Python. Usually my information is from job adverts and 'third parties', you rarely hear directly from those in the banking industry who use Python.

I figure that banking is another 'dark market' for Python, where it is used a great deal but rarely as active members of the community. (EWT being a notable exception of course.)

The reasons that Python is suited to this high-pressure industry probably include the following:

  • Rapid development
  • Experienced programmers can learn Python very quickly
  • Simple cross-platform deployment
  • Debugging interpreted languages tends to be easier (and require simpler tools)
  • Hot fixes can be applies in place, just by modifying a source file if necessary
  • A mature language, with good performance, that interfaces to C libraries and other languages
  • A wide variety of quality libraries available

In an environment where a software failure can start costing a lot of money very quickly, some of these points will be extremely important.

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-08-06 20:57:11 | |

Categories: , ,

IronPython at Mix UK

emoticon:ghostradio The speaker and talk information has gone up for the Mix UK conference:

Mix UK is a Microsoft conference for developers and designers. This year there is a lot on Silverlight.

I'm speaking in the afternoon on day 2. Apparently my talk is entitled "Python et al: Using Dynamic Languages in .Net and Silverlight". That's not exactly what I agreed with them, but close enough. Razz

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-08-06 03:21:17 | |


Interesting New gadgets

emoticon:firefox Several new gadgets have launched recently:

  • The Drobo

    A 'storage robot' that handles redundant backup with hot swap and addition of drives for you. Looks easier to configure and use than RAID.

    It costs $499 in the US and has just become available in the UK for £350. The usual premium for buying in the UK. Sad

    At the moment I have more than enough storage, but Drobo would be a safer solution.

  • Zonbu

    A small Linux based home computer that costs as little as $99 plus a subscription fee. It uses online storage (S3 according to Ian Bicking).

    It sounds like an excellent hacking device, but without the subscription fee it costs $249 which is not such a bargain for small devices. Still tempting though.

  • Chumby

    Another small hackable computer gadget. This is effectively a soft toy with a screen and a computer behind it. Widgets are apparently programmable with Python and flash! Very tempting. Smile

  • Multiverse

    Ok, so this isn't a gadget at all. The Multiverse is a software platform for creating MMOG.

    It is still in beta (despite the 1.0 release) and the client crashed a few times for me. Plus I couldn't find anyone else in the few example worlds at the time I tried. The worlds are pretty slick though. Apparently parts of the worlds are scriptable in Python.

    It's interesting because online worlds are interesting, but this is a platform for creating online worlds. Now I'd love to script an online world in Python.

On the subject of gadgets, my phone contract is due soon. I can either wait for the iPhone, or wait for the next version of the Open Moko. Hmmm...

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-08-06 02:57:07 | |

Categories: , ,

Resolver at PyCon UK

emoticon:noise All the talks for Pycon UK (September 8th & 9th) have now been announced. There are three talks to be given by Resolver people:

  • Test Driven Development, Jonathan Hartley
  • The New Age of the Amateur: End-user Computing without Tears, Giles Thomas
  • IronPython in your Browser with Silverlight, Michael Foord

All of the Resolver staff will be there, and I'm really looking forward to the event. Apparently 125 people have registered already! This is great news for the Python scene in the UK.

Talks I'm particularly interested in include:

  • The Bazaar Version Control Project, Michael Hudson
  • Using and Developing with Python Eggs, Stephen Pascoe
  • The PyPy Project, Michael Hudson
  • Building Systems with Kamaelia and Kamaelia Core Internals, Michael Sparks
  • An Introduction to Twisted, Richard Wall
  • Stackless Introduction, Christian Tismer

And of course the keynote by the effervescent Simon Willison. There are lots more that look interesting though. Smile

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-08-06 02:50:27 | |

Categories: , ,

Hosted by Webfaction