POV-Ray : Newsgroups : povray.advanced-users : Object Oriented POV code Server Time
21 Nov 2026 19:56:43 EST (-0500)
  Object Oriented POV code (Message 101 to 150 of 179)  
<<< Previous 50 Messages Goto Latest 50 Messages Next 29 Messages >>>
From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 12:22:02
Message: <cjameshuff-E97472.12224322022004@news.povray.org>
In article <40388944@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

> > Interfaces are not obsolete. As for abstract classes...what are you 
> > talking about?
> 
>   Interfaces are obsolete of you can make abstract classes. And why
> wouldn't you (unless you want to make the language so that it does
> not support virtual functions, which would limit its OO capabilities
> by a whole lot).

Argh...forget about virtual functions. They are an artifact of C++, 
which does everything statically by default. I specifically said no 
static binding. No virtual functions, because everything is dynamically 
bound.


>   A class is abstract if it has pure virtual functions (that is,
> the class does not implement the virtual function(s) and thus cannot
> be instantiated because of this; it can only be used through
> inheritance so that the derived class implements the virtual
> function(s) in question).

Again, I'm talking about single inheritance. Multiple inheritance is not 
necessary, and is needlessly complex. Abstract classes are not as useful 
in single inheritance models, interfaces cover their functionality. 
Interfaces render multiple inheritance + multiple abstract root classes 
obsolete, not the other way around.


> > Sorry, but I don't. I've never accidentally tried to access a private 
> > member.
> 
>   That's right. *You*. But that's ok only for as long as you don't
> distribute that library of yours containing public member variables...
> Someone will inevitably use it in the wrong way and his code can then
> break with an updated version of the library.

That's their fault for screwing around with stuff that's not documented 
as the public interface. They could do the same thing with preliminary 
code that may eventually be public interface, but which isn't nailed 
down yet. But I've seen enough people trying really hard to do really 
stupid things to get your point...fine if they are the only victims of 
their stupidity, but if I have to work on their code or use their 
software...


>   Well, that's just a question of implementation of the interpreter/compiler.
> If you can implement the interpreter so that the private part does not need
> to be specified at the same place as the public part, good thing. (In C++
> this is not possible for technical reasons, but in an interpreted
> scripting language it may very well be possible.)

Oh, it's possible for C++, just more complex to compile. The compiler 
would have to collect both definitions before it could compile anything 
using more than a pointer or reference to the type. Probably be best to 
have special directives specifying the files that have the 
implementation and interface. Or tie the class names to the file names, 
like Java.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 12:32:55
Message: <cjameshuff-D59D28.12333622022004@news.povray.org>
In article <n8ag309hemfhpmj8jnt5j5s3k8gr66rm62@4ax.com>,
 Andreas Kaiser <aka### [at] nurfuerspamde> wrote:

> This might be a 'learning' problem if you aren't aware of the
> operators 'hidden' complexity. 

Only if the code is poorly designed. You shouldn't have to care about 
the hidden complexity. It doesn't matter one bit how the = operator 
copies a string, only that it does so.


> >So do functions.
> 
> Yes, same problem here. There's no correlation between length of
> function name and complexity. 

It's not a problem. It's a feature. Code written without functions is 
called spaghetti code, it ain't pretty and it is very inefficient and 
unmaintainable. Or should functions that do more have longer names? How 
long should POV-Ray's main() function be?


> If you call a Trace() function you should know why.
> May be to write a trace record to a log file, may be to start a render
> that will be finished some months later.

And when it's in a raytracer, and when you're giving it ray information 
and receiving a color from it, which do you think it is? This is an 
English language issue, not a programming language one.


> The macros required to do trivial colour/vector arithmetic are
> 'information hiding' in the worst sense. They blow up source code and
> add visual noise which makes it sometimes almost impossible to see
> what's going on.

Agreed. They hide what the code is really doing by bloating up each 
little operation.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 12:43:14
Message: <cjameshuff-C74725.12435622022004@news.povray.org>
In article <40389d5e$1@news.povray.org>,
 Andrew C on Mozilla <voi### [at] devnull> wrote:

> > IMHO this comes down to 'pov ain't oo' - I don't think anyone denies 
> > that oo capabilities in pov wouldn't be at the very least interesting, 
> > but that's not the issue....
> 
> POV sure ain't OO. No doubt about it ;-)

Actually, it comes close in many ways. You transform all shapes and 
textures. You can texture all shapes. You can use the solid ones in CSG. 
It's a fixed heirarchy, but you could express it in terms of objects.

object

transformable:object

shape:transformable

solid_shape:shape


finite_solid_shape:solid_shape
sphere:finite_solid_shape
box:finite_solid_shape


infinite_solid_shape:solid_shape
plane:infinite_solid_shape


patch_shape:shape
bicubic_patch:patch_shape
triangle:patch_shape


pigment:transformable
solid_pigment:pigment {color}
patterned_pigment:pigment {pattern, color_map}


texture:transformable
patterned_texture:texture {pattern, texture_map}
plain_texture:texture {pigment, finish, normal}

and so on...

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 16:12:32
Message: <40391b40$1@news.povray.org>
> Which you have to call no matter what.

No you don't, there is always another way to write the code. That's my entire
point. If people have to think more when performing an operation which is more
complex than a simple "+" then hopefully they might some way to do something
simpler.

That is the nature of optimisation, doing the same things in a different way.

> Just be aware of what you're adding. It's no harder than keeping track
> of a bunch of methods named add(), mult(), etc, and the code is much
> easier to read.

The standards we use would be more like matrixAdd(), vectorAdd(), etc. That way
it is easier to keep track of because you are using different function names
according to what the back end is doing. This means you can search for them in
the code, which is a very useful feature.

> How is this so? If you need to add two matrices, you need to add two
> matrices.

Do you? What if you're adding two vectors? What if you're adding two vectors
before computing a dot product with another vector? it may be possible to do
this more efficiently by computing the dot product with each of the vectors and
then adding the results.

Code is malliable, nothing needs to be written a certain way. Our aim is to
write it in a more efficient way, and to write it in a way that makes it easier
to optimise later.

> > Heck, if were even remotely
> > feasible we'd write everything in assembler...
>
> No...then you run into the "can't see the forest for the trees" problem.

Uh, I did say "if it were remotely feasible". Obviously it isn't for the reason
you state there. However there is such a thing as too high level for any given
application, and the consensus amongst people I've worked with is that operator
overloading is a little too high level for the kind of code we write.

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 16:15:47
Message: <40391c03$1@news.povray.org>
> Why is this harder than "your webmaster was a fool. How do you find all
> the links to pages that don't exist?"

