[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.programming

C++ or Object Pascal...

Ramine

2/26/2015 12:37:00 AM


Hello,

I have tried to look at the C++ language and compare it to
Object Pascal, because i am also a Delphi and FreePascal develloper
that is using Object Pascal(i mean object pascal that is more powerful,
not pascal), so i have tried to look at the syntax of C++ patiently
to feel more what is C++ and C , and i have come to the follwing conclusion:

If you look at the "for" statement:

In Object Pascal we write this:

for i := 0 to 6 do

But in C and C++ we write this:

for (i = 0; i < 7; i++)

So as you have noticed there is an "i++" that we must add in C and C++,
so Object Pascal is more beautiful and easier here...


Other than that there is also the "case" statement:

In Object Pascal we write this:

case n of
0: str := 'alpha';
1: str := 'beta';
2: str := 'gamma';
else
str := 'invalid';
end; // case


but in C and C++ we write this:

switch (n)
{
case 0 : str = "alpha";
break;
case 1 : str = "beta";
break;
case 2 : str = "gamma";
break;
default: str = "invalid";
} // switch


So notice with me that in C++ and C you have to write
the "switch" word and you have to write all over again many times
the "case" word, but in Object pascal you write only one time
the "case" word, so Object Pascal is beautiful and easier here...


Other than that i was amazed to not find in C and C++ the data type that
we call "sets" in Object Pascal...

For example in Object Pascal we can do this with the "sets" type:

type
col_t = (red, blu, grn); // enum.
MySetType := set of col_t;
var
a, b, c : MySetType;
begin
a := []; // empty set
a := a + [red]; // union
b := a - [blu]; // difference
c := a * b; // intersection
if [red] in a then ...
(* Note that sets are generally used to handle non-exclusive flags in
Object Pascal. *)


But in C and C++ there is no equivalent type of the "sets" of Object
Pascal, so Object Pascal is beautiful and simple easier here again...


Also in Object Pascal, i have noticed that it's much easier to work with
strings than in C and C++... so Object pascal is more beautiful and
easier here also...


Also i have noticed that it's much easier to create a dynamic link
library(so or dll) with Delphi or FreePascal than with C++ or C compilers...

I think also that i don't need to speak about the macros in C++ or C,
because macros can become easily "cryptic" in C++ or C and that's bad...


And i have noticed that it's much easier to work with dynamic arrays
with Object Pascal than with C++ or C.

So i think i will not continu this comparison between Object Pascal
an C++ and C, because i think C++ and C are a mess.

So i think overall Object Pascal is more "beautiful" and easier than C++
and C, and i think that's the strenght of Object Pascal.




Thank you,
Amine Moulay Ramdane.












1 Answer

Richard Heathfield

2/25/2015 11:12:00 PM

0

On 26/02/15 00:36, Ramine wrote:
>
> Hello,

Hello. Why do you keep multi-posting this crap? If you must post the
same article to several newsgroups, learn how to cross-post. Better
still, learn how to post an article only in the newsgroup where it is
most relevant. I have utterly destroyed your arguments in a reply posted
in comp.lang.c, but I'm not going to repeat them here because it's a
waste of bandwidth. If you want to know why you're wrong, look in
comp.lang.c for the answer I posted there.

--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within