Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi versus C++ Builder - Which is Better Choice for a Java Programmer Doing Win32

I'm a pretty experienced Java programmer that's been doing quite a bit of Win32 stuff in the last couple of years. Mainly I've been using VB6, but I really need to move to something better.

I've spent a month or so playing with Delphi 2009. I like the VCL GUI stuff, Delphi seems more suited to Windows API calls than VB6, I really like the fact that it's much better at OO than VB6, and I like the unit-testing framework that comes with the IDE.

But I really struggle with the fact that there's no widely-used garbage collector for Delphi - having to free every object manually or use interfaces for everything seems to have a pretty big impact on the way that you can do things effectively in an object oriented way. Also I'm not particularly keen on the syntax, or the fact that you have to declare variables all at the top of a method.

I can handle Delphi, but I'm wondering if C++ Builder 2009 might be a better choice for me. I know very little about C++ Builder and C++, but then I know very little about Delphi either. I know there's a lot to the C++ language, but I suspect it's only necessary to know a subset of it to get things done productively... I have heard that the C++ of today is a lot more productive to program in than the C++ of 10 years ago.

I'll be doing new development only so I wouldn't need to master every aspect of the C++ language - if I can find an equivalent for each of Java's language features I'll be happy enough, and as I progress I could start looking at the more advanced stuff a bit more. (Sorry if that sounds painfully naive - if so please set me straight!)

So, for a Java programmer that's new to both Delphi and C++ Builder, which would you consider to be a better choice for productive development of Win32 exes and dlls, and why? What do you see to be the pros and cons of each?

like image 700
MB. Avatar asked Oct 07 '08 20:10

MB.


3 Answers

Delphi or C++ Builder - it's a difficult choice!

As you're aware, they're basically very similar, from the IDE and RAD point of view.

The pros and cons of each - irrespective of background - are a bit like this. Both share a great 2-way RAD form designer and framework (VCL) that are ideal for native Windows development.

Delphi:

  • FOR: Large, active, enthusiastic community
  • FOR: Delphi 2009 is the best version for many years
  • FOR: Delphi "units" make C source/header file pairs seem archaic
  • AGAINST: No automatic destruction as objects leave scope, hence lots of 'finally's in your code
  • AGAINST: Language can be 'wordy', which is a matter of taste
  • AGAINST: Using third-party DLL's or libraries in other languages (esp. C) requires Delphi header files to be written

C++Builder

  • FOR: C++Builder 2009 is probably the best version ever
  • FOR: RAII idiom simplifies memory management hugely
  • FOR: Templates are incredibly useful and powerful, even if the C++Builder implementation has some bugs with them.
  • FOR: Support for BOOST and other modern template-based libraries (even though the Boost support is not 100%)
  • FOR: Great interop with Delphi means most Delphi components can easily be used.
  • FOR: Easy to use with third-part DLLs/libraries with C/C++ headers.
  • FOR: C++ may look better on a CV than Delphi.
  • AGAINST: CB2009 is "unicode only" - the implications of this for code portability are different and less well thought-out than for Delphi
  • AGAINST: C++Builder user-base is much smaller than Delphi. Maybe 20% or less.
  • AGAINST: Borland/Inprise nearly killed BCB a few years ago, and it was only resurrected after major efforts from the community. (However, Codegear/Embarcadero commitment does seem impressive)
  • AGAINST: C++Builder is not top of the pile within Codegear.
  • AGAINST: Third-party component vendors don't always understand/support C++Builder

That's about it. Just to state my position, I'm a happy BCB2007/2009 user (since BCB5), and I also infrequently use Delphi. A few years back, I considered a switch from C++ to Delphi, but the lack of RAII idiom was the one thing that I found difficult to come to terms with.

like image 95
Roddy Avatar answered Sep 28 '22 03:09

Roddy


Go with Delphi and you can use the Boehm Garbage Collector API written by Barry Kelly so you can have garbage collection in Delphi. Barry wrote this before he went to work for CodeGear as a compiler architect. It does have issues with really large applications, and most likely won't work with 64-Bit Delphi. He talks about it quite a bit in this podcast interview.

Even if you don't use that garbage collecting memory manager, I would still recommend Delphi over C++. The only advantage C++ gives you for general development is the curly brace syntax. If you don't mind the Delphi syntax, then for most things you will find it better. Granted C++ Builder has the whole Delphi VCL and RTL, so it isn't as bad as Visual C++, but I still think Delphi would be a better choice.

For Excel add-ins (as you mentioned in your comment) I would recommend Delphi over C++ builder because it has better COM support (which I believe you need for Excel add-ins).

like image 37
Jim McKeeth Avatar answered Sep 28 '22 03:09

Jim McKeeth


Delphi will be a lot easier for you to come to terms with, sure you have to manage your memory, but its very simple

MyObj = TMyObj.Create;

try
  MyObj.DoSomething;
finally
  MyObj.Free;
end

In Delphi all your objects are allocated on the heap, so the rule is very simple if you create it you free it.

C++ with its stack and heap based objs means you have a little more to learn and more scope for getting into trouble.

like image 25
Tim Jarvis Avatar answered Sep 28 '22 03:09

Tim Jarvis