Django: First impressions from a non-web developer

I write in Java and I don’t do “web stuff”. If you haven’t left already, you might be wondering what a non-web developer is doing looking at Django? I’m hardly their target audience and yet somehow they may have scored a convert.

I got wind of its existence from a talk Leah Culver gave at CUSEC 2009 and realized it could be suitable for a problem I was facing with a project at school. We needed to develop a web frontend, mostly as proof of concept, for a database-backed system we’ve been developing but had been dragging our heels about doing soon. Between the three members of the group, none of us had much experience outside of PHP and we certainly had more important aspects of our system to focus on. The trouble was that without a web frontend, it was going to be difficult to demo our system to our project supervisors. Enter Django.

I’m a self professed “non-web guy”. I don’t know much about “web stuff” (and the use of the term “web stuff” should be telling on its own). To give you some perspective: I hacked a bit with perl and cgi at the start of my undergrad in a fit of boredom at a desk job and the last time I made a website was when frames were in style. So I figured diving into Django should be a good test of how it streamlines the little things for web developers. Thankfully Python is not foreign to me, though my mindset is still partway between Java and C# and thus writing Good Python is still a conscious effort.

After following the tutorial, I had gotten a taste for some of the neat features Django had to offer. I was particularly interested in the object-relational mapping, bullet point #1 on Django’s front page, as this had been a sore point for our project’s development. Paired with the flexible, shiny and virtually automatic admin interface, the solution we sought was staring us in the face.  The problem is that we had our model defined in Java and re-doing it in Python, while quite straightforward, was not an option due to time and project commitments.

Slightly dejected, since Django’s admin interface would be sufficient for our demoing needs, I stumbled across Django’s instructions for integrating with existing databases. Jackpot.

First bump: the MySQLdb module doesn’t work with Python >2.5. Alright, no biggie. After that, the

python manage.py inspectdb 

command went swimmingly. What followed was series of re-arrangements to the models.py file that was generated in order to get the dependencies in line (the table models are simply output alphabetically). A bit tedious, but a breeze compared to some alternatives.

Running the server with the new model was initially unsuccessful. Validation was failing on a field accessor “clashing” with a related field and instructed me to add a “related_name” for the definition. Looking it up in the docs revealed its intended use for when a table needs to reference itself. This, however, wasn’t the case in my model. We simply had two references from TableA to TableB. A little further searching revealed that the prescribed remedy, giving each field a different related_name, was indeed the correct one. I don’t completely understand how this is not a bug, though perhaps there’s simply a default value for related_name (in which case I understand how the clash occurs and why it’s invalid).

The next problem was… actually there was no next problem. It’s working. I can barely believe it. I’m sure part of it is being so ridiculously out of sync with the web development world that even mundane features would impress me, but I’m impressed. A minor version requirement (for a third-party db adaptor) and some fiddling with a generated file and that was it.

I’m off to play with Django admin options to get wrestle the forms into something a bit more useable, but it’s all gravy from here.

Yes, there are alternatives, some of which might be better for what I’m doing (maybe in every way too). But that’s not the point. Django has lowered the barrier for entry to enable clueless folk like myself to create some cool and useful things. And that’s really the important thing – it’s gotten me to step into the web development realm to see what’s possible. Rails, for all its hype, can’t even claim that (for me).

Advertisements

XNA: Makes Games Programming Easier, Not Easy.

This is in response to the article over at TechRadar.com entitled “How to code games for the PC and Xbox 360” by Paul Hudson (published in PC Format magazine). I’m all for the promotion of the XNA framework but TechRadar’s take on this is completely out of touch with reality. I’m still not convinced it’s not being intentionally sensational (the sub-heading does make a claim of “unlimited riches”) but since the article does seem to go into genuine detail, I’m going to give a genuine response.

To sum it up, the article claims that games programming is suddenly easy thanks to XNA and anybody who tells you otherwise, including those in industry, is a lying idiot. Now maybe you think I’m being sensational here, but in TechRadar’s own words:

We get asked this question a lot: “What’s the best way to start programming?” Some people like to buy books. Some people like to get a computer games programming degree. But they are – and we don’t want to put too fine a point on this – stupid.

The article goes on to say how you can make anything in XNA, mentioning Halo 3 as an example, and have it work on the 360 to boot.

