Vennard.org.uk © Antony Vennard.
 
Home   CV   Blog   Maths   Code   Contact  
 

I just lost interest in PHP…

March 10th, 2010

Anybody who has done any web development of any variety, even if on a small scale will at least have heard of PHP. I am mostly, it has to be said, a client/server style developer and I’m much more at home working my way through C/C++ or Java than anything else. I also recently learnt and used Python in anger (aaarrrggh! or maybe hiissssss?). However, I’ve until recently always thought PHP – one script, one web page.

However, recently I started researching frameworks for web development, as I picked up from a really talented contractor I worked with that frameworks make web development much faster and much more flexible and as such are equivalent to the APIs I’m comfortable with (Win32/GTK/Qt/Linux/RCP/Swing/… etc). So I did a load of research, focusing originally on PHP web frameworks until I read a review of Django. I took a look. I am now hooked. Python is infinitely cleaner to write than PHP, it abstracts out the data from the code logic and the user interface too, like any well designed software package. Ok, there’s a few violations of the UNIX principles, like chuck everything in one API like Java, but that’s the modern way anyway and Django isn’t so heavyweight the average VPS/Shared Hosting package can’t cope. So.

Basically, expect a site re-design around here. Wordpress will still be the blogging engine for now, until I can be bothered to replace it. But, wow, basically.

Hi. I’m a penguin.

March 7th, 2010

Inspired by the recent IE8 adverts.

Hi, I’m a PC. I regularly get abused by bad software downloads, visiting dodgy websites, games and all sorts of other things. I start off pretty nippy but end up eating myself whole. I’m pretty dull, I feature in every office because I’m easy. I basically suck doing jobs I was originally designed to do until someone packed in every feature they could think of. I have a weight problem – too much bloat. If I run your phone or any other small device, you need a new device. I do hold up some of the web because I’m very point and click. I’m the master of badly written software.

Hi, I’m a Mac. I’m basically a wannabe. I’m all about the looks and I have a minor obsession with leftover apples. I’m a fave with graphics designers and audiophiles, cos they’re cool, don’t'ya know. I’m no use at anything other than looking good, mind.

Hi, we’re FreeBSD, IBM AIX, HP-UX, Oracle Solaris, OpenSolaris, NetBSD and OpenBSD respectively. Collectively, we’re like the penguin, just not as well known or widely used. We do a lot of big server stuff, maybe some super computer bits, databases and other stuff.

Hi, I’m a netbook. Stop laughing.

Hi, I’m an iPhone. I have a wide choice of shit applications available for you to freely waste your money on that won’t help your life any more than a pen and paper and good memory will. Not that I’m an expensive gadget…

Hi, I’m an Android. I’m actually a penguin.

Hi, I’m a penguin. I’m freely available. I come with thousands, if not millions of freely available pieces of software. I can be put together any way you want. I’m about choice. I’m about customisation. I’m secure too. I run on your Microwave, Car, Mobile. I run on supercomputers, mainframes, on networks. I hold up the world’s e-mail and web. Conceptually I’m old. But I’ll run on the next big thing. I come in every colour, shape and size available. I’m used in research and in the every day. Unlike Macs and PCs I actually have working ASLR and a working FLASK/TE (MAC) implementation. If you don’t know what that means, basically, I am very secure. I rock. I can do everything all of the above can do, better.

Student politics and socialism

March 6th, 2010

Right, blog post 51 is going to take a pop at student politics, and probably socialism too.

Firstly: student politics. My experience of this is at Durham, where we had two levels of politics: the students’ union and the junior common room (JCR). The latter was specific to your college and considered by most people to be more important. The thing I never really got was why anyone would want to spend 7-8 hours in a meeting on a Sunday night arguing about the price of vending machine goods or what colour badges to award the rowers. Give them a gold star, who cares. I care about and know a bit about the politics of the country because that affects me; 99% of student politics does not. It is not interesting.

