Shameless Plug (of a Memory Leak)

Superswitcher version 0.5 is out.

  • Plugged a memory leak. Previously, we were not destroying cairo contexts.
  • First draft of a D-Bus interface.
  • New add and remove workspace buttons.
  • Respects #define MAX_REASONABLE_WORKSPACES 36 as per metacity.
  • –trigger-on-caps-lock split into –also-trigger… and –only-trigger…

The memory leak turned out to be that I wrote gdk_cairo_create without having a corresponding cairo_destroy. You’d think compilers these days should be able to pick up an error like that. C++ has ‘smart pointers’ and destructors, but hot damn is it ugly. Garbage collected languages take away the problem of explicit memory management, but can be sluggish (yeah, yeah, it’s debatable), which might be quite important if you’re on limited resources.

I like C. I get it, and as far as software goes, it’s small and simple enough that I think I get all of it. I can read C, and I can understand what’s happening. Compare this to C++, where overloading and operators and multiple inheritance and references instead of pointers means that when you get an obscure bug, it hurts. Even when you have a simple bug, the compiler error messages are horrendous to get your head around. Apparently there’s a new C++ standard (“C++0x”, due Real Not-Soon Now) brewing that will ‘fix’ some of these problems, but I expect it to suck because they’re adding more things rather than taking stuff out. To mix metaphors, you can’t polish a backwards compatibility crutch.

Java and Python are (relatively) easy to write in, but for serious stuff, you have to “learn the architecture of the machine”, so says Samba guru Jeremy Allison. You gotta understand pointers, and that something is slow because you’re copying lots of char arrays in a dumb way. Having read what I just wrote, I am turning into such an old fart, but then again, I’m like 48 in computer years.

What I really want is a programming language that reads like Python and runs like C. That should be its mission statement: reads like Python, runs like C. Maybe I should enrol in a research degree, spend a few years inventing Yet Another Best Programming Language Ever, and whinge that nobody uses it even though it is the Best Programming Language Ever. If I do, you’ll surely hear about it. In the meantime, enjoy a less leaky window switcher.

Closing thought: what’s the biggest memory leak anyone’s ever seen? This fuzzy screenshot shows Firefox clocking over 1.5GB…

2 comments ↓

#1 Scott Robinson on 05.01.07 at 10:31 pm

Ask for a language, and a million language weenies will respond with their favourite pick of the week.

So, “reads like Python, runs like C” answer of the week is the D Programming Language.

Or, you know, if you like GObject and actual C, Vala is looking better and better.

#2 Nigel Tao on 05.02.07 at 10:41 am

Vala and D read like C# to me but, yes, they are two to watch.