It's not, but our way's easier than that: You just search for the name of the
function (thereby getting cases that the compiler might not complain about
because it gives up early or some code might depend on a #define'd switch)

-- 
Tek
www.evilsuperbrain.com

"Darren New" <dne### [at] sanrrcom> wrote in message
news:4038f420$1@news.povray.org...
> Tek wrote:
> > How do you do that?
>
> You use the right tools. Heck, the compiler can tell, can't it?
>
> The trivial method is to change the name of the matrix multiply routine
> and see all the places where the compiler complains of missing functions.
>
> Why is this harder than "your webmaster was a fool. How do you find all
> the links to pages that don't exist?"
>
> -- 
> Darren New, San Diego CA USA (PST)
>    I am in geocentric orbit, supported by
>    a quantum photon exchange drive....


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 16:18:38
Message: <40391cae$1@news.povray.org>
>   You need to know about how a library function is implemented anyways,
> regardless of how it is called, if you want to make as optimal code as
> possible.

Which is easier to keep track of if it has a different name to all the other
library add functions. You can glance at the code and see what it's calling.

>   If you are using class instances you know that calling the operator+
> for them will (potentially) generate a function call. If you don't know
> that, you don't have business making highly-optimized hacker code.

But if you're looking at unfamiliar code how do you know if you're looking at
class instances? They could just be typedeffed ints. You need to find the
definition of the class, which takes longer than simply seeing what function
it's calling.

However, I note you have dodged my question, which I think is the crux of the
issue:

Right, lets say your product ships in two weeks time, and you've discovered that
the physics guy who got sacked last week was a moron. Hey, it happens. You need
to go through his code and find everywhere that he's performing a matrix*vector
multiply, in order to replace it with a more efficient piece of code.

How do you do that?

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 16:21:01
Message: <40391d3d@news.povray.org>
In article <4038f266$1@news.povray.org> , Darren New <dne### [at] sanrrcom>  
wrote:

> And in real languages, you don't even have to tell the compiler to do
> that. ;-)

You don't need to do in C++ either.  "inline" is only a hint to the compiler
just like the "register" keyword.  Most modern compilers will inline
whatever they see fit, and some will even completely ignore the "inline"
keyword and find a better selection of functions to inline.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 16:22:25
Message: <40391d91$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message news:4038bb04@news.povray.org...
> Tek <tek### [at] evilsuperbraincom> wrote:
> > We like the clunkier syntax *because* it is harder to use and requires more
> > thought from the programmer. In our situation this is a good thing.
>
>   Good luck trying to maintain and enhance such code in the future then.

What the heck do you think I've been doing for the last 5 years?!

I'm not talking about some nice theory on a strategy for writing code, I'm
telling you the way that we actually do it. You can disagree all you like, but
this approach *does* work.

In terms of maintenance, this approach again makes it easier to optimise code
(even code you're not familiar with) because you can always see at a glance what
functions are being called where. This is ugly and confusing information if you
are thinking purely in terms of theoretical algorithms, but in our world the
reason you are looking at the code is precisely to see that very information! We
put this extra info there not because it clutters the code, but because it is of
use to us.

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 16:24:03
Message: <40391df3@news.povray.org>
"Thorsten Froehlich" <tho### [at] trfde> wrote in message
news:4038be6e$1@news.povray.org...
> If you write games, you don't have to, I suppose.  All you need is a few
> patches later on when bad coding style produced plenty of bugs in the
> initial release version ;-)

I write console games, so actually we have to release stuff with less bugs in
than people in most fields of development (possibly banking and military
applications need even less bugs, but most fields get away with shoddy code).

We use this coding style because it helps us, not hinders us.

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 16:29:01
Message: <40391f1d$1@news.povray.org>
> __normal_iterator& operator++() { ++_M_current; return *this; }
>
> That's the ++ operator for one of the STL iterators. And it does make
> sense to do it this way...other operators have to do more complex
> things, but it still makes sense to have a ++ operator.

Damn, I'll grant you that's a good example :)

> > prevents people writing lines like a = b + 3*(c-d), which looks
> > perfectly innocent, but could be a major bottleneck.
>
> All the coder has to do is look at the types being worked on.

Which is not as easy as just looking at the name of the function being called. I
realise this sounds messy and cumbersome to you, but this "mess" is actually
information that we find useful for our application.

> And this
> still isn't an argument against the existance of operator overoading.

I never said it was!!!

I like operator overloading, I'm just explaining why we don't use it where I
work (or indeed at the last place I worked either).

> > We like the clunkier syntax *because* it is harder to use and requires more
> > thought from the programmer. In our situation this is a good thing.
>
> But it requires more thought about the wrong things...I don't see how it
> can help.

For us, these are not the wrong things, these are the things we want people to
think about. In most OO programming applications you want to free people to
think at a higher level, we do not. In fact we seldom even use objects and
inheritance, because we prefer to keep things at a lower level than that.

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 16:30:59
Message: <40391f93@news.povray.org>
> Game coding and movie special-effects both have the advantage that once
> released, you're likely to never look at the code again. (Well, at least
> until they started doing MMORPGs and such.)

Not true, we do sequels. Every game I've worked on has used elements of an
engine from an earlier game, so we try to write code that helps us do that. For
our applications it is more useful to see which function is being called than to
see a simpler looking piece of code that has a complex back end.

I guess what I'm saying is normal people look at a piece of code to work out
what it does, games programmers look at it to see how it does it.

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 17:09:26
Message: <cjameshuff-CF95A3.17100922022004@news.povray.org>
In article <40391f1d$1@news.povray.org>, "Tek" <tek### [at] evilsuperbraincom> 
wrote:

> > All the coder has to do is look at the types being worked on.
> 
> Which is not as easy as just looking at the name of the function 
> being called. I realise this sounds messy and cumbersome to you, but 
> this "mess" is actually information that we find useful for our 
> application.

I've written a raytracer using vectors that use operator overloading. It 
was much easier to see what the code did than it is in POV, which uses 
macros for the vector operations.


> > And this
> > still isn't an argument against the existance of operator overoading.
> 
> I never said it was!!!

Yes you did...in a reply to one of my earlier messages:

> > I am. I definitely would want operator overloading. I've never seen a
> > good argument against it..."you can make the plus operator multiply" is
> > not a good argument. I can make a "plus()" method that multiplies as
> > well...I can also do a lot of useful things with the ability to use
> > operators with my own types.
> 
> Well, I know a good argument against it. So good in fact that it's the reason
> why every games programmer I know doesn't use operator overloading: It hides
> processing.


> > But it requires more thought about the wrong things...I don't see how it
> > can help.
> 
> For us, these are not the wrong things, these are the things we want people 
> to think about.

If you don't know anything about optimization. You optimize the big 
things first, algorithms and specific bottlenecks. You do the smaller, 
more work for the return items later, if necessary. By forcing more 
focus on every little operation done, you make it more likely that some 
larger problem will go unnoticed, and you make the programmer waste time 
they could be spending doing actually useful optimizations.


> In most OO programming applications you want to free people to
> think at a higher level, we do not. In fact we seldom even use objects and
> inheritance, because we prefer to keep things at a lower level than that.