But, that’s not all. Durham University’s Debating Society recently tried to invite Nick Griffin, that guy from the British Nasty Party, to have a debate about how racist he is. Anyway, this was all set up and arranged until the welfare and LGBT reps from the NUS sent a somewhat strongly worded letter to the DUS telling them not to hold the debate. In order to make sure it didn’t happen, they got the UAF (United Against Facism) to “mobilise” large numbers of students and get ready to descend by the coachload on Durham. Not only that, but the resultant security implication was the responsibility of Durham’s Student Body.

There’s something fundamentally wrong here. Everyone has the right to hold an opinion; morality is not the law, although the way people go on you’d think it was. It’s acting on that opinion that becomes illegal. I can say and argue what the hell I like, thanks. It’s ironic that a lefty-organisation like the UAF is basically as militant as the right and just as prepared to violate human rights, just on different levels.

Now, also, students at Sussex have recently been holding demonstrations against cuts in their university’s budget. Not a problem for me, up to the point they’ve decided to break into their Vice Chancellor’s Office. See this link. This is breaking and entering and therefore illegal. It’s also very immature, deprives other students of university facilities and just a bad way to go about things. Besides, the problem is higher up in the funding chain really, oh, and if the government hadn’t screwed up our economy, you wouldn’t be in this mess.

So, as far as I’m concerned, student politics has actually failed. It doesn’t represent the interests of mainstream students in any capacity, except to give us cheap CDs from HMV. Sure, students’ unions do a good job, but they’re in effect staffed organisations these days, albeit with charitable status. The overall system, however, simply appears to be a vehicle for socialist extremists to cause trouble.

Another thing I’m struggling to figure out is why student politics and socialism seem to go hand in hand. Is it the case that some of my peers think that “nobody’s thought of or tried the whole sharing idea before” because if it is, you’re wrong. Which leads me nicely onto socialism.

Socialist ideas work in some small areas and corners, like the NHS. However, as a larger method of governing society, they don’t work. Allow me to explain: scarce resources = demand for resource. Mix this with private property and you get trade where two demands are mutually available. Sorry, that’s the way it is. Now, you say, we could have a regulating authority step in and prevent all this. Do you honestly expect those with power not to abuse it? If so, you’re making some very naive judgments about human nature and really need to read some history books.

Secondly, there’s the concept of competition. I want to be rewarded for the good work I do, thanks, I don’t want to share it with everyone unless I have good reason to do so. I’m good at what I do and whilst there are better people than me, there are also worse. There’s a hierarchy there we can’t erase, sorry, if I can do a better job I want to win the work/earn the money, not have it given away because “it’s fair”. Don’t get me wrong, socialist ideas do work, sometimes. On the face of it, there’s Open Source and things like SO. But, I do get something out of those, it just isn’t monetary. Equal distribution of wealth, however you measure that, just isn’t possible even in these fields. It isn’t my right to know how to do xyz; I go through the hard work and spend time learning it. I might well contribute it for free as in beer back, but someone else still has to “spend” to make use of it.

It is a hard line to draw, especially as an open source user. The principles are different there, however, we’re talking about the free as in freedom / libertarianism angle, and yes, I’m all in favour of empowering the individual as much as is possible whilst keeping some sense of regulation.

Finally, just in case, participatory economics. I’ve heard some socialist arguments along the lines of “well, communism/traditional socialism doesn’t work, but parecon does.” The basic idea is mumble mumble something about planning the economy such that everyone gets a share of doing work (some work rotation scheme) and parcelling out goods based on quotas. It might work in very small scenarios such as teams at work, but try doing it on the scale of the country. It wouldn’t work – that’d be bureaucracy on unheard-of scales. Not only that, but the job-rotation thing is utter nonsense. I can’t sing to save my life and I’d be a rubbish child’s entertainer. I also don’t know much about law beyond the cursory stuff. Nor biology. But I can do problem solving, maths, programming, engineery-things. Adding specialisms to parecon sounds to me just like “industries” – basically, as soon as you try to fix the faults of parecon it becomes the free market economy anyway.

That’ll do for this evening. Off to make eggy bread.

Lessons in OpenMP #1