What gets me is the author clearly has done a least a little cursory research in preparing this. He mentions the Xbox 360 having a “curious superset of shader model 3.0”. They don’t print that on the front page of creators.xna.com, so either the author actually does have some experience developing with XNA or else they’ve picked out some choice phrases from someone else who has the experience and is no doubt weeping softly in a corner after reading the resulting article.

Other infuriating excerpts:

[…] we’re not going to explain to you what every line of code does, because, quite frankly, it’s irrelevant.

Don’t worry about debugging for now – a wise man once said that debugging is harder than coding, so if you write your code as cleverly as you possibly can, then you are – by definition – not smart enough to debug it.

The rest of the article goes on to explain how the sample “tutorial” project works, though it’s glossed over to the point where it’s not worth reading. There are so many other better resources out there for learning the basics of XNA, including ziggyware.com and the creators.xna.com website itself (and its forums).

So the article isn’t very helpful; what’s the big deal? There are three main problems:

1. It misrepresents games programming

Contrary to the article, games programming isn’t about stealing code from others, ignoring the debugger, and making the next Halo. It really is as hard as people say to make a AAA game, even with massive budgets and large teams. Comparing the ease of drawing a few sprites on screen with developing a modern real-time engine is a disservice to the industry.

2. It fails to promote XNA properly

How you can have an article devoted to XNA development and completely fail to mention the XNA community at creators.xna.com is baffling. I’ve mentioned it three times already. The article doesn’t even provide any sources of follow-up information for budding developers. The days of developing in a vacuum are long gone. If the intention is to “sell” XNA to readers, why not show them where to get more tutorials, projects, documentation, and community help?

3. It misrepresents XNA

XNA’s great. I love it. But it won’t make a game for you, nor should it. You can’t make a decent game without understanding how to code, nor would you be able to get it onto the Marketplace thanks to peer review. XNA is only a framework and as such, it can’t possibly have everything a budding game designer might want. Texture loading? Sure. Skeletal animation? Not so much.

I can look past the half-hearted jabs at the games industry, forgive the useless tutorial and the lack of any pointers to helpful resources. But I can’t look past encouraging enthusiastic newcomers to ignore learning how to code and making wild claims about the capabilities and ease of the XNA framework. That sort of advice is what sends kids (and adults) off to try it out only to get frustrated and give up once they hit their first roadblock. It can turn them off programming, much less game development, for years, if not forever. Teach them how to do things properly and give them access to they help they need (and they will need it).

Sorry lads. Games programming has gotten easier, but it ain’t easy.

Skate2: Go Get It!

Skate 2 shipped last week for PS3 and Xbox 360 and so far, it’s been received pretty damn well. I feel some attachment to it since I helped make it and consequently it’s the first game I’ve ever had my name associated with in some way. If you haven’t already, go check out the demo on PSN / Marketplace and try out some of the new features (or just try the mechanics in general if, heaven forbid, you never played the skate.).

For a quick look at what Skate 2 can do, check out this video on Youtube (click High Quality). It’s impressively technical and also pushes the boundaries of the whole ‘movable object’ thing. Cool stuff.

Gamespot has a pretty concise and level-headed review that’s worth watching too.

And if skateboarding isn’t your thing, there’s plenty else going on in Skate 2:

Vodpod videos no longer available.

Rumour has it that I opened a shop in San Van. Can you find it?

moved (here)

Switched wordpress domains to benkane.wordpress.com (you’re already here). Carry on.

CUSEC 2009

I spent this past weekend in Montreal attending CUSEC 2009. Aside from being in Montreal and ridiculously affordable, it was also a great conference – well-run with a lot of great speakers. I had previously attended CUSEC in 2007 and found it to be hugely motivating – so much so that I had moved to Vancouver for a co-op job by the time CUSEC 2008 rolled around and thus skipped a year. This year’s conference had that effect once more.

CUSEC features a collection of speakers from the corporate and academic world, as well as keynotes known for their research, accomplishments or just plain awesomeness. This year’s list was no slouch, featuring some very entertaining talks, some cool tech demos and even Richard Stallman.

The conference opened with a keynote by Leah Culver, one of the founders of (the now-defunct) pownce.com. While it might seem to send the wrong message with pownce having closed down just last month, it was pretty clear that Leah and the rest of the crew had moved on to greener pastures at SixApart. We actually missed the very beginning of Leah’s talk but for what we saw, she described the life of a sucessful software engineering in a lively and motivating way. Success doesn’t necessarily equate to money and I think she made it clear that you can be successful doing what you love, if you keep your eyes open, head up and just keep coding for fun.