Frankly, I don't think you understand OO programming. Unless you use 
virtual functions, inheritance has zero overhead. If you have virtual 
functions, overhead is still miniscule. And abstracting things can be of 
great help in creating a tight, efficient module that is still both easy 
to use and understand. And I don't buy your argument about vector-matrix 
multiplication...if you're doing high-performance code, you should 
always be aware of the types you're working with.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 17:15:24
Message: <cjameshuff-24EA8C.17160622022004@news.povray.org>
In article <4038f726@news.povray.org>, Darren New <dne### [at] sanrrcom> 
wrote:

> Warp wrote:
> > Int foo = container.size(); // <- gets a *reference*
> > foo -= 100; // Ooops! The container breaks badly!
> 
> In this case, you'd make the -= operator return a new reference to be 
> assigned to foo.

You make the initial = create a copy. The actual copy operation may be 
done later, in the -= (copy on write), but from the point of view of the 
user of the code, the -= operator should modify the value of the object 
on the left hand side, not create a new one.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 17:22:44
Message: <cjameshuff-5DD27F.17232622022004@news.povray.org>
In article <4038f64d$1@news.povray.org>, Darren New <dne### [at] sanrrcom> 
wrote:

> > wouldn't you (unless you want to make the language so that it does
> > not support virtual functions, which would limit its OO capabilities
> > by a whole lot).
> 
> Well, then it wouldn't be OO at all, as you wouldn't have any dynamic 
> dispatch.

Oh? Objective C doesn't have anything called virtual functions. It has 
methods and messages instead. And they're not the same thing...the 
messaging model is a bit more flexible than the member function call 
model.


> > Someone will inevitably use it in the wrong way and his code can then
> > break with an updated version of the library.
> 
> Interestingly enough, C# actually addresses this problem. Nice language, 
> that.

Could you clarify this?
C# does sound like a good language from what I've heard, too bad it's 
MS-only.
(Don't say Mono...it's incomplete, and will always be so...its existance 
only gives people something to point at when claiming C# isn't MS-only.)


> That's actually what Eiffel does. You might want to look into it. It 
> even goes a step farther, in that it allows you to restrict (for 
> example) what values a child object is allowed to return from a member 
> function it overrides.

So the superclass can define that a method returns a real value between 
0 and 1, and subclass overrides must remain in that range? This is one 
of Eiffel's design-by-contract features, right?

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 17:31:22
Message: <40392dba$1@news.povray.org>
> I've written a raytracer using vectors that use operator overloading. It
> was much easier to see what the code did than it is in POV, which uses
> macros for the vector operations.

Well yes, I'm not debating that. I'm saying for what you're doing it's better to
deal with things on a cleaner more mathematical basis, but for what I do at work
it's better to deal with things on a more technical implementation-based level.

> > > And this
> > > still isn't an argument against the existance of operator overoading.
> >
> > I never said it was!!!
>
> Yes you did...in a reply to one of my earlier messages:

No, I said it was an argument against the *use* of operator overloading, not
it's existence. I'm not saying it should never be used, I'm just explaining why
we don't use it.

> If you don't know anything about optimization. You optimize the big
> things first, algorithms and specific bottlenecks. You do the smaller,
> more work for the return items later, if necessary.

Which still is not a reason to hide what the code is actually doing.

Besides, a good optimiser does neither of those, you begin by profiling the
system extensively to ascertain what is slow. It doesn't matter how cumbersome
the big concepts are, or how badly implemented the low level things are, all
that matters is how long things take.

> By forcing more
> focus on every little operation done, you make it more likely that some
> larger problem will go unnoticed,

This is a valid point, but you must see that this is a balance. Depending on
your needs you choose how high/low level you want to be. If you only care about
the simplest processes you work in assembler, if you care most about the overall
structure you code in OO. We have gravitated to a point a little above the
functionality supported by C, and a little below true OO C++. This is the
balance that works for us, but I do not suggest it is applicable to all
situations.

> And abstracting things can be of
> great help in creating a tight, efficient module that is still both easy
> to use and understand.

High level code can be very good for dealing with high-level concepts. And
certainly as the games become more sophisticated people move naturally to higher
level concepts. But at this point in time the people I have worked with feel
that we're still dealing with concepts best expressed by C-style code with just
a few C++ features.

> And I don't buy your argument about vector-matrix
> multiplication...if you're doing high-performance code, you should
> always be aware of the types you're working with.


But how do I gain this awareness if it's not my code? Last project I was on had
20 programmers, and I was one of the main people assigned to optimise things. It
was more important to me to see how the code worked at a lower level than to see
nice clean algorithms.

However I know there are other games companies that go all out for OO code,
because they wish to code at a higher level. They do not produce such efficient
code as we do :)

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Patrick Elliott
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 17:31:27
Message: <MPG.1aa2db602f53d3599899b6@news.povray.org>
In article <4037f302@news.povray.org>, war### [at] tagpovrayorg says...
> Patrick Elliott <sha### [at] hotmailcom> wrote:
> > But it can happen.
> 
>   Of course it can happen. And it can also happen that a function
> named "multiply" calculates the square root. But that doesn't mean
> it's not avoidable. It just means the design of the program/library
> has a flaw.
> 
But is it always a flaw?

For example, say you want to manipulate an image:

Fade(Object.DC)

function Fade(myDC AS DC ByRef)

Do you want Fade to have *only* the contents of the DC, which could be 
40x40 or 80x20 or even 1600x1? No, you pass it a reference to the DC, so 
you can manipulate the original contents.

You could also pass the DC to the function with it automatically making a 
copy by using it like:

Object.Image = Fade(Object.DC)

function Fade(myDC AS DC ByVal)

But you are performing two copies here, instead of just manipulating the 
actual data. This will take more time and added memory to accomplish. Why 
exactly do you think the first version is bad design? It makes a whole 
heck of a lot more sense that wasting extra processor cycles making 
copies, instead of performing the effect on the original image. Yes, this 
may not be the 'best' way in some case, but what if you do this:

set a = GetCompatibleDC(Object.DC)
Grayscale(a)
Fade(a)
FindEdges(a)
Object.DC = a

That eliminates 6 extra copy processes you have to make by passing the 
contents of the DC, instead of a reference to the one copy your actually 
needed. This is not *bad* library design.

-- 
void main () {
  If Schrödingers_cat is alive  
    call functional_code()
  else
    call crash_windows();
}


Post a reply to this message

From: Dan P
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 17:55:25
Message: <4039335d$1@news.povray.org>
"Tek" <tek### [at] evilsuperbraincom> wrote in message
news:40391d91$1@news.povray.org...
> "Warp" <war### [at] tagpovrayorg> wrote in message
news:4038bb04@news.povray.org...
> > Tek <tek### [at] evilsuperbraincom> wrote:
> > > We like the clunkier syntax *because* it is harder to use and requires
more
> > > thought from the programmer. In our situation this is a good thing.

Thank you, Warp. This has been a puzzle for me for some time now: why do so
many programmers write such awful code? At first, I thought it was because
they didn't want other programmers to understand it because they could be
replaced. Then, I figured it was just because they were engineers with no
sense of cognitive psychology. Finally, I read your message, and now I
understand it: these engineers are doing the world a /favor/ by making code
hard to read because it makes other programmers think more. I get it now!
It's alturism.