March 1st, 2010

What is OpenMP? As far as I’m concerned it’s by far the fastest way to achieve SIMD or Vector processing – Single Instruction, Multiple Data execution. To give you an example, consider the case where you have a number of calculations you wish to do. You could call the results an array of results, correct? Well, anywhere you can do that you can probably parallel process and on small datasets notice no difference whatsoever. However, on large datasets, things will probably speed up.

Anyway, I came across an interesting problem this evening: how do you have a private (per parallel thread) dynamically allocated array? The solution looks like this:

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
 
/* compile with gcc -o test2 -fopenmp test2.c */
 
int main(int argc, char** argv)
{
    int i = 0;
    int size = 20;
    int* a = (int*) calloc(size, sizeof(int));
    int* b = (int*) calloc(size, sizeof(int));
    int* c;
 
    for ( i = 0; i < size; i++ )
    {
        a[i] = i;
        b[i] = size-i;
        printf("[BEFORE] At %d: a=%d, b=%d\n", i, a[i], b[i]);
    }
 
    #pragma omp parallel shared(a,b) private(c,i)
    {
        c = (int*) calloc(3, sizeof(int));
 
        #pragma omp for
        for ( i = 0; i < size; i++ )
        {
            c[0] = 5*a[i];
            c[1] = 2*b[i];
            c[2] = -2*i;
            a[i] = c[0]+c[1]+c[2];
 
            c[0] = 4*a[i];
            c[1] = -1*b[i];
            c[2] = i;
            b[i] = c[0]+c[1]+c[2];
        }
 
        free(c);
    }
 
    for ( i = 0; i < size; i++ )
    {
        printf("[AFTER] At %d: a=%d, b=%d\n", i, a[i], b[i]);
    }
}

How does this work? Well, we allocate the dynamically-sized array inside, not outside, the parallel region. Anything else won’t work, because OpenMP demands parallel jobs look identical (obviously) and needs to be able to deduce variable size at compile time.

Digital “Rights” Management

March 1st, 2010

I’m writing this having just watched a news article on the “Alice in Wonderland” vs “Cinemas” issue – namely that Disney wants to release the DVD within 12 weeks of the film’s release, rather than 17, to avoid pirates. I am of course reminded of growing concerns in the music industry since they shut down Napster in 2000 and finally, Google versus Mr Murdoch in the battle for free newspaper content.

So, I’m going to dissect the failure of digital rights management and the lack of understanding these companies seem to have.

Firstly, free. I think, given a choice, most people would want something for nothing and this instinct is driving half the problems here. When you can get something for nothing, why wouldn’t you?

Clearly, there needs to be some form of remuneration for the content creators, however. I license things I produce on this website for free because mostly, they’re pretty much just small bits of information. Unless I’m going to get something out of it for free, in the case of open source, I damn well want to be paid for my ability to code. So do musicians, actors, journalists, etc. I think, however, the industry is changing its theatre of operation and really hasn’t woken up to that fact. It isn’t that content is worse, but, content is now much easier to distribute. Production executives see this as their right to charge the same and make even more profit, but you just can’t do that. Content being easier to distribute should be cheaper for the customer, period. You rely on economies of scale to correct the short term loss in profit – more distribution gives you more sales, eventually more profit. Such was the way in the past, so it is now if only said directors would wake up and smell the coffee. 79p to download a single track for an album is too much, regardless of the quality of encoding. 50p would be more realistic and 25p would probably eliminate pirates entirely. Similarly, albums. Why charge £8.99 for an album? At 10 tracks, I make that £90p per track, which is extortionate. £4 would be a good price for an album. Likewise, DVDs. I will buy a DVD that costs £3 in the shops even if I consider it of marginal interest to me – why? It’s so cheap. I’ll think twice about spending £10 though. £10 for 1 hour 30 minutes of entertainment? Again, too much.

