Red Gate Coder interviews: Peter Cowan


Having just finished a Computer Science degree at Cambridge University, Peter is spending this summer being an intern here at Red Gate. We chatted about his relationship with PHP and C#, whether the Raspberry Pi will inspire a new generation of computer scientists, and what the future holds for programmers.

How did you get interested in computing?

Back in the day when he was a consultant surgeon, my dad had a 486 PC. Instead of having a laptop, he would pack up his PC and bring it home, and I was just fascinated with this shiny box that he’d pull out. I’d just sit with him, watch him work, doing this boring, mundane stuff. He’d be typing things up on Word, but I’d be fascinated with how it worked. I was with him when he’d upgrade the PC, he’d take it apart, install Windows 95 on it, and he taught me as we went along. It wasn’t too long before I started progressing beyond him, and I was the one teaching him. He’s the one who taught me to build my first PC from scratch, and that was when I started saying “This is my thing now, I’m going to go with it”, and embracing it utterly.

How did you get started with programming?

I got started with programming the way that I imagine most people did, with the web. The Internet was first really made known to me from an early age, when I was about seven or so. My first introduction to what you could call programming would be HTML, and then the natural progression was JavaScript, getting the pages to do something. Then I got interesting in Flash and dabbled around with a little bit of ActionScript. A little later, I got interested in PHP, which was also my first introduction to Linux, and I started messing around with open-source stuff. It was only really in university where I got proper programming training, if you like, actually learnt Java, imperative programming language concepts, object-orientated programming language concepts, and that was when I started tackling proper, meatier projects, instead of little toy projects that I used to write in VB, which would just manipulate variables.

You mentioned the first programming language you learnt was PHP. Was there a first big project you did with it?

Back in Sixth Form, and a little bit earlier than that, one of my friends saw social networking was really cool, and thought, “Hey, why not make my own social network, that’s going to go down well, right?”, so I thought “Oh well, may as well jump on board with it, looks like fun”. So my first real project was extending an application called Dolphin from BoonEx, which was a social networking application, and it would interface with its APIs and extend it to do exactly what we wanted from it. I also worked on MediaWiki to produce wikis for my school, which I thought was a really good idea at the time, but no-one used it, which is the way with most projects in school. At University, I started working with bigger projects, such as Drupal content management systems for student union websites. And I’m currently in the middle of overhauling our May Ball ticketing system, which is written entirely in PHP. My weekend was full of PHP, it is a filthy language, I despise it but love it at the same time. PHP is the first language I’ve ever really played with, and I have a little soft spot for it even though it’s filth.

So it’s a love-hate relationship with PHP?

Most definitely!

What’s the love and what’s the hate?

I hate the fact that it’s so badly typed, I hate that a function can return any data type. There is no strict typing in it at all. If it’s a badly written API, then you have to have your own handling and error checks when you use it. I really don’t like the fact that its syntax is similar to other languages yet very different. So, string concatenation doesn’t use a plus, it uses a dot, and now you can’t use a dot for object-orientated stuff, you have to use an arrow. It’s just little niggles, but it doesn’t conform to a schema.

We’ve got C at one end, which has really simple functions, and you can go really fine-grained with memory management. Then you can go all the way to C#, which is totally managed code, with vast APIs and a vast library of objects. Then I plant PHP right in the middle. But that’s not a good thing. It’s simple, but it doesn’t have a vast library of objects. It has a polluted namespace, and you can do comparatively little with it compared to more advanced programming languages. It’s just a bit dirty. What I do like about it is that it’s comparatively easy to pick up. It’s easy to get things done in it quickly, and it’s so common in the wild. You can drop a PHP file into a reasonably fresh Ubuntu installation, and it will run.

I think one of the nice things about PHP is that if you’re someone who already knows HTML, then there’s a very nice learning curve. If you want to display this year’s date on a copyright notice, you just change the extension to PHP, and copy and paste in a little fragment you found off the Internet.

Yes, that’s very true, I do like that. I’m sure there are a lot of things about it that I really like, I just can’t pinpoint them right now. I have a lot of hate for it after this last weekend.

