|
![](/i/fill.gif) |
"Warp" <war### [at] tag povray org> wrote in message
news:4035e6de@news.povray.org...
> Dan P <dan### [at] yahoo com> wrote:
> > To create the object dynamically without the new keyword, the
interpreter
> > would need to look up whether what proceeds it is a Class or something
that
> > the user already defined. That would not effect small scenes, but in
scenes
> > with hundreds of thousands of objects, it would show in the parse time.
By
> > using new, the interpreter /knows/ that what follows it is a class.
>
> Believe it or not, there are faster ways of searching than linear
search.
Yep, I know; I spent an entire summer building AVL trees and heaps. But it
is /still time/ and, in a loop, that time adds up.
> Even if you have 4000 millions of names, you can find a specific one
> by doing at most 32 comparisons.
> In the same way, adding a new name to the set of existing names requires
> at most 32 comparisons and other operations.
32 comparisons for /one lookup/. Multiply that by, say, 100,000 lookups for
fur.
> Besides, what does it help to tell the interpreter that "what follows is
> a type"? By that you can at best just cut the amount of items to search
> to half (to 2000 millions in the example above).
In a loop, that makes a difference.
> > I think it would be a really good idea to make everything an instance of
a
> > class.
>
> There's a reason why in Java everything is not an instance of a class.
I think everything should have been. It was just a programmer's decision to
do that, probably because of their C/C++ experience. However, it is
certainly true that if all primitives were represented by a class, it would
take more memory, and even though it might only take a slight bit more
memory, with hundreds of thousands of instances that can show as well so it
might be a good idea to use primitives in a ray-tracing context anyway.
Post a reply to this message
|
![](/i/fill.gif) |