Welcome to the Java Programming Forums


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.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

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

  1. #1
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default 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)


  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

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

    Quote Originally Posted by Ada Lovelace View Post
    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 a look at the Unsafe class. It allows for direct memory management.
    Link: Java Magic. Part 4: sun.misc.Unsafe - mishadoff thoughts
    But as the name suggests its, well, unsafe...

    Quote Originally Posted by Ada Lovelace View Post
    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.


    Quote Originally Posted by Ada Lovelace View Post
    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.

    Just my personal opinion on this matter.

Similar Threads

  1. Image Processing in Java
    By java_novice in forum Java Theory & Questions
    Replies: 6
    Last Post: April 1st, 2014, 11:23 PM
  2. Manual Memory Management
    By iPick12 in forum Java Theory & Questions
    Replies: 2
    Last Post: February 22nd, 2013, 12:08 PM
  3. Manual Events @ Robotix 2013,IIT Kharagpur
    By payal_priya in forum The Cafe
    Replies: 0
    Last Post: December 11th, 2012, 01:22 PM
  4. Replies: 0
    Last Post: June 23rd, 2012, 12:57 AM
  5. Netbeans User Manual
    By systech44 in forum Java IDEs
    Replies: 1
    Last Post: December 8th, 2009, 12:56 PM