So you mentioned the fact that it has no static typing – you call a function, and you don’t know what it’s going to return. Does that hate extend to other dynamically-typed languages as well?

Python is also dynamically typed, but Python’s lovely. I’ve not done that much with it, but things just worked, and its objects were actually decent. I felt you could do a lot more with them. I don’t loathe Python as much as I loathe PHP in that respect.

So you don’t have a problem in Python with not knowing the return type of a function?

I think so. I think in Python, the code’s more obvious. Python will actually break if you try to do something wrong, whereas PHP will fail silently. One of my biggest bugbears with PHP is the fact that I can try and reference a variable that hasn’t been defined, and it will still run the script. That’s the source of most of my bugs. If I’ve made a slight little typo, it’ll take me ages to trace it.

You mentioned when you were taught “proper” object-orientated concepts at university. When I was at university, I never felt as if I was learning that much about how to program.

I think it’s a way of looking at things. They didn’t teach you to program properly for an industry environment. Coding practice isn’t taught, and they definitely don’t teach you about useful things like version control and stuff like that. But I tried to understand concepts of object-orientated programming for a long time, just on the internet, and it just wasn’t going in. When I took a lecture with some explanations and some examples, it all suddenly fell into place and clicked. I think university gave me a basic but very crucial understanding of these concepts, and I’ve built on it from there through work experience.

What was you first job writing code?

My first job writing code was last year in an internship in Oxford at a place called CoreFiling. I was working on their web applications, which are financial reporting software. I learnt about GWT, servlets, and loads of really cool Java features.

Was CoreFiling the first time you’d worked in a team of developers?

We did a university group project where we produced a product – we produced a Red Gate Twitter dashboard – so that was my first experience of real teamwork. It was a really fantastic experience, because it taught you responsibility. I find if you’re working on a project on your own, there is a tendency to say, “Well, I can just slack off here, I’ll take a break”, but when I actually have people relying on me for deliverables, the responsibility is pushing me to actually get things done. I really enjoyed that. After that, CoreFiling was the first time that I’ve worked in a team in industry.

How did you find working with colleagues who were presumably a lot more experienced than you?

It can sometimes feel a bit awkward, especially when you’re struggling. When they’ve tried to explain a concept to you and said “Go away and apply this”, and you’re still not entirely sure, it can often be quite awkward, and feels slightly embarrassing when you have to ask, “Could I have some help here?”. They then turn around and say a few words, and it’s suddenly so obvious. Maybe you think “If I’d take a bit of time to step back, and maybe dig a little further, read a little more, then I wouldn’t have had to ask”. But having said that, it was really good to have people there supporting you, and learning and teaching on the way.

You mentioned a couple of your side projects. Did you have any particular that you’re working on?

I’m really interested in the Raspberry Pi, mine arrived recently. I had a list of possible projects from one of the guys who’s running the Raspberry Pi project, so I’m hopefully going to investigate them, do something with them.

How much do you believe in the vision of the Raspberry Pi? Do you think it could be this generation’s BBC Basic?

I do. But I’ve heard a lot of pessimism, which is enough to make me question it. But I do firmly believe, when done in the right way, it is this generation’s BBC Basic. I came from a generation where developing for computers was incredibly accessible. There was no need to download massive SDKs, there was no need for the massive API documentation that you have these days, you could just get in there and do it. But nowadays, children are good with computers, they know how to use their iPods and iPhones, but with the platforms they’re using, they have no desire to go out and make their own things. Even if they do, they’re met with so much red tape which is very difficult to get past. You have to get past licensing things, or you have to get into these app stores, and you need all these SDKs which are just a bit of a maze, which some people just don’t want to traverse. I think the Raspberry Pi presents a relatively open platform where it’s quite easy to say “I’m going to hammer something out and it’s going to work”. I really hope that, coupled with the new computing curriculum they’re hopefully putting in for GCSES and A-Levels, it will make a difference and Computer Science will be taken seriously in schools, and that we get a generation of people interested in computing. That would be perfect! Will it happen? I don’t know. I hope it will, but we’ll see.