However, the real failure in the fight against privacy was the introduction of DRM. Not only does DRM control on which platforms content can be watched, it also controls how many copies can be made to mobile devices. Often, phoning home occurs. This is very much a case of assuming everyone is a criminal and checking up on their every activity. Psychologically, I don’t think customers ever appreciated this kind of control. Nobody wants to be told how many times they can copy the track they paid for to their mp3 player. What happens if, given a limit of 5 times, the user loses two mp3 players and writes 2 cds, one for mr’s car, one for mrs’s car. Is that not a valid use, or should the user pay twice, once for each CD they wish to burn? If you thought users resented prices you can bet they resent the idea they should pay twice for exactly the same thing.

Not only that, but technologically copy protection was poorly implemented, often leaving the user without access to their content. DRM-compatible hardware such as Hi-Definition HDMI output on Vista is an alliance of large corporates with a vested interest in maintaining profit margins against the will of the consumer. Who is going to buy into such an ecosystem, seriously?

Then, there’s the newspapers’ sudden realisation that given a choice between a paper copy of yesterday’s news for £1 or today’s news for nothing, most people gravitate towards the latter.

What I think everyone has missed is that the field is changing, massively.

Le Monde, a well respected French newspaper, has since I can remember operated an interesting pricing model. Their current news in most areas is available online for free. However, if you wish to access archived content, or certain types of content, you have to pay. There are additional benefits to becoming a subscriber, too. For example, a PDF version of the newspaper is emailed to you / available online. You don’t just have to take out a life subscription either; there is the usual granular access.

I don’t think that’s a bad idea at all. Another interesting model is one used on StackOverflow. The idea of community sounds very communist, until you look at how it works. Users are up-voted for posts other users deem excellent and the sum of these up-votes is your reputation (each upvote gives you 10 “points”). The more reputation you gather, the more you can do with the site, such as reduced advertising, commenting, voting down and eventually access to the moderation tools. That to me, seems more of a capitalist idea – you get out what you put in. I wonder if there’s a way to adapt that sort of model to perhaps newspapers or film. You don’t have to pay to use StackOverflow, but you can create a free CV with it and pay to have that filed for searching…

As someone with an eye condition that means I can’t see in 3D, I have no interest in the rise of 3D cinema, or more likely, the momentary fad of 3D cinema. However, it isn’t a bad idea. I’m sure, beyond plastic toy giveaways, there’s a lot can be done to increase the experience and benefit of going to the cinema versus watching a dodgy copy off the net. Price will be another factor here – you’re competing with free. Of course, commercial companies must also consider this idea sent to me via Brain Detour.

Finally, music has such an obvious “this experience is better if you pay” exploitation route it almost hurts: live music. Ok, so it’d kill off a few rapping artists and the general bling bling duo of: female artist: you’re such a bad boy, I still want to **** and the male artist: in da club, yeah, treat you rite, no sexin with any of dem ova girls and all that bollocks that somehow passes for music and encourages teenagers to act like they’re in Fast & Furious, but y’know, we can probably cope and it wouldn’t be such a bad thing, really. If you haven’t noticed, youtube is littered with live music videos, 90% of which were filmed with home video cameras, or worse mobile phones, in what looks like an earthquake. What I’m trying to get at is without considerable talent it is pretty hard to pirate a live music experience, decent artists are usually worth paying for and people all around have a good time. So, so what if you have to charge less for CDs. Run more live gigs. Really.

And as for software, well, unless it’s a specialist piece of kit, there’s an open source app for that (sorry Apple).

Mind Games

February 27th, 2010

Time to play mind games again this evening.

Mind games are what I call needing to survive “the big crash”, which is the moment it all goes downhill mood-wise. The big crash can also be preceded by “the little downhill” slide, where my mood gets progressively worse until I actually hit the big crash, and there is of course “the little crash that might be an indicator a big crash is coming”.

