The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

What if Java had manual pointer processing...

Just thought I would throw this up in the air as a convocation piece.

I know Java is a managed language, and all pointer operations are done in-house by the GC,
but let's (for fun) Assume the creators of the language had thought "y;know what? Let's put
manual memory allocation in!"

Would it scare some people off learning the language in general? I mean C# "does" have pointers
but only in an unsafe context. (I bring C# up as it is quite close to Java). Would applications be
able to run faster? Take video games for example, if the GC has to reallocate memory for each
FPS or module or event, the game would lag badly or run extremely slowly.

I mean for example:

// Note this is totally made up code syntax as pointers do not physically exist in Java
protected class Client {
protected String Player;
public Client()
{
Player *ply = new Player(150);
}
}

Let's assume that code allocates 150 indexes of memory to the object *ply.
If that object was manually managed, would it preform better or worse?

Just an observation here. The bottom line is, people argue that the GC is slower
than Manual memory - but I think if used correctly (i.e do not go over the index bounds of an
array) then there is nothing wrong with it.

Any thoughts?

Wishes Ada xx

If to Err is human - then programmers are most human of us all."The Analytical Engine offers a new, a vast, and a powerful language . . .
for the purposes of mankind."
— Augusta Ada Byron, Lady Lovelace(1851)

Re: What if Java had manual pointer processing...

Originally Posted by Ada Lovelace

Just thought I would throw this up in the air as a convocation piece.

I know Java is a managed language, and all pointer operations are done in-house by the GC,
but let's (for fun) Assume the creators of the language had thought "y;know what? Let's put
manual memory allocation in!"

Take video games for example, if the GC has to reallocate memory for each
FPS or module or event, the game would lag badly or run extremely slowly.

Thats just an assumption of you. You can very well code complex 3D games with java without any lag. The trick is to do it right.
Look, for example, at libGdx which is a somewhat more advanced gaming library. There are many games out there which utilize it without having any problems with performance.
Java has become incredibly fast today, there are some java programs which run as fast as C++ because of the great work the JIT usually does.

Originally Posted by Ada Lovelace

Let's assume that code allocates 150 indexes of memory to the object *ply.
If that object was manually managed, would it preform better or worse?

Just an observation here. The bottom line is, people argue that the GC is slower
than Manual memory - but I think if used correctly (i.e do not go over the index bounds of an
array) then there is nothing wrong with it.

Any thoughts?

Wishes Ada xx

We should really be looking at the future and how to advance programming. Pointers are a relic and working with them quickly becomes a real pain arguably.
Instead of trying to go backwards and re-introduce them we should make sure there is no need for them in the future, and I think java is doing a great job here.