Delphi vs C#

J

Jon Shemitz

I'm outlining a chapter on choosing between Delphi and C# for .NET
programming.

I know why I prefer C# over Delphi ;-) but would love to hear from
other ex-Delphi programmers.
 
C

C# Learner

Jon said:
I'm outlining a chapter on choosing between Delphi and C# for .NET
programming.

I know why I prefer C# over Delphi ;-) but would love to hear from
other ex-Delphi programmers.

Here's an example:

C1 void Foo()
C2 {
C3 int i = Bar();
C4 if (i != MagicNumber) {
C5 ProcessNonMagicNumber(i);
C6 }
C7 }

D1 procedure Foo;
D2 var
D3 i: Integer;
D4 begin
D5 i = Bar;
D6 if i <> MagicNumber then
D7 ProcessNonMagicNumber(i);
D8 end;

Just off the top of my head, looking at fundamental syntax, I prefer:

- Delphi's 'procedure' keyword (D1) to a 'void' return type (C1);
- C#'s braces (C2) as opposed to Delphi's 'begin'...'end' pair (D4);
- C#'s variable declaration syntax (C3), and the fact that declarations
and assignments can take place on a single line;
- the fact that C# method calls allow parentheses even when the
method doesn't have arguments (C3 - D5);
- the fact that 'if' constructs in delphi doesn't require parantheses
for the condition (D6 - C4);
- Delphi's '<>' operator (D6) to C#'s '!=' operator (C4).
- Delphi's assignment operator - ':=' - to C#'s - '=';
- Delphi's implicit 'result' variable, as opposed to C#'s 'return'
construct; and
- the fact that Delphi code just seams to be easier on the eye.

I still can't decide which language I prefer overall :)
 
J

Jon Shemitz

C# Learner said:
C4 if (i != MagicNumber) {
C5 ProcessNonMagicNumber(i);
C6 }

Fwiw, the braces aren't necessary.
- Delphi's 'procedure' keyword (D1) to a 'void' return type (C1);
- C#'s braces (C2) as opposed to Delphi's 'begin'...'end' pair (D4);
- C#'s variable declaration syntax (C3), and the fact that declarations
and assignments can take place on a single line;
- the fact that C# method calls allow parentheses even when the
method doesn't have arguments (C3 - D5);
- the fact that 'if' constructs in delphi doesn't require parantheses
for the condition (D6 - C4);
- Delphi's '<>' operator (D6) to C#'s '!=' operator (C4).
- Delphi's assignment operator - ':=' - to C#'s - '=';
- Delphi's implicit 'result' variable, as opposed to C#'s 'return'
construct; and
- the fact that Delphi code just seams to be easier on the eye.

Thanks - exactly the sort of thing I'm looking for.
I still can't decide which language I prefer overall :)

Follow the money ... ;-)
 
C

C# Learner

Jon said:
Fwiw, the braces aren't necessary.

I guess my example comparison was a little unfair in that respect -- I
didn't use Delphi's brace equivalent for the single statment in the 'if'
construct.

I did this because I don't use 'begin' and 'end' in Delphi where there's
only a single statement, but I *always* use braces in C#. I use K&R
style for any C-like language, but not for Delphi code, probably due to
the fact that I think 'begin' on the first line doesn't look so neat.
Thanks - exactly the sort of thing I'm looking for.

No problemo.
Follow the money ... ;-)

Ah, that makes it a much easier decision :)
 
D

Daniel O'Connell [C# MVP]

C# Learner said:
Here's an example:

C1 void Foo()
C2 {
C3 int i = Bar();
C4 if (i != MagicNumber) {
C5 ProcessNonMagicNumber(i);
C6 }
C7 }

D1 procedure Foo;
D2 var
D3 i: Integer;
D4 begin
D5 i = Bar;
D6 if i <> MagicNumber then
D7 ProcessNonMagicNumber(i);
D8 end;

Just off the top of my head, looking at fundamental syntax, I prefer:

- Delphi's 'procedure' keyword (D1) to a 'void' return type (C1);
- C#'s braces (C2) as opposed to Delphi's 'begin'...'end' pair (D4);
- C#'s variable declaration syntax (C3), and the fact that declarations
and assignments can take place on a single line;
- the fact that C# method calls allow parentheses even when the
method doesn't have arguments (C3 - D5);

Actually requires it. A method identifier without a () at the end refers to
the method itself, not a call(as used in delegate syntax).
 
C

C# Learner

Daniel O'Connell [C# MVP] wrote:

[...]
Actually requires it. A method identifier without a () at the end refers to
the method itself, not a call(as used in delegate syntax).

I understand that. The point I was trying to make was that Delphi
doesn't allow calls to use parentheses when no parameters are being
passed (unless the routine returns a value and that value gets assigned
to a variable)*, but C# does.

i.e. the following wouldn't be legal Delphi code:

procedure Foo;
begin
end;

procedure Bar;
begin
Foo();
end;

* Well, I believe this to be the case, but can't test this tonight, due
to a lack of a Delphi compiler here. It's standard in Delphi not to use
parentheses unless the you're passing a value, so I can't say I've ever
tried using them in this scenario :)

Cheers

[...]
 
G

genc ymeri

More or less I would say the same things. I have been programming for 5+
years in Delphi and 5 months+ in C# and Delphi in the same time ... but C#'s
code IMHO it's easier to understand.

What other things I like most in C# are

C9) i += 3; or i++;++i
C10) declaring variables almost anywhere when we need them for {short
i=0;i<b;i++)

but speaking of Delphi, I like very much its IDE and generally Borland
IDE-s.