Don't send me a resume.


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 18:14:04
Message: <cjameshuff-ECDCA2.18144622022004@news.povray.org>
In article <40392ffb@news.povray.org>, Darren New <dne### [at] sanrrcom> 
wrote:

> Christopher James Huff wrote:
> > Oh? Objective C doesn't have anything called virtual functions.
> 
> They're not called that, but that's the effect. Messages are dynamically 
> dispatched to the appropriate method.

It's more than a different name for the same thing. Virtual functions 
are just function calls that are looked up at run-time through a virtual 
function table. Message lookup is based on a message selector that is 
itself a piece of data the program can manipulate. You can forward 
messages that you can't handle, for instance. You can even send them to 
objects on other machines. The overhead is higher, but surprisingly low. 
Virtual functions are just a specific implementation detail, not a core 
requirement for object oriented languages.


> I've found it useful to learn a bunch of different languages, if only to 
> understand useful paradigms, even if I never obtain a compiler for them.

I agree. If you don't keep learning new things, you'll end up being 
unable to.

BTW, have you ever looked at Dylan?

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 18:30:15
Message: <cjameshuff-CD5ABF.18305722022004@news.povray.org>
In article <4039335d$1@news.povray.org>,
 "Dan P" <dan### [at] yahoocom> wrote:

> > > > We like the clunkier syntax *because* it is harder to use and requires
> more
> > > > thought from the programmer. In our situation this is a good thing.
> 
> Thank you, Warp. This has been a puzzle for me for some time now: why do so
> many programmers write such awful code? At first, I thought it was because
> they didn't want other programmers to understand it because they could be
> replaced. Then, I figured it was just because they were engineers with no
> sense of cognitive psychology. Finally, I read your message, and now I
> understand it: these engineers are doing the world a /favor/ by making code
> hard to read because it makes other programmers think more. I get it now!
> It's alturism.
> 
> Don't send me a resume.

Warp didn't write that. And even if he had, your attack would have been 
completely unwarranted. Speaking as a member of the TAG, please stop 
these personal attacks, insults, and other anti-social behavior. Now.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 18:30:48
Message: <40393ba8$1@news.povray.org>
"Dan P" <dan### [at] yahoocom> wrote in message
news:4039335d$1@news.povray.org...
> Thank you, Warp.

Uh, I said that, not him.

> This has been a puzzle for me for some time now: why do so
> many programmers write such awful code?

It seems impossible for me to make a statement without people taking it too far!

I'm *not* saying all abstraction is evil and should be avoided, but I'm also
*not* saying everything should be abstracted as much as possible. I'm talking
about finding a balance between the two, according to the needs of your task.

There is never any excuse for writing code that is needlessly difficult to read,
such as many unproffessional coders like to do in the flawed belief that it
makes them look clever.

However, there is good reason to sometimes write code that makes it harder to
see the overall structure if doing so provides you with some other useful
information. Obviously a balance must be found and that balance is different for
different applications, but in my work it is useful to avoid a lot of
abstraction.

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 18:31:19
Message: <40393bc7$1@news.povray.org>
In article <cjameshuff-CF95A3.17100922022004@news.povray.org> , Christopher
James Huff <cja### [at] earthlinknet>  wrote:

> I've written a raytracer using vectors that use operator overloading. It
> was much easier to see what the code did than it is in POV, which uses
> macros for the vector operations.

In the source code you have access to it doesn't!

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Dan P
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 18:33:54
Message: <40393c62@news.povray.org>
"Tek" <tek### [at] evilsuperbraincom> wrote in message
news:40393ba8$1@news.povray.org...
> "Dan P" <dan### [at] yahoocom> wrote in message
> news:4039335d$1@news.povray.org...
> > Thank you, Warp.
>
> Uh, I said that, not him.
>
> > This has been a puzzle for me for some time now: why do so
> > many programmers write such awful code?
>
> It seems impossible for me to make a statement without people taking it
too far!

Oh, I'm sorry; I didn't think that sounded like you, Tek :-)


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 18:42:34
Message: <cjameshuff-D818AA.18431622022004@news.povray.org>
In article <40392dba$1@news.povray.org>, "Tek" <tek### [at] evilsuperbraincom> 
wrote:

> Well yes, I'm not debating that. I'm saying for what you're doing 
> it's better to deal with things on a cleaner more mathematical basis, 
> but for what I do at work it's better to deal with things on a more 
> technical implementation-based level.

No...I don't give a damn about the mathematics. It's just cleaner 
looking and easier to read with overloaded operators. Easier and faster 
to write and debug, giving me much more time to spend on optimization or 
extension of the program.


> > Yes you did...in a reply to one of my earlier messages:
> No, I said it was an argument against the *use* of operator overloading, not
> it's existence. I'm not saying it should never be used, I'm just explaining 
> why we don't use it.

Then why did you even reply to my message?


> Which still is not a reason to hide what the code is actually doing.

The only information hidden is that which isn't of any use to the 
situation anyway. You don't need to know exactly how vectors and 
matrices are multiplied, it is enough to know that doing so is 
time-consuming.


> Besides, a good optimiser does neither of those, you begin by 
> profiling the system extensively to ascertain what is slow. It 
> doesn't matter how cumbersome the big concepts are, or how badly 
> implemented the low level things are, all that matters is how long 
> things take.

I did mention "specific bottlenecks". How do you think those bottlenecks 
would be found, if not by profiling the program?


> > And I don't buy your argument about vector-matrix
> > multiplication...if you're doing high-performance code, you should
> > always be aware of the types you're working with.
> 
> But how do I gain this awareness if it's not my code?

You read the code.


> Last project I 
> was on had 20 programmers, and I was one of the main people assigned 
> to optimise things. It was more important to me to see how the code 
> worked at a lower level than to see nice clean algorithms.

You regularly have separate programmers coding and optimizing? That does 
not sound like a good idea...the person optimizing starts out knowing 
nothing about the code.
And again, it's not about "nice clean algorithms", it's "nice clean 
*code*" that lets you see what's being done!


> However I know there are other games companies that go all out for OO code,
> because they wish to code at a higher level. They do not produce such 
> efficient code as we do :)

Then they're doing it wrong. And what company do you work for? I never 
want to work there.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Dan P
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 18:42:53
Message: <40393e7d@news.povray.org>
"Christopher James Huff" <cja### [at] earthlinknet> wrote in message
news:cjameshuff-CD5ABF.18305722022004@news.povray.org...
> In article <4039335d$1@news.povray.org>,
>  "Dan P" <dan### [at] yahoocom> wrote:
>
> > > > > We like the clunkier syntax *because* it is harder to use and
requires
> > more
> > > > > thought from the programmer. In our situation this is a good
thing.
> >
> > Thank you, Warp. This has been a puzzle for me for some time now: why do
so
> > many programmers write such awful code? At first, I thought it was
because
> > they didn't want other programmers to understand it because they could
be
> > replaced. Then, I figured it was just because they were engineers with
no
> > sense of cognitive psychology. Finally, I read your message, and now I
> > understand it: these engineers are doing the world a /favor/ by making
code
> > hard to read because it makes other programmers think more. I get it
now!
> > It's alturism.
> >
> > Don't send me a resume.
>
> Warp didn't write that. And even if he had, your attack would have been
> completely unwarranted. Speaking as a member of the TAG, please stop
> these personal attacks, insults, and other anti-social behavior. Now.

