May 9, 2015

Some COM for you - Chapter 3

We finished Chapter 2 having registration-free COM working, but having 3 files (.dll, .tlb and .manifest) instead of single .dll. Now, it's possible to embed both .tlb and .manifest into .dll.

Here's the recipe.

May 3, 2015

Some COM for you - Chapter 2

In which Tigger COM is unbounced

...what they should do is take Tigger on a long walk to somewhere where he won't know where he is, and then leave him there, and when they go back to find him the next morning 

he will have learnt his lesson and been unbounced.
A. A. Milne

We ended chapter 1 having working Delphi - .Net interop via COM, but with one unfortunate issue - a need to register a library on every machine with absolute path. A solution for this would be to use Registration-free COM also known as Side-by-Side COM. This chapter is how to make it work, and though it worked in the end, the whole process is a bit thorny and winding and fragile and... well, it's possible to make it work still.

Rube Goldberg coffee machine by Dina Belenko

Mar 21, 2015

Some COM for you - Chapter 1

In which Piglet Meets a Heffalump Delphi meets .Net

"I saw one once," said Piglet. "At least, I think I did," he said. "Only perhaps it wasn't."
A. A. Milne

If you ever programmed for Windows, you should have heard weird stories of evil COM that lurks there in shadows waiting to drag you into the abyss of marshalling and IUnknowns...

As for me, I remembered Joel saying that when Microsoft first presented COM, they were proud to say that "it requires at least 20 000 lines of code just to get started". (Strangely, I can't find that line on his site anymore, can somebody help me with it?) So I never had any will to learn COM through (which may be not the best part of me), but anyway.

When I found that I need to use some COM libraries in a desktop app I decided to study C# because .Net has been said to have native COM support and I should not have to worry about the details. (And this was for the better, actually! I was prejudiced against C# knowing that Gosling blamed it for having unsafe code, but it turned out that C# is actually a better Java, and I like it!).

So when I recently found that I have to make a C# library to work with Delphi app and the only way to do it is COM, I started preparing for worst. Below is a story of how to make this work, which I'd like to keep in case I'll need to do something like that again.

The problem just reminded me about this promising energy source

Aug 21, 2013

Documentation? Again?

A year and a half ago I was already whining on the quality of documentation even of big companies. Since then the situation seems to get even worse!

I recently came upon this article - "Api Documentation" by Chris Parnin. The article is a research studying the fact that most developers are using StackOverflow as a main documentation source. I totally recommend to read the whole article, but here I'll just quote the main result of the study:
  • Developers may be getting as much as 50% of their documentation from Stack Overflow.
  • More examples can be found on Stack Overflow than the official documentation guide.
  • In web searches, Stack Overflow questions are visited 2x-10x more often than official documentation.

Sep 22, 2012

A year after C++11

A spherical horse from MOBITECH
.. But - there's one proviso.
The model is only valid for a perfectly spherical horse
moving through a vacuum.

C++11 has been standardized on August 2011, more than one year ago. Though I'm not using it in everyday tasks (ARMCC for 3DS is said to have support for C++11 maybe in 2013), it's still interesting to know what's happening in a world of big programs and unrestricted resources.

Feb 13, 2012

Even more rope to shoot yourself in the foot

The title of this book describes what I consider to be the main problem with both C++ and C: the languages give you so much flexibility that, unless you're willing and able to discipline yourself, you can end up with a large body of unmaintainable gobblygook masquerading as a computer program. You can do virtually anything with these languages, even when you don't want to.
Allen I. Holub

C++11 is already here. I'm not going to make another overview of all the good new things in it. Actually, I don't know much about those good new things. What I'm going to make - is an overview of why these good new things don't matter much (and why I am not too ashamed of not knowing much about them). There are few reasons.

Feb 10, 2012

Write-only code

There are lots of modern and mature languages stating the speed of coding as one of major language advantages:

Python lets you write the code you need, quickly. 
Perl -- Because life's too short to code without punctuation.

Phrases like this always puzzle me. While it sounds nice to be able to write code quickly, what's about reading it? I mean, the code you write is not only for a compiler to read. The code is to be read by humans. By you! And by those unfortunates, who will have to support your code after you leave the building. These poor guys will be glad to know that the fancy language allowed you to write that shit of a code by 15 minutes faster. This warm thought would be with them all that hours they would spend sticking eyes into cryptic lines, trying to fix that little mistake you did 6 months ago..