I can't understand why MS Studio C# is so backward compare to Borland's
IDEs. (It has crashed to me 3 times and now still I have problems, specially
when I rename menuItems.....)

In the bottom line, I love them both but my eyes and I feel better now in C#

PS
"> Follow the money ... ;-)"
Nowadays it seems to like money is going to India and China ,,,,,no, better
delivering pizza here in US :) :) :)
 
M

Marc Scheuner [MVP ADSI]

Delphi .NET is comming you know that ???

It's here already.

Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
M

Marc Scheuner [MVP ADSI]

i.e. the following wouldn't be legal Delphi code:
procedure Foo;
begin
end;

procedure Bar;
begin
Foo();
end;

OF COURSE IT IS !! In Delphi, you don't HAVE to add the () to an
"empty" method call, but you damn well can, if you insist......

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
M

Marc Scheuner [MVP ADSI]

- C#'s braces (C2) as opposed to Delphi's 'begin'...'end' pair (D4);

That's one of the WORST features of C# - hate those pesky squiggly
things all over the place.... begin/end is just SO much easier to read
and comprehend!
- C#'s variable declaration syntax (C3), and the fact that declarations
and assignments can take place on a single line;

YIKES! Talk about messy - define variables in the middle of your code
- I find this highly irritating, actually.
- the fact that C# method calls allow parentheses even when the
method doesn't have arguments (C3 - D5);

Works for Delphi too !!

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
M

Michael Moreno

I'm outlining a chapter on choosing between Delphi and C# for .NET
programming.

I know why I prefer C# over Delphi ;-) but would love to hear from
other ex-Delphi programmers.

You cannot easily compare the language Delphi for Win32 with the language C#
for the .Net platform.
You cannot either compare the developing software Delphi for Win32 with VS
for .Net

You need to compare either Delphi 6-7 vs VS 6. So no C# but C++ or VB
and Delphi for .Net vs VS.Net C# or VB.Net or managed C++.

Then your conclusion should be something like: it all depends on the type of
application but I have no doubt that you will eventually find that Delphi
tends to be very good at many things whether because of its IDE, integration
with UML, many free components, its community, etc and that the .Net
platform somewhat revolutionize our job and that we have not got the
experience to really make any comment on it : who has created a rock solid
N-tiers app in C# for 30 users and knows all the network security problems?
you know the kind of things we now know about COM+ and DCOM as an example
but could not say anything on it 10 years ago...
 
J

Jon Skeet [C# MVP]

Marc Scheuner said:
That's one of the WORST features of C# - hate those pesky squiggly
things all over the place.... begin/end is just SO much easier to read
and comprehend!

I guess it must be a preference thing: I find that braces (combined
with indenting, of course) make the code look much less cluttered.
YIKES! Talk about messy - define variables in the middle of your code
- I find this highly irritating, actually.

On this one I have to disagree *vehemently*. Why should one part of a
method interfere with another, in terms of variable availability? Why
should I have to look back to the top of a method to see the type of a
local variable, or go there in the editor to declare a new one?

The loss of this restriction was a *very* good move. Of course, you can
always write your code declaring everything at the top if you want.
Just don't expect me to read it :)
 
M

Morten Wennevik

That's one of the WORST features of C# - hate those pesky squiggly
things all over the place.... begin/end is just SO much easier to read
and comprehend!

Well, I for one find that 2 easily distinguishable characters is far
easier to spot than 8 characters :)
YIKES! Talk about messy - define variables in the middle of your code
- I find this highly irritating, actually.

Again, less characters, cleaner code :)
 
B

Brian W

I can't understand why MS Studio C# is so backward compare to Borland's
IDEs. (It has crashed to me 3 times and now still I have problems, specially
when I rename menuItems.....)

Because, if they (MS) made the IDE better they would be accused of ripping
off Borland ;-)
"> Follow the money ... ;-)"
Nowadays it seems to like money is going to India and China ,,,,,no, better
delivering pizza here in US :) :) :)

I hear ya brother! I got my name on the waiting list at Dominoes and my
truck is in the shop getting a tune-up for the long miles ;-)

Brian W
 
J

Jon Shemitz

Jon Skeet said:
On this one I have to disagree *vehemently*. Why should one part of a
method interfere with another, in terms of variable availability? Why
should I have to look back to the top of a method to see the type of a
local variable, or go there in the editor to declare a new one?

Indeed.
 
G

Guest

I'm outlining a chapter on choosing between Delphi and C# for .NET
programming.

I know why I prefer C# over Delphi ;-) but would love to hear from
other ex-Delphi programmers.

Both Delphi and C# are very good candidates. In my opinion they are both
worth learning and using.
Just choose the one that you think that is closes to what you prefer. Or
choose one that you think that the market will need.

I have Choosen C# since I can also compile C++ code in the same project
because of Microsoft Visual Studio.
We have a lot of old C++ code that needs to be ported step by step. So for
the moment we rely on mixed code but we are slowly migrating to .NET code.
 
J

Jochen Kalmbach

Marc said:
OF COURSE IT IS !! In Delphi, you don't HAVE to add the () to an
"empty" method call, but you damn well can, if you insist......

"have not" oder "must not" heisst im deutschen "darf nicht"
dagegen bedeutet
"need not" im deutschen "muss nicht"

Also sollte der Satz heissen:
"you don´t need to..."

Ist zwar etwas verwirrend, aber die deutsche Sprache ist da leider etwas
"falsch"...


--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp


Do you need daily reports from your server ?
http://sourceforge.net/projects/srvreport/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top