October, 2005


27
Oct 05

Programming Fonts

Still think Courier New is the best (only?) suitable font for programming? You might just be missing a trick, there are a whole bunch of freely available fonts out there designed specifically with programming in mind.

Rather than write up the whole lot myself, I’ll point you at an excellent write-up of several of the most popular by Jeff Atwood.

I’m currently using Dina (a derivative of Proggy ) for my development, and find it very clear and easy to read. I also often use Lucida Console and Typewriter as scalable alternatives.


17
Oct 05

Exposing Functions to Embedded Python

So far, instead of exposing functions to Python, we have (the reverse I guess) embedded the Python interpreter in our process using Boost::Python. So, running Python from within our process is all good and well but we want the Python code to interact with our C++ code as well.

We’ll add to the previous example:

const char* greet()
{
	return "Hello World from C++";
}

BOOST_PYTHON_MODULE(embed_test)
{
	def("greet", greet);
}

Here we have defined a python module embed_test which we will now expose to our embedded Python interpreter. The module has one function, “greet” in the Python module calls the C++ greet function.

Now we add to the main function:

if(PyImport_AppendInittab("embed_test", initembed_test) == -1)
		throw std::runtime_error("Failed to add test module to builtins");

The initembed_test reference is the function name generated by the BOOST_PYTHON_MODULE macro. Once we have made Python aware of this built-in module, we can modify the python code we run in the example to print out the result of the greet function:

handle<> ignored((PyRun_String(
	"import embed_test\n"
	"print embed_test.greet()"

	, Py_file_input
	, main_namespace.ptr()
	, main_namespace.ptr())
));

The techniques used here are all based around the basic functionality available in the Python C API. However, the Boost::Python library does make it easier to expose your own code to the Python interpreter. Next we’ll look at exposing classes and then move on to the use of SWIG.


17
Oct 05

Wordpress Naming

I wrote a while back about Wordpress using a similar naming scheme to that used for PN2 releases, there’s an excellent write-up of some of the release names chosen so far over on Ryan Boren’s blog.

Ever since the third release of PN 2 (2.0.3) PN releases have been named after my favorite jazz musicians. It started with coltrane (one of the candidates for the next wordpress release) for, obviously, the legend John Coltrane.

Next up was 0.4 with “miles” for Miles Davis, one of the best known and perhaps most accessible jazz artists. Wordpress has already been here! 0.5 ushered in the era of “mingus” – another wordpress release name. Ryan’s write-up of mingus is fantastic, every new bit of mingus I listen to provides something new – what an immense talent but less accessible than Davis.

Half way through the numerous 0.5 releases saw PN move from mingus to “herbie”. Herbie Hancock is one of my favorite jazz artists – a hugely influential modern jazz pianist. Head Hunters was a landmark album and both Chameleon and Watermelon man are pure jazz genius. Herbie Hancock was the artist that re-lit my interest in jazz and has had me looking back for old favorites and rediscovering the whole scene.

This brings us nicely to 0.6 and “ella”. I discussed Ella Fitzgerald in the release post for 0.6 and note that she has also been suggested as the name for the next wordpress release.

Coming up on the PN 2 roadmap are Count Basie, Dizzy Gillespie and Duke Ellington. More to come about them with the releases!

As for Wordpress, go for Thelonius Monk. I just bought a couple of Monk CDs to experiment and they are fantastic – 0.6 “Monk”.


13
Oct 05

And then there was video…

iPod Does Video


12
Oct 05

Hello World from Boost::Python

I just created a “Hello World” application in Boost::Python. I’m comparing the Boost and SWIG options for embedding Python and making PN code available to it so this is the first step for the Boost implementation.

Here’s the code:

#include <boost /python.hpp>

int main(int argc, char* argv[])
{
  Py_Initialize();

  object main_module((
    handle<>(borrowed(PyImport_AddModule("__main__")))
  ));

  object main_namespace = main_module.attr("__dict__");

  // Run some python!

  handle<> ignored((PyRun_String(

    "print \"Hello World from Python!\""

    , Py_file_input
    , main_namespace.ptr()
    , main_namespace.ptr())
  ));

  Py_Finalize();

  return 0;
}

Not very much code at all to get going! boost_python.dll (required to use Boost::Python) comes in at 180kb. The initial test app (as coded above) in Release configuration takes 40kb.

The differences between this and the SWIG embedding version will be minimal, boost doesn’t hide much of the embedding code for you. The real differences will be in creating wrappers for functions and classes. With boost I have to write wrappers, SWIG will automatically generate them. The interesting bit will be the size of the code created.


11
Oct 05

Stable and Development PN 2

Testers on the mailing list have had access to essentially “daily” builds of PN 2 for a little while now. Recently I have had loads of bug reports for problems that really should have been fixed in PN 2 in maintenance releases rather than waiting for a whole bunch of features to be completed first.

Stable PN 2 releases will have even numbered revision numbers (e.g. 0.6, 0.8.27) and pn-devel builds will have odd revision numbers (so we’re now working on 0.7). The idea is that I’ll be able to release potentially less stable versions of PN 2 for mass testing without upsetting those who need a stable build for day-to-day use (and recommending to friends etc).


11
Oct 05

Ella Released – PN 2.0.6

A new release of Programmers Notepad, PN 2.0.6-ella, has been uploaded to Sourceforge for immediate download! This version adds lots of new features and schemes, and fixes lots of bugs. It marks the start of a new stable/development plan for PN 2 development. This is now the stable PN2 release and unstable releases will be more common. PN 2 is the recommended version of PN for all users.

Thank-you!

Thanks to all the testers and developers that helped with this release, and a special thanks to those who have made donations that are helping to pay for hosting and other essentials.

Why Ella?

Ella Fitzgerald was a fantastic jazz singer, selling over 40 million albums in her lifetime. PN 2 releases are all named after jazz greats, and Ella is certainly welcome in this crowd! One of my favorite Ella tracks is a recording of her performing Mack the Knife live in berlin, such a great song and a great performance.

Download: the installer, or Read: the release notes

The md5sum for this release is 2504c3dd31c9a9daf4cbdcf17090b24f – check your pn206.exe (what is an md5sum?)


11
Oct 05

Odd Bugs

I just had a bug report that paste wasn’t working when using PN through VNC. It turns out, that if you have Caps Lock on and press Ctrl+V then VNC actually sends Ctrl+Shift+V. It turns out that notepad.exe supports both shortcuts! The next release now supports Ctrl+Shift+V for paste! I’ll probably add the copy and cut shortcuts as well, but won’t do this for other shortcuts.