Roughly speaking, a big crash I know about. It generally involves getting exceptionally upset, generally hating everything, being frustrated with everything, feeling like “there’s no way out” and “it’s all gone wrong”. It’s the little crash or the slide I tend to not know about: feeling down, or inadequate. Under-rating myself. Not wanting to do or not having the confidence to do something. I’m generally always on the border of this sort of area – what we call “bad thoughts” constantly creep in, but sometimes they get more intense. Noticing the bad thoughts sometimes happens, sometimes not, and when it goesn’t we get the little crash or the slide. When that happens, well, it might all pass, or it might not, in which case somewhere along the way we have the big crash.

We’ve already described the big crash, so let’s go with another short description: pre-lude, inconsolable, better, biscuit consumption phase, recovery. Biscuit consumption phrase is exactly what it sounds like and is optional, although roughly speaking I find consuming my own body weight (not literally, 400g will do) in chocolate digestives usually helps.

So those are some of the pit falls I have to avoid on the daily jaunt that is life. The others are “being late somewhere” which I think I’ve fixed now, and “I don’t want to feeling”, which is still a work in progress.

Mind Games is the name that came to mind when I tried to think how I’d explain the process I go through for “survival” of these events. I’ll come back to “survival” in a minute. The next few paragraphs will cover my means of “survival”.

The anti-panic attack technique has become a reflex. I get somewhere, I feel sick. Then I go through a process: am I actually likely to be ill, or is this a panic attack? Most likely, it is the latter as I’m rarely physically ill. OK, so, what’s the problem? I am in a meeting room, or about to go into something I’m nervous about? Ok, well, if I wait long enough it’ll be over. If I breathe properly that tends to make me feel better about things anyway, so do some of that. Water? Helps, but isn’t a neessity. I’m not likely to be sick though. Repeat: not likely to be sick. Repeat ad nauseam (pun not intended) won’t be sick. With a massive success rate, this technique works very well. Which bit of it gets invoked first depends on the issue at hand.

The life is rubbish technique So I’m typically post big crash, or recognised little crash. Repeat all key successes from the past four years with respect to getting through (you can think of it as repeat the post “with animus” – that was written as part of this technique). Repeat again. Start listing things I am actually good at. Like programming. Like French. Like my academic record. Like anything that went well. Repeat and repeat again.

The language technique My Dad can claim most of these as his anyway, but this one can have his name on it if any of these get named. Unlikely, but you know. Language. I’ll write about it soon, it’s in my drafts. Words like “never”, “everything”. Everything’s gone wrong? What, everything? Last time I checked I’m still breathing ok, so that’s still working. This blog is still online. We haven’t yet all nuked each other. Cool. “Never”? I won’t, thankfully, live to see forever. Never kinda cheats chance, too. Last time I checked I’m not an oracle either, although I am a pretty good cook, or so I’d like to think. Take any phrase and look at the words. Change them to something less dramatic. CBT practitioners call this “de-catastrophising” which is nice of them, aint it. They’re right, though.

The sphere of influence Can’t remember who coined that phrase. Probably Dad again. Anyway, SOI comes down to “so, this big mighty issue, what can I do about it?” and the answer is usually “fuck all”. That’s not to say if you wanted to, you couldn’t given sufficient time and determination, but this is one of those “accept it and deal with the next one” ideas. Borrowing slightly from nihilism, I’ve recently translated this to “I’m still alive. If it kills me, I’ll be dead and I won’t give a shit.” This is of course making some gross assumptions about the afterlife but you get the general idea: seemingly devastating issue affects me – rationalise. Rationalise, that’s a CBT dude’s word again. That’s what it comes down to.

The carry on and it all goes away technique This works with mixed success. Not to be tried during exams, by the way, although it has actually been known to work. Basically, hijack brain with sufficiently complicated problems so it can’t think about the stupid ones. There’s a reason I brought Donald Knuth’s The Art of Computer Programming: Part II Seminumerical Algorithms recently…

Books, Exercise, Film technique. Because everyone’s allowed some escapism!

Anyway, there you go, some mind games I play, hopefully written with a twist of humour so it isn’t too dry reading. I’m off to watch some rubbish film about the end of the world and sit through it rationalising…

Two Months Post Facebook

February 26th, 2010