The next keynote was Dan Ingalls, who demoed the Lively Kernel. The abstract claimed “an entire computing environment can be built from scratch entirely in JavaScript”, something we found somewhat curious and borderline laughable. One theme that ran through the entire conference was that JavaScript was on its way back in thanks to the advent of more powerful engines. The Lively Kernel ended up being pretty interesting, if not convincingly useful beyond an educational tool. It definitely impressed with its live code editing and universal treatment of GUI objects. I was particularly surprised that it managed to “run” on my iPod touch (though only conceptually; it was unusable). The coolest part? You can go try it right now.

The Lively Kernel

The next day brought Avi Bryant who delivered “Good Hackers Copy, Great Hackers Steal”. Aside from talking about the resurgence of SmallTalk, including his web framework built using it (called SeaSide), Avi’s main point was about ‘stealing’ research from papers that haven’t been tapped for their end user potential. It was a pretty inspiring talk about the benefits to actually knuckling down and doing some research when faced with a problem. He also demoed a few things, including a small web app that would apply a theme to a page based on a pallette pulled from a logo you provide. In his words, “I really enjoy taking really simple little features and overdoing them.”.

Next up was Giles Bowkett. Giles had a MIDI generator written in Ruby to demo, which was actually pretty sweet and I don’t think the crowd gave him enough credit for it. Music generation is on my list of things to tinker with. Aside from that, Giles didn’t so much have a message to share or an opinion to express so much as he had an entertaining story to tell. I liked it, and the crowd liked it, and it was motivating if nothing else.

Following  Giles was Joey DeVilla, also known as the accordion guy. Joey is one hell of a storyteller. He’s a tech evangelist for Microsoft and he opened his talk by playing “Hit Me Baby One More Time” on his accordion, which alone should tell you he’s a pretty interesting guy. He reminded me of my calculus prof who told us nearly unbelievable stories of his youth during class, which always came as this huge juxtaposition to the subject at hand. Joey’s talk was excellent and the audience ate it up. He made an appearance later on by winning an auction to buy a stuffed gnu from Richard Stallman (see it unfold on his blog).

Joey DeVilla wins a stuffed gnu from Richard Stallman


I’ve stuck to just mentioning the keynotes so far, but the final day of the conference brought on Caitlin Kelleher, an academic speaker from Washington University. She spoke about Storytelling Alice, a programming environment aimed mainly at middle school girls. It can clumsily be described (by me) as a sort of 3D Sims-like machinma maker that focuses on scripting. The scripts are input with a GUI to enforce syntax but in doing so, they also expose students to programming concepts like functions, parameters and loops. I was pretty interested in the whole thing, partly because of the technology involved and partly because of the problem it’s attempting to address (namely, increasing enrollment in computer science from a broader group of people). Its effectiveness in studies is admirable. Yes, the Alice engine is no longer much to look at, but there is apparently a deal in the works to use Sims 2 characters for the next version. I have too many thoughts on the topic to explore them now – perhaps a future post.

Storytelling Alice

Storytelling Alice

The second-last keynote was Francis Hwang. This was another talk about engineering as a profession and how it related to other professional areas. It was different largely because of Francis’ take that software engineering was not at all like art, it didn’t have to be, and it doesn’t suffer for it. He was challenged on this but held his position quite well. A memorable line: “Q: How is a brain surgeon like an artist? A: Why would I want to be an artist? I’m a fucking brain surgeon!”. If nothing else, it seemed like people took from his talk that you should challenge things you disagree with.

Last of all was Richard Stallman. His talk was on “Copyright vs. Community in the Age of Computer Networks”. I’d write a synopsis, but Joey DeVilla has a virtual play-by-play on his blog of another time Stallman gave the speech. This is another topic that I could probably write a lot on, and one I don’t actually want to go near without due diligence and reading Stallman’s essays. You can probably guess that I don’t completely buy Stallman’s arguments. It was a very interesting talk nonetheless, in terms of content rather than delivery.

Phew! So that was CUSEC (well, the conference side of things anyway; Montreal itself breeds adventures). So what did I take away from all of this? Well, few more people to follow on blogs and twitter, and a renewed interest to look into web development that I have avoided up to now with the blanket statement “I don’t know web stuff“. I’m going to be looking into Django and Ruby to see what’s going there. Oh, and I’m going to blog about the things I find out and create. So really, the most valuable thing about CUSEC? Motivation.