Sunday, 16 January 2011

Why Python? Why Linux?

Since the whole raison d'etre for this blog is that I'm teaching myself Python it might make sense to explain why!  I've programmed in one form or another right back to my first home computer - a 48k Spectrum back in the early 1980s - generally speaking all simple programs to address a specific need I had at the time.  As a result I've ended up with a basic understanding of BASIC (several variants including Visual Basic and VBA), COMAL (a language used mainly in schools for teaching (and possibly not at all any more!), C++, Delphi (Pascal), Javascript and Fortran which combined gives you the ability to read most languages.  However I am far from an expert in any of them - so when I needed to write a program to control a serial device from either a Linux or Windows computer I started exploring the options.  After some searching it became clear that this could involve a bit of effort porting across platforms - and even C++ which is routinely "offered" on both platforms was likely to throw up problems with needing different serial libraries.  I was then introduced to Python and clicked with it immediately - perhaps those early days with BASIC and COMAL interpretters on a Spectrum and BBCB convinced my of the advantages of Interpretted languages!  When my 7 year old son declared he'd like to write a program I chose Python and he was learning the elementary steps quickly - with none of the pain involved in compiling etc, but I had also seen some of the really advanced features and impressive programs which had been written in Python and I was convinced. 

So why do I want to program in both Linux and Windows.  Firstly let me say whilst I am pretty computer literate and reasonably confident with most things I am not a serious Linux geek!  I'm also not a Windows/Microsoft hater, but I do get frustrated when computers which ran fine when they were new slow down amongst clutter either legitimately added by users or malware acquired through use.  I started off my experiments with Linux a couple of years ago using PCLinuxOS to overcome this and enable me to use a really cheap PC and whilst I found some things worked really well - I also found a few things incredibly frustrating - in particular doing anything "non standard" as the PCLinuxOS philosophy is not to tweek the OS in case you break it.  One day I did break it and rather than reinstall PCLinuxOS decided to try Mint - a different distribution of Linux which is also designed to be really simple to use, especially for people migrating from Windows.  Mint was amazing and essentially everything (except an old webcam I have) works out the box and just how you would expect it to!  I've also got a netbook (Acer Aspire A110) which until recently was running the Linpus Linux OS that came with it - but has just been moved onto the Mint LXDE distribution.  Mint is based on Ubuntu (the most popular distribution of Linux) - so if something I suggest works for me in Mint it will almost certainly work on native Ubuntu too.  In fact it will probably work on any Linux as it will be unusualy for me to be doing anything too clever!

Whilst I like Mint, and almost never have to go back to Windows for normal home or office tasks, it would be niave to ignore the huge number of machines running Windows, and I have some scientific apparatus which only runs in Windows - so any code I need to run there also needs to run in Windows too.

I'll start off this project with the following basic assumptions about anyone who wants to borrow, use or modify my code:
  1. You are running Linux.  The code should port to Windows (or other systems) with minimum effort - but at this stage I'm only writing it with Linux in mind.  A "next step" will be to make it cross platform!
  2. You already have Python installed.  This is probably the case if you are using Linux but if not then it should be readily available via apt / yum / synaptic or whichever package manager you use.  e.g. something like: sudo apt-get install python
  3. I'm using version 2.6 of Python - I can't guarantee backwards compatibility but will highlight anything that becomes obvious to me as an issue.  The change to Python v3 involves some major differences.  I see it as a future project to check and fix any forward compatibility issues (probably once v3 is finalized and a bit more established).
  4. I assume you already know (or will work out) how to use Python, and edit the source code files etc.  I intend as things develop to produce a "distributable" version which will allow any old person to install and run my code - but the early stuff will all by simply *.py files and you'll need to install libraries etc if they are missing (anything I need to download I'll briefly describe how/where).
  5. You'll recognise this is a work in progress, from someone developing their knowledge so it comes without any guarantees or promises it can be made to work on your system.  If you want to be confident you can get your robot arm to work use the software supplied by the manufacturer and run it in Windows!  Documentation will not be at a "professional" level!
  6. This is a bit of fun and learning for me.  If you want to use the code feel free.  If you want to modify the code feel free.  If it is being published or used in a public arena then I'd ask for an acknowledgement in the source code and on any "credits". If you make improvements then why not send me the code (or post it in a comment) and then it can be shared here for everyone to see.  In the unlikely event you think there is money to be made from this (or a derivative of it) then please get in touch and we can formalise license terms.

No comments:

Post a Comment