That wasn't an attack, that was sarcasm. I apologize, Warp; I didn't realize
that wasn't you that said that. Chris, if you want to single me out, okay,
but this group is anything but friendly and I'm just as happy to remove it
from my newsgroups list as you are to remove me from it. Because I feel
personally attacked every time I write a message on this board, particularly
when I post code of any sort. Messages like, "You should read an OO book"
are pretty damned insulting and pretty damned personal so I ask you,
politely, to remove the double-standard when wielding your "big stick".


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 18:44:06
Message: <cjameshuff-5499E0.18444822022004@news.povray.org>
In article <40393bc7$1@news.povray.org>,
 "Thorsten Froehlich" <tho### [at] trfde> wrote:

> > I've written a raytracer using vectors that use operator overloading. It
> > was much easier to see what the code did than it is in POV, which uses
> > macros for the vector operations.
> 
> In the source code you have access to it doesn't!

In the currently final version, the version that everyone has access to, 
it does. ;-)

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 19:18:31
Message: <403946d7@news.povray.org>
Dan P <dan### [at] yahoocom> wrote:
> Because I feel
> personally attacked every time I write a message on this board, particularly
> when I post code of any sort. Messages like, "You should read an OO book"
> are pretty damned insulting and pretty damned personal so I ask you,
> politely, to remove the double-standard when wielding your "big stick".

  No, there's no conspiracy against you here.

  I don't tend to remember people names for negative things, but tend to
easily forget them. If I have a flamewar with someone and then it stops,
after a week or two I have probably already totally forgotten the name
of my "adversary". In fact, I wasn't completely sure if it was you whose
C code I commented when I responded with the OO things (and I didn't make
much effort remembering, for that matter).

  Although you might feel like it, this is not a place where regulars
select some newcomer at random and start attacking him as a team effort.
That would be completely silly.
  If you are receiving tons of negative responses, then think about why
that may happen. It's certainly not a conspiracy against you personally.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Dan P
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 19:22:57
Message: <403947e1$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:403946d7@news.povray.org...
> Dan P <dan### [at] yahoocom> wrote:
>
>   Although you might feel like it, this is not a place where regulars
> select some newcomer at random and start attacking him as a team effort.
> That would be completely silly.
>   If you are receiving tons of negative responses, then think about why
> that may happen. It's certainly not a conspiracy against you personally.

Actually, I think I am wired a little different. Here's an example: when you
said to someone, "If you don't know what operator+() does with the type you
are using, then you should seek another job, IMHO," I thought that was far
worse than anything I have ever said to anybody on here by at least a factor
of 10. I've never said you weren't qualified to do your job or even hinted
at it. In my response, I indirectly said that I wouldn't want you working
for /me/. But, I think you aren't using an active reference in your
sentence. What I mean by that is I read your message as, "You, poster, don't
know what the operator +() does and, therefore, you should seek another
job." What I think you must be saying, if it isn't insulting, is, "If some
person doesn't know whwat operator +() does with the type you are using,
then that person should seek another job." Even that could be taken the
wrong way, but it is not direct and, therefore, not an "attack".

I think we have different parsers and I'm going to have to adjust mine to
get along here. Plus, I felt way more negatively about what I thought you
were saying because I have to deal with that on a daily basis and it just
makes my job hard... I was emotional and /wrong/ for being so.

Can I get another chance at fixing my parser?


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 19:25:20
Message: <40394870@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> > And in real languages, you don't even have to tell the compiler to do
> > that. ;-)

> You don't need to do in C++ either.  "inline" is only a hint to the compiler
> just like the "register" keyword.  Most modern compilers will inline
> whatever they see fit, and some will even completely ignore the "inline"
> keyword and find a better selection of functions to inline.

  What I meant when I said that the operator function should be made
"inline" was that it should be implemented where it's declared (or
at least at the same visibility level).
  If the function is declared in a header file but implemented in a
separate object file then the compiler naturally can't inline it.

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 19:32:51
Message: <40394a33@news.povray.org>
Christopher James Huff <cja### [at] earthlinknet> wrote:
> Argh...forget about virtual functions. They are an artifact of C++, 
> which does everything statically by default. I specifically said no 
> static binding. No virtual functions, because everything is dynamically 
> bound.

  What do you mean "no virtual functions"? If every function is dynamically
bound, then *every* member function is virtual.

  At least you should be able to specify a default implementation for
a member function or live it as purely virtual.
  If you leave all the member functions as purely virtual, then what
you have is an interface.

> >   A class is abstract if it has pure virtual functions (that is,
> > the class does not implement the virtual function(s) and thus cannot
> > be instantiated because of this; it can only be used through
> > inheritance so that the derived class implements the virtual
> > function(s) in question).

> Again, I'm talking about single inheritance. Multiple inheritance is not 
> necessary, and is needlessly complex.

  Who is talking about multiple inheritance here? I'm not.

  And multiple inheritance may be complex from the point of view of
the interpreter/compiler, not from the point of view of the user.
Why should that be a limit?

> Abstract classes are not as useful 
> in single inheritance models, interfaces cover their functionality. 

  I don't understand what you are saying.
  Why have *two* types of classes when you can have just one?
And why abstract classes are not useful in single inheritance model?

> Interfaces render multiple inheritance + multiple abstract root classes 
> obsolete, not the other way around.

  Interfaces are a poor way of making multiple inheritance. They have
all the logical problems of multiple inheritance and they force you
to make code repetition.
  I have never understood what's so good about interfaces.

> >   That's right. *You*. But that's ok only for as long as you don't
> > distribute that library of yours containing public member variables...
> > Someone will inevitably use it in the wrong way and his code can then
> > break with an updated version of the library.

> That's their fault

  You can't design libraries with that principle.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 19:35:14
Message: <40394ac2@news.povray.org>
> Then why did you even reply to my message?

You said you'd never seen a good argument against it, I merely wanted to tell
you the argument against it that I've heard, since it was good enough to
convince the programmers I know. I never meant the argument was against operator
overloading being used by anyone, just against it being used in the environments
I've worked in. It was really only inteded as trivia, I never meant to spark
such a long discussion! :)

Though I confess at the time I heard the argument I knew far too little about OO
code, so I've failed miserably to convey the true convincingness of the original
discussion...

Well that's my excuse.

> The only information hidden is that which isn't of any use to the
> situation anyway. You don't need to know exactly how vectors and
> matrices are multiplied,

