Noah Silva on Thu, 11 Jul 2002 18:46:30 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Pascal?


On Wed, 2002-07-10 at 20:14, Jason wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Wednesday 10 July 2002 16H:37, Fred K Ollinger wrote:
> > > But, we're not talking grammer, here. And, even with correct grammer,
> 
> It doesn't seem like 2 is a plethora of functions to me. Actually, I find that 
> one of the many benefits of OO is fewer function names that accomplish the 
> same thing, sometimes due to overloading,

"Function overloading" can be done without OOP at all.

> sometimes due to inheritance. So, 
> in the example given, rather than printf, vprintf, etc. you replace that with 
> cout, or more generally streams. Now, you have one concept to learn that 
> applies in many different instances. That way, you don't have to memorize a 
> lot of function names that all do similar things.
> 
> 
> This seems a little strange at first glance. You are frightened by something, 
> which makes you want to learn it. I guess that's encouraging in a sense. I'd 
> recommend learning C more as part of a foundation for continuing on to C++ or 
> Java. But, you probably wouldn't need to dwell on it too much upfront if that 
> was the approach you decided on. There are some parts of "straight C" that 
> you don't absolutely need in C++ (or that have been removed entirely), I just 
> think it's good to be familiar with the basics first.
> 
> 
> Noooooo.... Sorry, that's not at all what I meant to say. I have one word for 
> you: Inheritance. Without inheritance, you are missing out on a great deal of 
> the benefits of OO. Then, you've got to virtual functions and abstract base 
> classes, and.... Hey, the work has already been done for you. It's called 
> C++.

And with too much inheritance and too many virtual functions you have a
slow-ass program ;)
 
> If you really want a language holy war, try to discuss the 
> strengths/weaknesses of single vs. multiple inheritance. But, we won't go 
> there...

Well this is easy: 
Look at how many compilers support each, and Why?
C? Java? Pascal? Oberon? Eiffel? Modula3?
Language designers have -some- idea what they are doing.  Later
languages are usually developed to fix the perceived shortcoming of
older languages.

> In short, Java does have a notion of "pointers", but not pointer arithmetic. I 
> would say that this is definitely safer for the general programmer.

Yes, to me, low-level pointers should be avoided unless needed, when
they cause so many programming mistakes.

> > > Well, if you and/or Noah want to learn about the design and evolution of
> > > C++, read it from the source. Bjarne Stroustrup has a book out, titled,
> > > "The Design and Evolution of C++". If you guys want to understand what he
> > > did and why he did it, go ask him, or read his book. And, I'm sure he
> > > didn't come up with all of these ideas by himself, but he was certainly
> > > one of the primary focal points of all of the activity. But, he probably
> > > covers most of this in his book. I haven't read it, but I recommend it to
> > > anyone that wants to discuss his design intentions.

That actually sounds interesting if I have time.

This makes me remember my OOP book at Drexel, which called C++'s OOP
implementation "an embarrassment", so at least that author didn't like
it much he he.

> > > > > To me, OO does not mean "don't create procedures anywhere". IMHO, it
> > > > > does mean simplify and group functions with relevant data. If you
> > > > > don't have a set of related functions and have no related data that
> > > > > you need to keep with that function (different data every time you
> > > > > call the function), then you probably don't have a new type of
> > > > > object.

I'm with you, but a lot of OOP books and such aren't.  I think overusing
OOP makes no sense and leads to bloated code.  There are situations
where it makes sense, and those where it just plain doesn't.

Especiall in Pascal, where many of the things OOP brings to the table in
C++ already exist in straight Pascal.

> One more time, anybody can write really crappy code in any language. IMHO, 
> that includes ObjectPascal, C++, and Java. I know some people that are really 
> good at writing crappy code.
> 
> I don't have any experience with ObjectPascal, but if you want someone to 
> write some crappy code in ObjectPascal, I could give you a few references :)

This is certainly true.  Pascal makes you declare variables before the
block of code you use them, lets you organize procedures in a hierarchy,
etc., but you could still obfusicate it or choose not to use and
language features if you want to, just the came way you can in C.  Which
is easier to read?:

dest[0] := source[0];

or:

SetLength(dest, length(source));

They do the same thing (assuming you are using short strings). But for
the first one, you have to be using old style static "short" strings,
and also you have to know that element Zero of a string is it's length. 
likewise you can ignore pascal's features and declare something like:

pWindow:pointer;

instead of 

pWindow:^window;

Not only is "^window" more descriptive to the reader than "pointer", it
is more descriptive to the compiler too.  If you use "^Window, the
compiler will check at compile time to make sure any thing you assign to
it is either "window" or a pointer to "window".  If you use "pointer",
you bypass this and can assign a pointer to anything to it.

  -- noah silva


______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug