PyKSD - Python bindings to LibKSD


Python is very powerful language whose main advantage is its absolute simpliticy. It was designed with a consistant image of what it should be from the ground up unlike certain other languages that weren't designed so well. Personally, I prefer Python to C++ for application design because it removes a lot of complication present in C++ developement. First of all, in C++ you have to write Makefiles and go through a build process everytime you make a change. Where as Python is interpretted so you just edit and run. Second, Python is more easily portable. I know from experience (as the author of libksd) that writting C++ that runs on multiple platforms and compilers is very difficult and time consuming.

PyKSD is glue that allows you to write python applications that can use the power of LibKSD. Currently, PyKSD isn't very far along. But the base it there. Just to show you how much easier it is to code in Python, here is a minimal demo that you find in the current PyKSD source tree.

#!/usr/bin/env python

from pyksd import PyApp
from pyksd import KSD_MAIN

class TestApp(PyApp):
	def __init__(self):
		PyApp.__init__(self)
	def Init(self):
		print "Init'ing ..."
		self.CreateScreen(320, 200)
	def Shutdown(self):
		print "Shutting down ..."

KSD_MAIN(TestApp)

Now, compare that with the same demo in C++:

#include <ksd/ksd.h>
#include <iostream>

using namespace ksd;
using namespace std;

class TestApp : public TApplication {
public:
	void Init() {
		cout << "Init'ing ..." << endl;
		CreateScreen(320, 200);
	}

	void Shutdown() {
		cout << "Shutting down ..." << endl;
	}
};

KSD_MAIN(TestApp);

The first thing you should notice is how close the code is between the two. This is intentional. Using PyKSD should provide a very similar experience to LibKSD. But the most important thing is how much shorter and simpler the Python version is. Not to mention that it is already to run on any PyKSD supported platform . The C++ code is useless until it has been compiled for the platform.

Downloads

Currently, there isn't an official PyKSD release, but you can get the code from the LibKSD CVS . Checkout module pyksd.