POV-Ray : Newsgroups : povray.off-topic : Games programmers : Re: Games programmers Server Time
10 Oct 2024 15:14:33 EDT (-0400)
  Re: Games programmers  
From: Nicolas Alvarez
Date: 12 Sep 2008 17:01:58
Message: <48cad8c6@news.povray.org>
Invisible wrote:
> You know what? In Java, if you reference a null pointer, a little
> message pops up that says "hey, you just dereferenced a null pointer".
> And it even tells you where it happened. In C, your program just behaves
> bizarely.

In Java, if you deference a null pointer, it throws a NullPointerException
which basically kills your program if you don't catch it anywhere (and
usually you shouldn't).

In C, your program immediately segfaults, and if it was running under a
debugger you get the line of code where it did. Or at least the address of
the code it was executing.

> Java has a seperate Boolean type, so you can tell when a function
> returns a numer and when it returns a Boolean. (And you don't have to
> memorise whether 0 is true or false. And if you accidentally try to use
> a number where a Boolean is expected, the compiler *tells* you about
> this. And...)

C++ has a bool type. Although it's easy to accidentally convert it to a
number (true + true isn't a compiler error).

> Memory leaks? What memory leaks? No dangling pointers here either.

In Java, you're leaking memory all the time (quote from Warp), and the
runtime environment is trying to clean up the mess behind you. Forgetting
to set a reference to null when you don't plan to use it anymore would keep
it from being cleaned up, and would cause the same effect as not freeing
memory in C/C++.

C++ doesn't need garbage garbage collection because it generates so little
garbage (quote from Bjarne Stroustrup).


Post a reply to this message

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