Yes, *I* do. That's what I'm saying. That's why we don't use operator
overloading, because we prefer to see the information that it hides.

> You regularly have separate programmers coding and optimizing?

Not exactly, but some of us can optimise a lot better than others. Besides we
believe everyone should write code in a way that anyone else can read, and for
our purposes that means at a lower level than true OO.

> Then they're doing it wrong. And what company do you work for? I never
> want to work there.

Naughty Dog, (Jak & Daxter, Crash Bandicoot, and the engine for Ratchett &
Clank), and until recently I worked for Codemasters (on the Toca series of
games). Just a few little multimillion selling titles, I'm sure we don't have a
clue what we're doing.

There are higher level languages and there are lower level languages, you have
to choose what you use according to the nature of what you do. The games
industry has progressed from Assembler to C to using some features of C++, but
(in our case) not all of them, because the nature of the games we develop is
gradually becoming more high level.

In the future we shall doubtless move to a more pure C++ style of code, but it
is naive to presume that assembler is simply inferior to C++. Higher level is
not necessarily better, it depends on the nature of the program you are
developing. We have chosen our level based on many decades of combined
experience of games development, and whilst I may not personaly be able to
explain all the reasons for this (since my OO experience is limitted) I think it
is foolish to assume these intelligent professionals would simply get it wrong.

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 19:40:01
Message: <40394be1@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> >   Interfaces are obsolete of you can make abstract classes.

> Technically, they're obsolete if you have decent multiple inheritance. 
> The benefit of a Java interface is that you can be a Stream *and* a 
> Thread *and* an Iterator.

  Supposing you are happy with the fact that you must implement every
single method of Stream, Thread and Iterator in every single inherited
class... You can't group common functionality in the interfaces.

  This is one thing which I have never understood (and probably never
will) about interfaces: They *force* you to perform one of the basic
sins in programming: Code repetition.
  I thought Java was designed to force the programmer to make good
code, not bad code. *sigh*

  Besides, multiple inheritance was not included in Java because you
can use it "in the wrong way" (same song as with every non-included
feature in Java).
  How can you use multiple-inheritance in the wrong way? Well, one
classical example is that you have a Boat class and a Plane class
and you multiple-inherit a Hydroplane class from them. This is
bad OO design (mainly because a Hydroplane is not a boat).
  Well, make a Boat interface and a Plane interface and make
a Hydroplane class which implements them. What's the difference?

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 19:43:46
Message: <40394cc2$1@news.povray.org>
> Actually, I think I am wired a little different. Here's an example: when you
> said to someone, "If you don't know what operator+() does with the type you
> are using, then you should seek another job, IMHO," I thought that was far
> worse than anything I have ever said to anybody on here by at least a factor
> of 10.

Yeah, speaking as the recipient of that comment, I did find it a little uncalled
for. I'm not sure whether Warp was trying to suggest I'm an idiot or simply
assuming that myself and every professional games programmer I know fails to
understand how to write code, but in either case I think he was out of line.

Though my policy is that I don't tend to take offence unless it's a direct
insult. i.e. if you actually think I'm an idiot but you don't say so then we
should get along just fine.

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 19:44:30
Message: <40394cee@news.povray.org>
Christopher James Huff <cja### [at] earthlinknet> wrote:
> > Int foo = container.size(); // <- gets a *reference*

> No, that initializes an Int named foo to the object returned by 
> container.size. Not a problem.

  And what if you *do* want a reference to the member variable?
You can't?

  (One common situation where you want to do this eg. in C++ is when
you have a big container inside another container and you return
a const reference to the internal container; this way the big internal
container is not needlessly copied, which would be inefficient, but you
can read it directly.)

> You could also introduce const references...not sure if its worth the 
> trouble.

  I think they are useful, as I mentioned above.
  Don't know what would be a practical syntax, though.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 19:53:17
Message: <40394efd@news.povray.org>
Tek <tek### [at] evilsuperbraincom> wrote:
> Yeah, speaking as the recipient of that comment, I did find it a little uncalled
> for. I'm not sure whether Warp was trying to suggest I'm an idiot or simply
> assuming that myself and every professional games programmer I know fails to
> understand how to write code, but in either case I think he was out of line.

  Nope, it was not directed at you personally.

  From what I understood, you said something in the lines of "I don't want
to hide a complex operation behind an overloaded operator because then
someone else could use that operator in the wrong way, not knowing what
it really does".
  To that I responded basically "if this someone" (ie not you) "uses your
library for some time-critical application and does not know what the
operator does, then he is in the wrong business".
  What I meant is that it's not your fault if someone uses your library
in the wrong way without taking care of knowing which functions are heavy
and which aren't.
  You can, of course, design the public interface of your library in
such way that even less aware coders are warned about a possible
inefficiency, and I fully understand this ideology. I just opposed
the idea of avoiding operator overloading in all cases.

  So no, I was not directing any insult or anything else against you
personally.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Dan P
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 19:56:56
Message: <40394fd8@news.povray.org>
"Tek" <tek### [at] evilsuperbraincom> wrote in message
news:40394cc2$1@news.povray.org...
> > Actually, I think I am wired a little different. Here's an example: when
you
> > said to someone, "If you don't know what operator+() does with the type
you
> > are using, then you should seek another job, IMHO," I thought that was
far
> > worse than anything I have ever said to anybody on here by at least a
factor
> > of 10.
>
> Yeah, speaking as the recipient of that comment, I did find it a little
uncalled
> for. I'm not sure whether Warp was trying to suggest I'm an idiot or
simply
> assuming that myself and every professional games programmer I know fails
to
> understand how to write code, but in either case I think he was out of
line.
>
> Though my policy is that I don't tend to take offence unless it's a direct
> insult. i.e. if you actually think I'm an idiot but you don't say so then
we
> should get along just fine.

As I think more and more about this (I went for a drive to cool off), I
realize what is happening and what I'm doing wrong. I came on these groups
initially because I just made a move to an apartment where I'm isolated and
I needed some social interaction. I felt that, by coming on to a board where
I felt I could contribute, I would fill that need. Colored by the fact that
I am easily at the lowest point in my life of nothing but low points, I
didn't come in with a very thick skin to begin with.

It wasn't your commentary on my code, Warp, that made me angry initially -- 
it was when you supported Thorsten's personal attack on me that made me
angry with you. I've learned a lot from your critique and I feel honored
that you took the time to teach me how to do it right. Proof's in the thread
on my claim there.

Truth is, almost every one of the messages on this board makes me sad in
some way. Disrespect makes me feel sad -- not even angry, just sad, which
turns to anger when I start to rebel against it. I can't afford to be sad
and it is coloring how I read things and not in a good way. There are povray
boards that are making me happy, however, so I've decided to desubscribe to
this group and stick to the boards that make me happy. I'm not lurking -- 
not expecting a response -- Chris, you don't have to kill-file me -- I'm not
going to post here again.

For what it's worth, please accept my sincerest apologies for walking in and
stirring things up.


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 20:12:01
Message: <40395361@news.povray.org>
>   To that I responded basically "if this someone" (ie not you) "uses your
> library for some time-critical application and does not know what the
> operator does, then he is in the wrong business".