Do you feel as if the web filled the gap between the BBC Basic and the Raspberry Pi?

Yes, I think a lot of people would have started using web tech as an introduction into programming. And since it is so open, and since these technologies are so freely available, it’s not difficult to get involved in that. Working here [at Red Gate], I’ve realised just how rich and powerful web technologies are. I think there’s definitely a future for applications moving away from the desktop environment to being web-based. It’s definitely the way forward, and I think that you’re right that the web has filled that role. But it also provided an abstraction layer away from developing on the device itself. Producing, say, operating systems, or applications to run on the device itself. With the Raspberry Pi, you can write what hosts the web technologies. So, yes, I think the web did fill a void, but I think the Raspberry Pi will attract people to do things that are lower-level. I think it’s particularly exciting that I can, with relative ease, go out and write assembly code for the Raspberry, and make your own operating system if you desire.

You said that you hacked on some existing projects like MediaWiki. When you’re presented with a new codebase that you’ve never seen before, how do you begin to understand how it works?

When I’m given a desktop application, I start from the main function, and work from there. I take a bit of a “Bull in a china shop approach”, especially with web technologies, like MediaWiki or Drupal. I’ll just dive in and see what works, where it’s commented, see if I can understand the flow of control, and what the modules do. I don’t really have an approach that works. I’ve not worked on enough projects to find an approach that works for me.

As a developer of a codebase that you might work on, what can I do to make life as easy as possible for you?

Comment, not to excess, but just make sure that if there’s something smart that you think you’ve done, if you’ve written a really clever method, but it might be a bit obscure for people, make sure you comment it and explain why it does what it does, why it’s so clever. Making methods and fields and variables as clear as possible, make it clear what they represent, so that someone coming along doesn’t have to dig around with almost obfuscated code to work out what goes where. I’ve been in the really privileged position of getting hold of a codebase, and it’s been written well, it’s very easy to work out how it does things. We’ve got clear interfaces, and clear implementations of these interfaces. It also uses dependency injection, which, whilst it took some time to understand in the first place, makes a lot of sense, and you can see why things do what they do. Just make sure that things are obvious. If you think you’re being smart, chances are, someone else might not be as smart, and I’d like you to tell me exactly what you’re doing, why it’s so smart, why it works.

Do you think you write your code in a particular style?

Yeah, badly, I think! The way I write code is entirely dependent on what I’ve been given with the codebase. If I’m starting my own project, then I really like to have schemas to work with, or layouts that I know work. When I’m on my own, I’ll try to look back on projects that I’ve worked on before, and see how have they laid out their folder structure, how have they laid out their class structure, and try to replicate something like that. If I’m working on an existing codebase, then of course I’ll go along with the way they’ve done things. I like to look at an example where I’ve looked at the code and said “I understand what that’s doing, that’s a really good way of doing things”, and emulate that as best I can. But I still haven’t found the “right” way of doing things.

How do you make the trade-off between perfect code and quick-and-dirty code?

I’ll write out code that gets the job done in the way that I think is most obvious, check the results, and then step back and say “Okay, what have I done here, can I clean up these variables, can I push things into constants, can I pull things out into methods”. Currently, with the May Ball ticketing codebase, I’m going through it, cleaning up the HTML, and once that’s done, I’m going to take a step back, and say, this code corresponds to one page, and pull that out into a method, and get rid of redundant and duplicated code. My approach is get things done, then step back, and improve things. Assuming I have the time. And usually I don’t have the time, so that slips a bit. But thankfully I’m not selling any of my projects!

Do you wish you did have the time?

Yeah, I think so, I think you have to take pride in your work. I’ve seen some truly horrific code that I’ve written, and I’m very ashamed. I want to come back in six months’ time and say “That’s really well written”, or “I fully understand why that’s doing what it’s doing” instead of having to try and work out what was going through my mind at that time. So, more time would be good, so I can put in my good coding practices that I’ve preached about but haven’t really practised.

