Re: Converting Pascal to C++, C# or VB

"Eric" <englere.geo@yahoo.com>
12 Apr 2006 22:48:36 -0400

          From comp.compilers

Related articles
[9 earlier articles]
Re: Converting Pascal to C++, C# or VB thompgc@gmail.com (thompgc@gmail.com) (2006-04-08)
Re: Converting Pascal to C++, C# or VB marcov@stack.nl (Marco van de Voort) (2006-04-09)
Re: Converting Pascal to C++, C# or VB marcov@stack.nl (Marco van de Voort) (2006-04-09)
Re: Converting Pascal to C++, C# or VB marcov@stack.nl (Marco van de Voort) (2006-04-09)
Re: Converting Pascal to C++, C# or VB DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-04-10)
Re: Converting Pascal to C++, C# or VB gneuner2@comcast.net (George Neuner) (2006-04-10)
Re: Converting Pascal to C++, C# or VB englere.geo@yahoo.com (Eric) (2006-04-12)
Re: Converting Pascal to C++, C# or VB hebisch@math.uni.wroc.pl (Waldek Hebisch) (2006-04-12)
Re: Converting Pascal to C++, C# or VB oliver@first.in-berlin.de (Oliver Bandel) (2006-04-14)
| List of all articles for this month |

From: "Eric" <englere.geo@yahoo.com>
Newsgroups: comp.compilers
Date: 12 Apr 2006 22:48:36 -0400
Organization: http://groups.google.com
References: 06-04-01706-04-039 06-04-072
Keywords: Pascal

First, let me say that I love Delphi and I would not want to start a
"Delphi vs C#" kind of debate here. They are both good, and they have
differences. The question about strongly typed cast checking at
runtime is not really a language issue - it's more of a platform
issue. The Win32 platform can support runtime cast checking, but you
don't see this in most popular Win32 languages because of efficiency
concerns.


Delphi for Win32 is more like traditional C in the way it handles
casting. The type compatibility is determined at compile time. Once it
passes the compiler test, there is typically no runtime code to
validate the cast. I know they have some runtime checking, but this is
not normally used on objects at runtime to determine if a cast is
valid. The cast normally does not exist in the runtime code - there is
only limited runtime validations for things like array bounds. You can
typically cast just about anything to a pointer, and use it as you
wish. I'm not trying to slam Delphi here - the way it does this kind
of code makes it very efficient. Delphi borrowed pointer handling from
C in a general sense.


.NET, like Java/JVM, does have a special instruction that is used at
runtime to validate a cast, and it throws a runtime exception if the
cast fails. Java doesn't have the same kind of delegates (function
pointers), but Java deserves credit for the concept of a runtime cast
validation. Of course it may have originated elsewhere, but Java made
it a popular idea.


Delphi for .net has first-class support for strongly typed delegates,
and Delphi supports most CLR functionality. It also excels at "unsafe"
code that runs under the CLR for cases where you need to break the
rules on purpose. Only C++ and Delphi can do a good job with "unsafe"
CLR code. C# is terribly bad at this, and they intentionally made it
hard to do because they didn't want to encourage unsafe code.


The only reason I didn't recommend Delphi for the original poster is
that he has a ton of legacy non-OOP Pascal code. This kind of code
can't be automatically translated into ANY OOP language in a good and
maintainable manner. So his best bet might be to stay with legacy
Pascal (perhaps with Gardens Point Component Pascal, which handles OOP
and non-OOP code AFAIK), and migrate to a true OOP design by
hand-coding new routines over a period of years.


I'm also somewhat concerned about Delphi's future in regards to their
impending spinoff from Borland. It won't die anytime soon, but it has
a black eye, and may get beat up a bit more. This is sad because the
fine lady deserves better.


Eric


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.