iPhone Apps without Objective-C

Yes, it’s possible. Even if Objective-C is one of my preferred programming languages, in any case I think it’s worth mentioning that, 2 years after the official iPhone SDK has been announced, the iPhone development landscape has really grown up, and many, many different options are available today. This article provides a very high-level enumeration of some options I’ve found on the web, but I’m sure there are even more alternatives around.

0321566157

Here it goes: Continue reading

Best books of 2008

You might remember my beloved mantras: learning a new programming language and reading at least 6 relevant books every year. Following the 2007 edition, here’s the list of the 8 books I have enjoyed most in 2008, ordered by a purely subjective and absolutely irrational decreasing preference. I strongly recommend all of them!

Winner: Geekonomics: The Real Cost of Insecure Software by David Rice

Runner-up: The No Asshole Rule: Building a Civilized Workplace and Surviving One That Isn’t by Robert I. Sutton, PhD

And 6 more:

Continue reading

Master

I’ve sent the final version of my dissertation to the University of Liverpool. I’ve been doing this Master’s degree since 2005, and now it’s over. It feels good and weird at the same time.

Rem 1.0, the final result and main objective of my Master’s thesis work, has been released today. A small, simple, yet extensible and portable UML tool written in C++, using Juce, POCO and SQLite. Not perfect but extensible and small. And that’s what’s great about it.

Amazing Xcode

Xcode is amazing. Of all the IDEs I’ve used (and this is, as always, a personal opinion, having used Visual Studio since version 6, Eclipse, Kdevelop and others) it’s the one I prefer. And today I found another reason to like it.

I’ve noticed this: when I use Xcode on a single-processor machine (such as a Powerbook G4) and I rebuild my master thesis project (in C++) I see this build window:

No big deal: each file is compiled, one after the other. However, it seems that when I run it on a dual-processor machine (both in my dual G5 desktop and my Intel Core Duo 2 MacBook) I get a boost in compiling time, with parallel compilations! See this:

Then, coupled with Bonjour networks, you can even go faster, using the processing time of your peers’ computers to have smaller compilation times.

ImageMagick

ImageMagick is a cool toolkit; not only it’s a complete set of command-line applications, ported to Windows, Mac and Linux, supporting hundreds of different image formats, it’s also a C++ library that you can use in your own applications!

On Mac OS X, I installed it via MacPorts using the all-time classic:

sudo port install ImageMagick

Then I created a C++ command-line application with Xcode, set the header and library paths in the target properties (/opt/local/include/ImageMagick and /opt/local/lib in this case) and I was ready to code. The API documentation and the tutorial give some hints, and using those examples I’ve cooked a quick image transformation utility to play with:

[source:c]

include

using Magick::Image; using Magick::Geometry; using Magick::Blob;

int main (int argc, char * const argv[]) { Blob blob;

Image png;
png.read("pic.png");
png.write(&blob);
Image jpg(blob);
jpg.magick("jpg");
jpg.zoom(Geometry(100, 200));
jpg.write("newpic.jpg");
Image tiff(blob);
tiff.magick("tiff");
tiff.zoom(Geometry(3000, 84000));
tiff.write("newpic.tiff");
Image gif(blob);
png.magick("pdf");
png.write("newpic.pdf");
return 0;

} [/source]

Interesting stuff indeed! The API provides a complete set of “Photoshop-like” operations on images, which I plan to study further in the near future.

Templates

Did you knew this is possible in C++? I didn’t.

[source:c] void Fun() { class Local { //… member variables … //… member functions … };

// ... code using Local ...

} [/source]

This feature is called “local classes” and is part of the standard; the limitations are that these local classes cannot have static member variables and cannot access nonstatic local variables. But, as Alexandrescu points out (page 28), you can use them in template functions:

[source:c] class Interface { public: virtual void Fun() = 0; // … };

template Interface* makeAdapter(const T& obj, const P& arg) { class Local : public Interface { public: Local(const T& obj, const P& arg) : obj_(obj), arg_(arg) {}

    virtual void Fun()
    {
        obj_.Call(arg_);
    }
private:
    T obj_;
    P arg_;
};
return new Local(obj, arg);

} [/source]

Not only that, but partial template specialization and template-based compile-time verifications just blew me away. The second chapter of the book was realizing I just haven’t had the slightest clue about all the cool things you could do with C++!

Blow your mind

Take a careful look at this:

[source:c]

include

class Gadget { public: void sayHello() const { std::cout << “Gadget!” << std::endl; } };

class Widget { public: void sayHello() const { std::cout << “Widget!” << std::endl; } };

template class OpNewCreator { public: T* create() { std::cout << “Using ‘new’: “; return new T; } };

template class MallocCreator { public: T* create() { std::cout << “Using ‘malloc’: “; void* buf = std::malloc(sizeof(T)); if (!buf) return 0; return new(buf) T; } };

template