Ah, I see. Yes, that is not an insulting statement to make, I simply
misinterpretted your meaning.

However, I find in my line of work that if you have to rely on people being able
to write good code, you will get an inferior result. We find these practices
make our style of coding easier, hence we use them. For more high-level
applications this approach would bog things down too much.

>   So no, I was not directing any insult or anything else against you
> personally.

In that case I shall stick to my policy of generally not interpretting anything
as an insult :)

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 21:15:41
Message: <cjameshuff-7413DB.21162322022004@news.povray.org>
In article <40394a33@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   What do you mean "no virtual functions"? If every function is dynamically
> bound, then *every* member function is virtual.

No. Virtual function tables are an implementation detail, the 
implementation specifically used by C++. There are other ways of 
implementing dynamic dispatch.


> > Again, I'm talking about single inheritance. Multiple inheritance is not 
> > necessary, and is needlessly complex.
> 
>   Who is talking about multiple inheritance here? I'm not.

You're implying it. You say abstract classes can replace interfaces. A 
class can have multiple interfaces, but in single interface models can 
only inherit from one class. Therefore, I figured you must be talking 
about multiple inheritance, because nothing else made sense.


>   And multiple inheritance may be complex from the point of view of
> the interpreter/compiler, not from the point of view of the user.
> Why should that be a limit?

Look at virtual inheritance and why it's necessary.


>   I don't understand what you are saying.
>   Why have *two* types of classes when you can have just one?

I never said anything about two class types...I have no idea how you're 
reading what I'm trying to say. 


> And why abstract classes are not useful in single inheritance model?

Because you can only inherit from one.


> > Interfaces render multiple inheritance + multiple abstract root classes 
> > obsolete, not the other way around.
> 
>   Interfaces are a poor way of making multiple inheritance. They have
> all the logical problems of multiple inheritance and they force you
> to make code repetition.

They do not have all the problems of multiple inheritance. And a 
language could have default implementations for interfaces. Java is not 
an example of a perfect, or even very good OO language.


>   I have never understood what's so good about interfaces.

They avoid many of the problems of multiple inheritance.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 21:21:58
Message: <403963c6@news.povray.org>
In article <40394870@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

>   If the function is declared in a header file but implemented in a
> separate object file then the compiler naturally can't inline it.

You would be surprised what some modern compilers can do if you care neither
about memory usage nor compilation time...

    Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 22 Feb 2004 21:26:22
Message: <cjameshuff-B0997F.21270522022004@news.povray.org>
In article <403947c4@news.povray.org>, Darren New <dne### [at] sanrrcom> 
wrote:

> OK, honestly, I misspoke. Folks were talking about C++ style 
> programming, and said something about lacking virtual functions. I 
> equated that to lacking dynamic dispatch, because that was kind of the 
> environment it was discussed in. The only dynamic dispatch in C++ is 
> virtual functions (or pointers to functions).

Ok, I was just talking about OO in general, not narrowing it down to a 
specific implementation.


> Sure, messages and methods are more than virtual functions. Objective-C 
> basically took the messaging model from Smalltalk and pasted it on top of C.

That's basically it. Works pretty well, actually, though it does look 
funny...and no blocks, unfortunately. There is the concept of "higher 
order messaging" that might take their place...


> > Virtual functions are just a specific implementation detail, not a core 
> > requirement for object oriented languages.
> 
> Correct. But I'd contend that dynamic dispatch (i.e., the same name used 
> at the same point in the program meaning different invocations at 
> different times in the execution of the program) is a core requirement.

I agree.


> > BTW, have you ever looked at Dylan?
> 
> No, but I've used Smalltalk. What's unique about Dylan that I should 
> look at it? :-)

Well, the name is an abbreviation of "Dynamic language". It's object 
oriented and very, well, dynamic. You mentioned Eiffel and said some 
things that made me think you were familiar with Smalltalk, so I thought 
you might know about Dylan...I don't know a lot about it myself, but it 
looks interesting. Hmm...
http://directory.google.com/Top/Computers/Programming/Languages/Dylan/
http://www.cetus-links.org/oo_dylan.html

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 23 Feb 2004 01:07:38
Message: <403998aa$1@news.povray.org>
"Thorsten Froehlich" <tho### [at] trfde> wrote in message
news:403963c6@news.povray.org...
> In article <40394870@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:
>
> >   If the function is declared in a header file but implemented in a
> > separate object file then the compiler naturally can't inline it.
>
> You would be surprised what some modern compilers can do if you care neither
> about memory usage nor compilation time...

We enabled link time code generation on the last project I worked on, it made
the game a huge amount faster, and made the link time REALLY slow. Like over 5
minutes just for incremental builds. Nasty. Still a good thing to do on the
final build.

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 23 Feb 2004 05:40:44
Message: <4039d8ac@news.povray.org>
Tek <tek### [at] evilsuperbraincom> wrote:
> Ah, I see. Yes, that is not an insulting statement to make, I simply
> misinterpretted your meaning.

  I sometimes write things a bit hastily without re-reading them and
thinking if they could be understood in a different way than what I'm
thinking.

> However, I find in my line of work that if you have to rely on people being able
> to write good code, you will get an inferior result. We find these practices
> make our style of coding easier, hence we use them. For more high-level
> applications this approach would bog things down too much.

  I just took the "operator overloading is not good" part of your text
and answered to that... :)

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 23 Feb 2004 05:50:02
Message: <4039dada@news.povray.org>
Christopher James Huff <cja### [at] earthlinknet> wrote:
> >   I don't understand what you are saying.
> >   Why have *two* types of classes when you can have just one?

> I never said anything about two class types...I have no idea how you're 
> reading what I'm trying to say. 

  I can't see interfaces as anything else than very limited classes.

  For example, in Java I see two types of classes: The regular ones
and the extremely limited ones which they call "interfaces".
  What I wonder is why have two types of classes like this when just
one type suffices? IMO interfaces cause more problems than they avoid.

> > And why abstract classes are not useful in single inheritance model?

> Because you can only inherit from one.

  So basically what you want is to support multiple inheritance, but
without the possibility of grouping common functionality to the
"base classes" (ie. "interfaces" in this case) but forcing the inherited
classes to implement everything again and again?

> >   I have never understood what's so good about interfaces.

> They avoid many of the problems of multiple inheritance.

  From the compiler's point of view or the programmer's point of view?

  Can you present a good example?

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 23 Feb 2004 05:57:53
Message: <4039dcb1@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> Right. But if you can't do multiple inheritance, you can't do that with 
> abstract classes either. Interfaces don't replace abstract classes, they 
> replace multiple inheritance. Abstract classes without multiple 
> inheritance is not a replacement for interfaces, either.

  But why forbid multiple inheritance?
  Everyone talks about multiple inheritance like it was a scary monster.
