Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

OpenGL programing with Java question

Options
  • 27-08-2003 9:51pm
    #1
    Closed Accounts Posts: 288 ✭✭


    I've started to research OpenGL in the hope of starting a personal project in the near future.

    It seems from what I've read, that OpenGL is designed for use by C/C++ programers.

    I'm going into my third year of a computer science degree and I've only studied Java and VB.

    My question is:
    Do you think it would be worth my while to learn C++, seening how it's not that much different to Java, and use that for any OpenGL programing or will I just stick with Java, cause thats what I know?

    The reason I ask is I don't want to go with, say, java and then later realise that C++ would of been a better choice because theres much more suport on the internet: tutorials, source code examples, people to ask etc.


Comments

  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    C++ is, and has been for quite some time the most popular language for developing high performance games, but that's not to say it's the only option. Using JNI, it is possible to implement the OpenGL API in Java.

    Have a look at: http://www.jausoft.com/gl4java.html

    All I'll say is that it's quite strange to observe high performance 3D rendering in the likes of an applet. Everything around the applet on the page looks so out of place. Anyway you'll see what I mean when you get up and running.

    NeHe has Java-OpenGL tutorials on his site also.

    ;-phobos-)


  • Registered Users Posts: 4,676 ✭✭✭Gavin


    Personally I'd go the for C++, simply because you haven't done it before and it will be a good way of learning it. A computer graduate will need to know how to program in c++

    Gav


  • Closed Accounts Posts: 288 ✭✭TARE


    I was thinking that myself Verb, could you or anyone else sujest a good C++ book?


  • Registered Users Posts: 4,676 ✭✭✭Gavin


    C++ How to program by Deitel & Deitel is an excellent book. Covers quite a range of stuff, and is useful enough as a reference as well.

    Gav


  • Registered Users Posts: 2,586 ✭✭✭gerire


    Dietel and Dietel book for c++ is very good, but more importantly dont forget to get the OpenGl red book, aka ogl bible.

    'OpenGL programming guide' Woo, Neider, Davis, Shreiner


  • Advertisement
  • Registered Users Posts: 491 ✭✭Silent Bob


    There are OpenGL bindings being produced for Java https://games.dev.java.net/


  • Closed Accounts Posts: 2,319 ✭✭✭sci0x


    Thinking in C++ 2nd Edition by Bruce Eckel


  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    Bruce Eckel is the man!


  • Closed Accounts Posts: 2,319 ✭✭✭sci0x


    Originally posted by TARE
    I've started to research OpenGL in the hope of starting a personal project in the near future.

    It seems from what I've read, that OpenGL is designed for use by C/C++ programers.

    I'm going into my third year of a computer science degree and I've only studied Java and VB.

    My question is:
    Do you think it would be worth my while to learn C++, seening how it's not that much different to Java, and use that for any OpenGL programing or will I just stick with Java, cause thats what I know?

    The reason I ask is I don't want to go with, say, java and then later realise that C++ would of been a better choice because theres much more suport on the internet: tutorials, source code examples, people to ask etc.

    Definitely learn C++, it has been and will remain industry standard (let's just face facts) for years to come. As far as one being better than the other, there is no reason to argue that either. They both have their place in the industry. Java cannot compete with C++ in terms of speed and C++ cannot compete with Java's portability (though it can try).

    If you want to learn OpenGL or do any programming with real games (not flash, shockwave or applets) then you will need to have an understanding of C++.


  • Closed Accounts Posts: 22 gerald


    They both have their place in the industry

    I do not know for Java, but I find it quite amazing that the industry keeps using (Or people keep recommending ) languages such as C and C++, which are responsibles for numerous security flaws and other bugs.


  • Advertisement
  • Registered Users Posts: 491 ✭✭Silent Bob


    Originally posted by gerald
    I do not know for Java, but I find it quite amazing that the industry keeps using (Or people keep recommending ) languages such as C and C++, which are responsibles for numerous security flaws and other bugs.
    That's just silly. People are responsible for security flaws and bugs.

    A C/C++ compiler will let you do whatever you want to do, it won't hold your hand though. It is up to you to write correct code when using these languages.


  • Closed Accounts Posts: 120 ✭✭test999


    You have obviously never supported a real product, which has to be portable and has to be tested on jdk1.1 jdk1.2 jdk1.3 jdk1.4, blah blah, portable my arse. In what way is it portable when compared to C++? What platform doesn't have a fully standards compliant C++ compiler? all of them do! and at least you only have to test it on each platform only once.

    The only advantage of Java is this regard it ease of deployment for patches, updates, etc.

    QUOTE]Originally posted by sci0x
    Definitely learn C++, it has been and will remain industry standard (let's just face facts) for years to come. As far as one being better than the other, there is no reason to argue that either. They both have their place in the industry. Java cannot compete with C++ in terms of speed and C++ cannot compete with Java's portability (though it can try).

    If you want to learn OpenGL or do any programming with real games (not flash, shockwave or applets) then you will need to have an understanding of C++.
    [/QUOTE]


  • Closed Accounts Posts: 22 gerald


    A C/C++ compiler will let you do whatever you want to do, it won't hold your hand though. It is up to you to write correct code when using these languages.

    Unfortunately, humans make mistakes. I have yet to see a consequent program written in these languages, which does not have (or will have) a buffer overflow.

    A compiler, which does not provide bound-checking should be forbidden by law. We would have avoided the current state of the IT industry, which so warmly recommends these languages.

    I am sorry you found that my post was silly. I find it more silly that people are running every day to apply thousand of patches, when they are available.


  • Registered Users Posts: 16,413 ✭✭✭✭Trojan


    http://developers.sun.com/solaris/articles/secure.html
    Originally posted by Silent Bob
    That's just silly. People are responsible for security flaws and bugs.

    A C/C++ compiler will let you do whatever you want to do, it won't hold your hand though. It is up to you to write correct code when using these languages.


    NRA line ... "Guns don't kill people, people kill people".

    I don't agree with you either.

    Al.


  • Registered Users Posts: 491 ✭✭Silent Bob


    All I'm saying is that blaming security flaws and bugs on a conceptual entity that can't even write code (i.e. a language) is silly. If you are blaming the language designers then you have to look at the context in which the language was written.

    Why don't we then go and blame processor designers for designing chips that will execute a "bad" sequence of instructions.

    If you choose to develop with a language like C/C++ then so be it, you must accept the rough and the smooth.

    There are many alternatives out there, use one of them instead.

    Trojan, a C/C++ compiler will let you shoot yourself in the foot, that's something a lot of people like about it, you can write the code that you want to. If you don't know what you are doing with it then woe betide you.
    And your analogy with guns is flawed. Guns are designed to fire bullets to cause damage to people and/or things. Try finding a (serious:)) programming language that has been designed with the intent of causing security flaws and bugs.

    Gerald, if it wasn't for C there probably wouldn't be an IT industry. The lack of bounds checking (like so many other things with C) was to allow code to run acceptably on the hardware of the time. If you had thrown all the safety net stuff into the language, computers would probably still be looked at as novelties for educational institutions. Java is dog slow on a P100 (I know this because that was my development machine all summer). Could you imagine trying to run a JVM on a PDP10?


  • Closed Accounts Posts: 22 gerald


    If you are blaming the language designers then you have to look at the context in which the language was written.

    I am happy to look back at the history of a language and the context of its birth. I can agree that indeed a language such as C could have been useful in its own time because of resource constraints.

    However the context I am living in has changed dramatically. Millions of powerful computers running similar software programs are networked. A security flaw in one software has dramatic consequences for a multitude of users. We learnt it the hard way.

    Why don't we then go and blame processor designers for designing chips that will execute a "bad" sequence of instructions

    This is an unjustfied extrapolation. You told the compiler to send these instructions to the processor.
    If you choose to develop with a language like C/C++ then so be it, you must accept the rough and the smooth.

    Are you confortable with the idea to cause vast financial loss to many persons or organizations? Probably not. You would be less enthusiast to write in such languages if you were held responsible for the incured damages. I.T. is still a bit like the far west. There is no rules so you can do whatever you like. I firmly believe that in the near future, organizations will be held legally responsible for their lack of care. You just cannot ask people to sign a contract telling them that the car they just bought may explode at any time when used in a regular way and to not engage legal pursuits in such case. This is insane.

    C or C++ may have some advantages like portability. Speed is overrated according to me: Most languages are nowadays quite fast, some are faster than C or C++ for certain operations. We just lack people who know their compiler well to write efficient programs (I will not mention the most representative class of programmers, the pseudo-programmers who keep switching from and to a string representation of their data when solving a numerical problem. I've got a recent experience in mind).
    But how can one sacrify security and integrity in the name of speed or control?? Is this the 10 to 20% of speed increase? Buy another machine to distribute the computation. It will be cheaper in financial and management terms than managing these buffer overflows.


  • Registered Users Posts: 2,281 ✭✭✭DeadBankClerk


    If you are so worried about buffer overflows you could always write a C++ Array class. You could even implement the exact API from the Java array type.

    If your feel that companies should be held accountable for incurred damages, should companes not also be held accountable for writing slow, inefficiant code that forces the client to purchase more hardware than they need to?


  • Closed Accounts Posts: 22 gerald


    If you are so worried about buffer overflows you could always write a C++ Array class.

    I am more than worried. As a user, I am annoyed like many by the consequences of buffer overflows. I did not suffer from financial loss.

    I am actually not writing C or C++ code. Please forward this recommendation to every developper you know, as it seems that very few apply it. Any recommendations for the C developpers?
    If your feel that companies should be held accountable for incurred damages, should companes not also be held accountable for writing slow, inefficiant code that forces the client to purchase more hardware than they need to?

    I agree that compagnies should be held accountable for incurred damages if the code is inefficient and forces the client to purchase more hardware. This actually seems to happen in India.
    It will happen in Europe or America.

    Writing slow code may or may not result from an inefficient code. If security induces 20% overhead on the CPU to encrypt a 100Mb link, this is for the good cause. Just add a CPU. Security is not a feature. It is needed.


  • Closed Accounts Posts: 8,264 ✭✭✭RicardoSmith


    As a programmer you can't predict every possible circumstance that can cause a error. You can avoid the majority of them and that the best you can do. Theres simply too many possibilities and no one can know everything or predict all events. The more flexibility and functionality something has, then the potential for error increases. The more you reduce flexibility and functionality the potential for error decreases.

    Ultimately we're all human and can make mistakes. Therefore no one should rely on software being prefect because it never is. If someone (a business etc) gets caught out because their software has a problem and they've no contingency plans in place. Thats just poor management and planning. If the problem should have been predicted by the programmer and wasn't due to poor programming practise well thats a completely different scenerio. But there should always be a backup process somewhere.

    Even NASA makes mistakes. Would anyone reckon that their developers are clever than NASA? No then mistakes WILL be made. That just the normal human condition. Expecting no mistakes is just fantasy.


  • Closed Accounts Posts: 22 gerald


    As a programmer you can't predict every possible circumstance that can cause a error. You can avoid the majority of them and that the best you can do.

    I totally agree. The best you can do for a start is to equip yourself with the best tools. A compiler with bound checking is a minimum, especially for networked applications. If your know that your tool is flawed and you are using it, you didn't make your best efforts to deliver your solution.

    I understand that it is usually not up to the programmer to choose his tools. But managers, I.T. directors and developers etc. must become critical. What we are doing now is just not working. There are solutions, just start to use them.


  • Advertisement
  • Closed Accounts Posts: 8,264 ✭✭✭RicardoSmith


    There are advantages and disadvantages to every solution. But there is no perfect solution because the world is not a perfect place. Software and programming are therefore equally not perfect. To expect perfection is irrational. Most Managers and business heads know squat about IT and therein lies the root of many problem. IT is a tool for business. A Bad workman....

    I think you are well off topic and would be best starting a new thread, unless no one has a problem with the direction this one is heading.


  • Closed Accounts Posts: 22 gerald


    To expect perfection is irrational

    Agreed. I never mentioned that I expect perfection.

    I expect best efforts to obtain best results. To be equipped with reasonable tools to palliate for human deficiencies is the first step to achieve this goal. Correctness of the implementation and thus security(to some extent only, by eliminating buffer overflows) is far more important than speed. You want a car to go fast, but you certainly prefer a car, which can bring safe to your destination. C or C++ just fail to provide this.

    I realize that I am off-topic. I am just suprised by the recommendations made in this thread. I will stop replying to this thread now. If someone feels this discussion requires a new thread, feel free to start it.


  • Closed Accounts Posts: 8,264 ✭✭✭RicardoSmith


    Not perfection. What level of bugs and problems are acceptable? Where do you draw the line?

    Of C/C++? It has many advantages over other languages. Java's not without its problems either. For many speed (of execution and development) is more important than security. For example in graphics programming as per the title of the thread. Which is why 95% of games and graphics applications are written in it. That said I've seen as many if not more badly written Java apps than I have in any other language.

    Any other languages or development enviroments and platforms you'd care to suggest as being superior and for what reason?

    On my last project I gave the client 3 possible solutions. They choose the one didn't recommend, but as professional still presented. Why'd they pick it? Because it was cheapest. I also gave a time estimate which they cut in half. We finished over their time estimate but within and close to my original estimate.

    That scenerio is the norm in my experience.


  • Registered Users Posts: 4,676 ✭✭✭Gavin


    Originally posted by gerald
    You want a car to go fast, but you certainly prefer a car, which can bring safe to your destination. C or C++ just fail to provide this.

    What do you recommend instead ? For network related programming for example.

    Gav


Advertisement