Well, at the start of this year I decided to try something new – delete my facebook account. No longer use facebook. Many reasons, not least because it’s a false way to manage friendships full of pictures of everyone “having a great time” out in clubs and all that nonsense, also known as being a “facebook whore”. Writing on people’s walls counts as getting in contact, usually “heyy how r u watz nu wt u?” and other abuses of the English language. Facebook has also suffered from the Eternal September syndrome of Usenet fame – the more users and features, the worse the site has become. Become a fan of “sleeping”, “If ya doo it ta me don’t freek out if a dooooo it bak”, “chocolate” etc. Fred has a new cow on farmville.

Not only that, but catching up with friends becomes reading status updates, amalgamating information and not actually talking to them. So, pining for the days when msn messenger was the new kid on the block, I dumped my account.

I don’t miss it a bit. I now do phone, IM, e-mail, meeting people. That’s it. I have proper IM catchups or e-mail conversations. When I want to. Not with the people I met once and will never talk to again. I don’t have to be part of the exhibitionism. Fantastic.

Rating oneself as a developer

February 26th, 2010

This comes from a recent question on StackOverflow: how do you rate yourself 1-10 as a developer, to which I gave the following suggestion:

  1. I know of it, a little bit of syntax and would be able to learn it, but to do most things I need a book.
  2. I can write stuff with the standard language features (i.e. basic console apps).
  3. I can write stuff including GUIs in this language.
  4. I can produce something functionably useable with this language including GUIs. I’ve used system APIs (C/C++ etc) or extensively the default runtime.
  5. I have started to use non-standard APIs with the system, such as Eclipse RCP etc. I still need books to use these, but I can do it.
  6. I know at least one non-standard API pretty well and have a basic understanding of the inner workings of the language i.e. compilation, what rt.jar is etc. Or, I’ve written an API in the language that is being used by my team / company (not just yourself…).
  7. I know a fair few non standard APIs pretty well, without the need for frequent book access.
  8. I know a lot of non-standard APIs pretty well. I can also integrate this language with others and have used it on multiple platforms for large projects in different settings.
  9. I’ve done something with the actual language development itself.
  10. I’ve written books on it and am considered an industry expert. I might even be consulted if LANGUAGE 2.0 were to be written.
  11. I wrote it.

Clearly, these points are cumulative and by usable I mean more than just “I re-wrote notepad”, I mean useful. What do you think? By my own admission that puts my highest skill level at a 6. I still think it’s valid though.

64-bit rip off

February 25th, 2010

Is it me, or do you see lots of stickers in computer shops extolling the fact that their laptops are 64-bit capable? Well, the processors definitely are, but in order to take advantage of the extra speed increase that is supposed to give you, you need a 64-bit operating system and 64-bit applications. Surprise surprise, most of the operating systems on these laptops remain 32-bit. Also, lots of vendors are still distributing 32-bit only apps. Why?

Basically, there are a lot of people out there not getting the full power they’ve paid for and a fair few developers like me who wish everything’d move to 64-bit, please. That said, I doubt most users with VT-capable Intel chips are using that functionality… Lucky for me also that the Linux ecosystem went fully 64-bit years ago.

We need to move fully 64-bit. It is far past time we did.

VirtualBox

February 24th, 2010

Well, I decided based on most of what I answer on Stack Overflow that leaving my Windows skills behind entirely might not be a good idea. Occasionally, after all, one needs to port, or remember how to do something. Visual Studio is a pretty good tool and since I have a license it seems a shame not to have it installed. Anyway, what with this whole insomnia thing going on at the moment I got fed up the other night and thought hell, might as well do something useful. So, I created a vm in VirtualBox (because it’s free, unlike VMware), set it up with Office and Visual Studio, let it do windows update then disconnected it again and voila, I has a Windows Development Environment. If it gets into issues, I’ll just roll back the virtual hard disk. Genius. Thanks to Intel-VT it’s pretty much like running Windows on the hardware itself, if not slightly faster, cause all the stuff I need to do my thing isn’t installed, just the necessities. Inspired by a setup I have at work for developing on Linux.