I have never understood why. All the examples of bad usages of multiple
inheritance are of the same type as how regular inheritance can be
used wrongly or how operator overloading can be used wrongly. Or what
the heck, how variable names can be used wrongly.

  As with all those other features, multiple inheritance is a very
powerful and useful feature when you know how to use it right.
  This is one reason why I hate Java: By trying to "protect" inexperienced
programmers they have taken away useful features from experienced ones who
know how to use the features right. My attitude with Java is "yes, I know
how things can be used wrongly, but I'm not going to, so give me the damn
features, ok?"

> >   This is one thing which I have never understood (and probably never
> > will) about interfaces: They *force* you to perform one of the basic
> > sins in programming: Code repetition.

> Well, more like they make it easier for the compiler-writer.

  So the maker of the compiler is simply lazy? ;)

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 23 Feb 2004 18:18:50
Message: <403a8a59@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> >   So basically what you want is to support multiple inheritance, but
> > without the possibility of grouping common functionality to the
> > "base classes" (ie. "interfaces" in this case) but forcing the inherited
> > classes to implement everything again and again?

> Right. It avoids a fairly wide range of problems, both semantic and 
> efficiency.

  So because the makers of the compiler are lazy they force the
user of the language to make bad code?

  C++ does multiple inheritance quite efficiently, and even if it didn't,
why should it matter? You just need to know how heavy multiple inheritance
is and then decide whether to use it or not in your application. However,
if you have a place where it would be extremely useful then it's good that
you have the possibility.
  One could argue that virtual functions are inefficient because they
produce internally an indirect function call (subroutine call to an
address got from behind a pointer got from behind a pointer), which
potentially make them slightly slower than regular function calls.
Does this mean virtual functions should be left out? Of course not.
You just need to be aware of what they do.

> Also, diamond-shaped inheritance is problematic, semantically speaking.

> For one: If D inherits from B and C, and both B and C inherit from A, 
> and A declares instance variables, how many copies of that instance 
> variable show up in D?

  Diamond-inheritance is truely rare, so if you want to forbid that
special situation IMHO you can. However, don't forbid *all* multiple
inheritances because of one specific case.
  In C++ if you want the base class to appear only once in the
bottommost inherited class in diamond-inheritance, you can make
the member variables of the base class virtual.

> A is a vehicle
> B is a plane
> C is a boat
> D is a hydroplane

  That was a classical example of bad OO design, so I don't think you
should be using it to demonstrate your point. ;)

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 23 Feb 2004 18:21:26
Message: <403a8af6@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> >   But why forbid multiple inheritance?

> Because it's difficult to get right. See my other post.

  We have used multiple inheritance in our project without the
slightest problems. I don't see what's so wrong with it.

  (In fact, we use it in places where the base classes from which you
are multiple-inheriting from act more or less like interfaces. The good
thing is, however, that these "interfaces" can and do have default
implementations for certain things and internally they form their own
inheritance hierarchy, which makes maintaining them easier.)

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 23 Feb 2004 18:22:39
Message: <cjameshuff-1806B5.18232323022004@news.povray.org>
In article <40394cee@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

> Christopher James Huff <cja### [at] earthlinknet> wrote:
> > > Int foo = container.size(); // <- gets a *reference*
> 
> > No, that initializes an Int named foo to the object returned by 
> > container.size. Not a problem.
> 
>   And what if you *do* want a reference to the member variable?
> You can't?

No...then you declare a reference to it. For example, Sapphire has two 
forms of the syntax for declaring variables:

def foo: bar; //declares foo as a reference to bar

def foo = bar; //declares foo as a reference to a copy of bar


> > You could also introduce const references...not sure if its worth the 
> > trouble.
> 
>   I think they are useful, as I mentioned above.
>   Don't know what would be a practical syntax, though.

And it does complicate the language. Remember that this is a scene 
description language...

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Object Oriented POV code
Date: 23 Feb 2004 18:31:52
Message: <403a8d68@news.povray.org>
Christopher James Huff <cja### [at] earthlinknet> wrote:
> >   And what if you *do* want a reference to the member variable?
> > You can't?

> No...then you declare a reference to it. For example, Sapphire has two 
> forms of the syntax for declaring variables:

  What if you want to make your class secure so that the user can't
break it?
  This may happen by accident (ie. the user doesn't realize what he
is doing), not necessarily by a malign coder.

> And it does complicate the language. Remember that this is a scene 
> description language...

  That doesn't mean it shouldn't be made secure.

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 23 Feb 2004 19:05:31
Message: <cjameshuff-6D99E8.19061623022004@news.povray.org>
In article <403a8d68@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

> > No...then you declare a reference to it. For example, Sapphire has two 
> > forms of the syntax for declaring variables:
> 
>   What if you want to make your class secure so that the user can't
> break it?
>   This may happen by accident (ie. the user doesn't realize what he
> is doing), not necessarily by a malign coder.

Then don't return a direct reference. You could return a proxy that 
doesn't implement modification operations, but otherwise behaves like 
the object referred to. You get the benefits of returning a member 
without a long copy operation, and that member is still protected from 
modification. Of course, this is basically doing what language-level 
constant references would do, and isn't much simpler...


> > And it does complicate the language. Remember that this is a scene 
> > description language...
> 
>   That doesn't mean it shouldn't be made secure.

It does mean it should be made as simple as feasible. Lack of constants 
hasn't done much harm in POV-Ray.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 23 Feb 2004 22:32:43
Message: <cjameshuff-391F89.22332723022004@news.povray.org>
In article <4039dada@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

> > I never said anything about two class types...I have no idea how you're 
> > reading what I'm trying to say. 
> 
>   I can't see interfaces as anything else than very limited classes.

Because you're stuck in thinking about things in terms of C++...I think 
it'd help you to learn a few more object-oriented languages.


>   For example, in Java I see two types of classes: The regular ones
> and the extremely limited ones which they call "interfaces".
>   What I wonder is why have two types of classes like this when just
> one type suffices? IMO interfaces cause more problems than they avoid.

Like? And don't say anything about the lack of default implementations, 
that's Java-specific. I'm talking about the concept of interfaces in 
general. I see it as being much like structured programming...rather 
than one construct that can do anything with complex enough code, you 
have restricted constructs that do specific jobs. It makes the intent of 
the code clearer, and makes the language easier to learn and understand, 
IMO at least. I also think languages should make more use of delegation 
and composition...


>   Can you present a good example?

At the moment, no. Nothing other than diamond inheritance, anyway. I'll 
try to get a good example...

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Object Oriented POV code
Date: 24 Feb 2004 05:05:12
Message: <403b21d8$1@news.povray.org>
In article <403a9f16$1@news.povray.org> , Darren New <dne### [at] sanrrcom>  
wrote:

> If you're asking "Why do X?" when you really mean to say "I
> don't think X should be necessary", you should phrase it differently.

You should learn when to interpret as question as a rhetorical question.
usually a good hint to interpret a question this way is when the person
continues to give an answer to it.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

<<< Previous 50 Messages Goto Latest 50 Messages Next 29 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.