среда, 18 марта 2015 г.

Objective-C and Delphi

Original in Russian: http://18delphi.blogspot.ru/2013/03/objective-c-delphi.html

More alike than different.

In fact, it was not a trouble to partly shift from developing in Delphi to Objective-C.

Unfortunately, too harshly. It looks like Delphi returns to life.

Later on I’ll continue writing this post and explaining the likeness of these two languages.
Meanwhile the following points:
1. Single inheritance.
2. Interfaces (protocols).
3. Metaclasses. class and CLASS.
3. Common for all objects base parent class - TObject and NSObject.
4. Reference counting.
5. TList and NSArray. The first does not have reference counting, though.
6. Controls and graphics contexts. These have LOTS in common.
7. Event's ad selector's.
8. Virtual classes methods.
9. Creating of objects (descendants of TObject and NSObject) only in a heap.
10. Means to override objects allocation (NewInstance and alloc).
11. Categories in Objective-C and helper's in Delphi.

Sure, in some aspects Objective-C “beats” Delphi, and vise versa. I’ll try to write about it, too.

Meanwhile, NSOperation is very cool for mobile devices. I don’t know yet if there is an analogue in Delphi XE. If there is not any, Delphi has a GREAT disadvantage.
I’d also mention NSDictionary, NSArray and native serialization.

Again, I am very attached to the concept of objects reference counting implemented in Objective-C. I have “devised” a concept of this sort, although I did not hit upon autoreleasepool (well, I didn’t need it).

If we develop not in Objective-C (.m), but in Objective-C++ (.mm), we “go over to the enemy” :-) Nevertheless, we get access to the “great and powerful” STL. Thus, we do not have to recreate wheels. Especially “tasteful” is the fact that Objective-C classes and C++ classes mix TRANSPARENTLY. Of course, this is done without cross-inheritance, which is NOT NEEDED. Aggregation is more than enough.

I’ll not even touch upon C++ 11 standard and its “goodies” – particularly with regard to metaprogramming. The mere auto and lambdas are worth something. (By the way, there are lambdas (block) in Objective-C, as well as in Delphi XE, as far as I remember, but I, to be honest, have not yet tried it and have nothing to tell).

I will not also mention patterns with a variable number of parameters (that’s the kind!).

Generally speaking – “a stitch in time saves nine” and each tool is good for something particular.

Delphi is more “dear” to me personally since I have been developing 18 years in it. Actually, I started with developing in Turbo Pascal 3.0 (probably, not everyone remembers).

But now I am not afraid of Objective-C. Quite the contrary – I have found it is much familiar to me.

I’ll just say a commonplace: “if you wish to find the difference – you find the difference, and if you wish to find the likeness – you certainly find the likeness”.

Try it. May be you will like it.

... to be continued ...

Комментариев нет:

Отправить комментарий