Do you think it would have helped if you’d shrunk that process down, so that rather than writing the entire application and then improving it, you wrote one smaller part, and improved that?

Most definitely. But the projects I’ve been working on, because of our time constraints, because of the fact that I’ve got existing code there, that practice doesn’t always lend itself. In an ideal world, yes, that’s exactly what I’d want to do.

You’ve mentioned some of the reasons why PHP drives you to hate. Is there a language that has the opposite effect?

C#. Last night, I was in e-mail conversation with a friend from university. She’s a computer scientist, but not really a programmer, but it was clear how much I love C#. I dedicated half of my e-mail to her saying, “I’m working with Red Gate, I’m working with C#, this stuff’s amazing!” I compared it to Java, how its syntax is similar, but there are certain things in C# which are just beautiful. I really, really love the language. I love properties in C#: instead of having to use explicit getters and setters methods, as you would in Java, using it as a property is fantastic. I think that’s really, really elegant. I also really like its delegates, and the fact that it does lambda expressions. I think that’s beautiful as well. Any desktop application project I do in the future, or any web-based project that might use IIS, there’s no question that I’d be using C#. None at all.

Comparing Java to C#, is it just the lambdas and the properties?

I like that it has WinForms, if you wanted to knock together a quick-and-dirty interface. It also has WPF, so you can do interfaces with comparative ease, whereas I found Swing in Java very difficult to use. I think that’s one of the key differences. C# just goes a little bit beyond what Java does, and even though I’ve probably only scratched the surface, I think it’s fantastic!

If you could go back a few years when you first starting to program, what would be the one thing you would say to yourself?

I don’t think I’d have changed the way I learnt programming. I could have tried to do projects in C# or Java, and they’d take me probably twice as long as they would now because I wouldn’t have had a good understanding of object-orientation, and code practice was pretty non-existent to me then. But if I was to go back, I’d say “Learn good coding practices, learn object-orientated programming properly, and then maybe you’ll have a headstart”. I’m not particularly unhappy about the way my coding life has been, because I’m exactly where I want to be right now.

How would you summarise the essence of programming, beyond just the mechanics of programming?

To me, programming is limited by your own imagination. You can do more or less everything. If you have an idea, then there is enough support out there with libraries, projects, and people that you can go and hammer out code. It’s the joy of being able to just build something. If you have an idea, unless it’s something like solving the halting problem, then you can realise it in code, and you can actually produce something from it. The limit is more or less your imagination with code.

Looking forward ten years, how do you think you see programming changing?

I think programming is going to be shaped by the wider computing field. At the moment, I see the cloud is going to be a big thing, I think the social networking boom is possibly on the way out. I think there’s going to be a lot of shifts towards paradigms that deal with that, and make things particularly easy to get things done in the cloud computing world. I think we’re steering away from the concept of ownership of a device, but more ownership of an identity which you can apply to any device, so I think programming will shift towards supporting that architecture very much.

I guess we’ve also got to see what happens with Microsoft’s new UIs, and whether Windows 8 belly-flops as most people predict. I think there will be a lot of paradigm shifts to developing Metro-style apps, at least in the Windows world.

Otherwise, are there any really cool technologies at the moment that I think is going to be adopted? People seem to think Scala is really cool, I guess maybe we’ll see more of that. I think functional programming languages are becoming cooler, and I think they might find more of a place in industry, or people’s hearts when they do their own projects.

If there was one problem or idea in programming that you could solve or work on, what would it be?

Not so much a programming problem, but I think the problem that I’d like to solve in computing is getting more people interested in it. Making people aware of just how important and valuable a skill computing is. My plan for the future is, with luck, if I work hard enough, to get back into a Master’s degree. But if not, I think education would be really, really valuable, and I think, because there’s a shift now in the curriculum to actually do proper computing at A-Level and GCSE, I’d quite like to be one of those teachers that gets young children interested in computing and realising that it’s an important thing to learn. I think that’s the biggest problem I’d want to solve, getting people back into computer science, and actually understand it’s useful. That’s what I’d like to solve.

More Red Gater Coder interviews