🔒 Locked
🎮 Unity
3D libraries with C or Java?
Advertisement
Original Post
I do not know how to start with my own 3D libraries like points, vectors, matrices, etc. I know Java and C. Java is Object Oriented Programming. C is Structure Programming. And I have a dilemma: Java represents the objects in the real world better than C, it encapsulates data and functions and you can have an entity Matrix to rotate points, etc. But because an entity like that has method like getX(), getY() and so on, when you want to do some mathematic calculations like multiplicate points with a matrix sush as: Point3D[] points = {new Point3D(2.0, 3.0, 4.0), ..., ...}; // Array of points 3D ... Matrix3DHomogeneous m = new Matrix3DHomogeneous(); Vector3D v = new Vector3D(0.0, 2.0, 0.0); m.translate(v); // Create an homogeneous matrix to translate points. m.transform(points); // Receive arrays of points and transforms them modifyng their coordinate. it may be take much time than C because you call more methods (functions) than C imaging that transform method do the following: Point3D p = null; for (int i = 0; i < points.length; i++) { p = points; // Multiplicate points with the matrix using p.getX(), p.getY(), p.getZ()... } C does not have entity but you can use struct and header files to create something like entity in Java, for example a point and functions: point.h struct point { double x, y, z } transform.h void transform(point p) { ... = p.x; ... = p.y; ... = p.z; ... } Another problem is when a method receives an object you can modify its data or you can return a new object with new data. For example: Point3D[] points = {new Point3D(2.0, 3.0, 4.0), ..., ...}; // Array of points 3D ... Matrix3DHomogeneous m = new Matrix3DHomogeneous(); Vector3D v = new Vector3D(0.0, 2.0, 0.0); m.translate(v); // Create an homogeneous matrix to translate points. points = m.transform(points); // Receive arrays of points and transform them modifyng their coordinate. // See that the argument points is modifing inside the Matrix and then this method (transform) // return a new array with new points. The example above has another problem for me. I think to do it when I though that you maybe have points referensed with two or more variables and if you modify values of one variable you have to modify the other variables but calling p.setX(x), p.setY(y) or p.setComponents(x, y, z) continues to call more methods than p.x = x; p.y = y, etc. But, in the case that this is good implemented when you create object and object and object...the memory is very fill of this object maybe innecesary. Well, I think C is faster access to p.x than p.getX() and then do p.x = 0.0 instead of p.setX(0.0); because you do not call method. Imagine it in all point that you need to show and image 3D on screen and imagine other similar situations with other entities. But use p.getX() is better thatn p.x because you do not how is implemented the code inside the class and you can use p.getX() where you want and it is clearer than C. You can return a new point without affect the original point, in this case, the argument point: Point3D p = m.translate(point); Maybe this is not very important but I want to create good libraries while I learn real-time rendering. I would choose Java but C has its own power and run faster than Java, and it runs in a poor machine, Java need a best machine. Java is clearer than C and is a good programming language. I need your advice and thank you for your help.
Quote:
Original post by Anonymous Poster Quote:
Original post by Guimo
May I suggest C#. It has the best of both and it quickly became one of my favorite languages... even above Java. If you don't have a 'opinion' about Microsoft try it.
.Net fanatics are of the most irritating kind. Is it possible that Microsoft contractors keep screening these forums and suggesting such things? Just to simulate some kind of "word of mouth" marketing?
It's the only explanation of so much unfounded opinions regarding Java in here!
I think Java is a superior tool, not only it doesn't lock you to Windows and Microsoft, but because it's more mature and has excellent tools (better than VS).
With fairness, Java fanatics are just as irritating. Especially the uninformed, tin-foil-hat-wearing conspiracy theorists such as the AP. Microsoft certainly has better things to do than hire people to pose as comunity members of Gamedev.net spreading pro-microsoft sentiment. Just accept that some people like Microsoft's tools and move on. God forbid, they may have even evaluated your personal favorite tool and STILL prefer Microsoft's offering.
The AP may take note that Guimo at no point stated as fact that C# was/is better than Java. Only that he has come to prefur it over Java personally. Presumably, this means that he has used and evaluated Java at some point and still prefers C#.
The AP's last paragraph is where he really swerves off into an alternate dimension.
Firstly, Microsoft only developed the C# language and .NET Environment. They have given control of both to an international standards body. To date, I believe there are 4 main .NET platform implimentations both closed and open source - Microsoft .NET/CLI(closed), Microsoft's ROTOR(open), Mono(open) and DOTgnu(open). These implimentations allow you to run .net applications on many platforms including Windows, OS X, Linux, *nix, *BSD, and many others. The implimentations are at various stages of completeness, granted, but all are functional and work is progressing steadily.
Secondly, while AP is certainly entitled to his/her own oppinion. It is not at all fact that Java is 'more mature' - Slightly older surely, but as many human beings demonstrate: Maturity is not solely a function of one's age. As for whether Java has better tools, I will only say that Visual Studio is one of the oldest continuously developed/improved and currently used IDEs available and has many, many rich and usefull features. Personally, I have yet to find an IDE which I prefer to Visual Studio.
I guess C++ has the best of both worlds. It is about as efficient as C (your mileage may vary) and it has many object-oriented features. If you are fond of objects and want the raw speed, go with it. You can also overload operators, and I think a vector-math library is one of the few places where overloading operators is definitely a good idea.
[Edited by - alvaro on September 5, 2006 11:11:25 AM]
[Edited by - alvaro on September 5, 2006 11:11:25 AM]
Yes Alvaro, I'm afraid of C++ is better, I suppose because like you say, it combines both, and I can understand why people use C++ to create their graphics instead of C or Java. But in this case how do you do to decide to use structure programming or object oriented programming and combine them in your libraries. I used C++ no much and for me is difficult to know when use one or other programming that is the reason I chose C or Java but C++ is better. For example you have a class in Java and a struct in C:
Java
----
public final class Point2D {
private double x, y, z;
...
public double getX() {
return x;
}
...
public void setX(double x) {
this.x = x;
}
...
}
C
-
struct point2D {
double x, y, z;
}
And how do you do to choose in C++ to modify that point. What do you think when you choose these ways:
Java
----
Point2D p = new Point2D();
...
p.setX( 1.0);
or
C
-
...
p.x = 1.0;
And when you use pointers instead of variables and so on?
Well, I have problems to decide!!!
Thanks.
Java
----
public final class Point2D {
private double x, y, z;
...
public double getX() {
return x;
}
...
public void setX(double x) {
this.x = x;
}
...
}
C
-
struct point2D {
double x, y, z;
}
And how do you do to choose in C++ to modify that point. What do you think when you choose these ways:
Java
----
Point2D p = new Point2D();
...
p.setX( 1.0);
or
C
-
...
p.x = 1.0;
And when you use pointers instead of variables and so on?
Well, I have problems to decide!!!
Thanks.
I am not trying to sway off topic or be a**ss, but dude, if you do not even know when to use Pointers or simply just simple variable, then surely enough you are not that good with C. So in that case i would suggest you stick to Java if you are more familiar with it. The reason why i say that is because when dealing with graphics, your code will get overly crowded with pointers.
Quote:
Original post by Guimo
May I suggest C#. ... If you don't have a 'opinion' about Microsoft try it.
Ughh!!! Would you people P-L-E-A-S-E quit spreading this "C# == Microsoft" myth. C# and CLI are open ECMA standards.
ECMA C# Standard
ECMA CLI Standard
-- Microsoft's .NET framework implements the standard for Windows.
-- The Mono Project implements the standard for Windows, Mac, Unix, Linux, Solaris, etc.
Your code is no more or less portable with C# than C++. In either language, you must use portable libraries to write portable code.
Oh, and AP...
Quote:You could have checked the mono page. Despite the fact that your question's implied premise is rooted in fallacious logic, here is a company that claims to have done so.
I have chalenged other times and I will chanlenge again, I still would like to hear a real developer, making real money, with real clients and real pissed off people if things break that has used .Net for crossplatform development of serious applications (that means "Hello Worlds" don't count).
[Edited by - smitty1276 on September 5, 2006 12:30:10 PM]
I know this is offtopic at this point, but I thought I would point this out for the benefit of people who are new to these forums. This anonymous poster is a perfect example of the sort of misinformation that you should be wary of. When the AP, here, thinks he knows what he is talking about, it can be easy to mistake him for someone who actually DOES know what they are talking about.
This is very simple, and is the way these things work with most standards.
1) New Standard (C# 3.0 for example) is released.
2) Mono implements the new standard.
3) Mono releases the new version with the new standard implementation.
There is no "catch up". Unless you are referring to the non-standard Windows.Forms libraries, which Mono is attempting to emulate, but that is a non-standard library and is not among the core libs.
What are you talking about? Are you not aware that any "crossplatform" software must have native libs compiled on the platform on which it is running? You may not know enough about this topic to realize it, but you are arguing against yourself right now.
In C++, for example, you can use GTK or SDL on Windows or Linux. But to compile your code for either platform, you must have the corresponding version of the GTK or SDL libs.
The same goes for C#. If you are using GTK or SDL with C#, you must have the native version of those libs available on the final platform on which the app is running.
I'm not really sure how you came to the conclusion that there were "crossplatform" libraries that didn't have to be compiled on each platform. This is just another example, though, of why the OP should be careful about who they listen to.
The point is that C# does not limit your ability to write cross platform apps any more than C++ does. C# does allow you to write apps that may not even require recompilation (something the "crossplatform" c++ cannot do). The bottom line is that C# does not tie you to Microsoft or Windows. People who say that don't have a clue what they are talking about.
Quote:
Anyway, C# == Microsoft, they add whatever they want to it. Did they consult others about the changes in C# 2 and the next version? So, basically, Mono et al willl be playing catch up until the end of times. A half-baked platform.
This is very simple, and is the way these things work with most standards.
1) New Standard (C# 3.0 for example) is released.
2) Mono implements the new standard.
3) Mono releases the new version with the new standard implementation.
There is no "catch up". Unless you are referring to the non-standard Windows.Forms libraries, which Mono is attempting to emulate, but that is a non-standard library and is not among the core libs.
Quote:
Except that they have a specific version for running on Mono, guess why? ... You have to be joking if you can't use the same libs in both platforms.
What are you talking about? Are you not aware that any "crossplatform" software must have native libs compiled on the platform on which it is running? You may not know enough about this topic to realize it, but you are arguing against yourself right now.
In C++, for example, you can use GTK or SDL on Windows or Linux. But to compile your code for either platform, you must have the corresponding version of the GTK or SDL libs.
The same goes for C#. If you are using GTK or SDL with C#, you must have the native version of those libs available on the final platform on which the app is running.
I'm not really sure how you came to the conclusion that there were "crossplatform" libraries that didn't have to be compiled on each platform. This is just another example, though, of why the OP should be careful about who they listen to.
The point is that C# does not limit your ability to write cross platform apps any more than C++ does. C# does allow you to write apps that may not even require recompilation (something the "crossplatform" c++ cannot do). The bottom line is that C# does not tie you to Microsoft or Windows. People who say that don't have a clue what they are talking about.
Quote:
Original post by EDBarrera
Java
----
public final class Point2D {
private double x, y, z;
Have you thought about using
public double a, b, c; ?
Wait a minute, why is that last variable in class named Point2D?
Stick to Java, if you know it best.
The call of p.getSomething, might be and often is inlined, so there is no function overhead in an optimal situation. If it would happen or not is actually on the JIT, so you might preffer class that alows p.a += p.b;
Difference between method call overhead, no method call, inlined private variables is rather neligible. (Yes I tested it.) If you think p.a is confy, use it.
Of course you can also use the old version of my library, that does exactly that.
[Edited by - Raghar on September 5, 2006 2:46:32 PM]
In all languages you have to use cross-platform libraries to have cross-platform code.
If you are using Java, you could use the JNI to call native code that is OS-dependant. How is that any different than using non-standard .Net libraries like Win.Forms?
If you want to write cross-platform C#, don't use these libraries. It's not like Microsoft is trying to fool you into thinking that a particular part is cross-platofrm when it's not (all Windows specific stuff is in Win or Microsoft IIRC).
And code written in Java does not need to be recompiled, but native code that has Java bindings (like OpenGL) does. That is what smitty was refferring to.
If you are using Java, you could use the JNI to call native code that is OS-dependant. How is that any different than using non-standard .Net libraries like Win.Forms?
If you want to write cross-platform C#, don't use these libraries. It's not like Microsoft is trying to fool you into thinking that a particular part is cross-platofrm when it's not (all Windows specific stuff is in Win or Microsoft IIRC).
And code written in Java does not need to be recompiled, but native code that has Java bindings (like OpenGL) does. That is what smitty was refferring to.
Quote:
Btw, JAVA DOESN'T NEED RECOMPILATION, so why's that genius? Because it's intended to BE CROSSPLATFORM, you know, real crossplatform.
You are referring to Java itself as a platform. In that respect, you are limited purely to the functionality provided by the Java platform. If you are talking about multiple platforms being operating systems/environments, then you will need to use native libs with Java. C# is exactly the same way.
In both cases (Java and C#) you must have a runtime that is compiled on the platform (the JRE or the CLI).
smitty1276
You are incorrect, and given the way with C# 3.0 moved we could see considerable bloat.
Any selfrespecting compiler writer could sit to the chair get crunchies, music, and babe and then could watch the firework.
nony
Be polite, you can't edit your posts so think before posting.
superpig
Private messaging would be bit silly. If they'd create new thread and these posts would be copied into it, it would be much better. When theirs arguments would go overboard someone could "correct" them, or others would have great laugh.
You are incorrect, and given the way with C# 3.0 moved we could see considerable bloat.
Any selfrespecting compiler writer could sit to the chair get crunchies, music, and babe and then could watch the firework.
nony
Be polite, you can't edit your posts so think before posting.
superpig
Private messaging would be bit silly. If they'd create new thread and these posts would be copied into it, it would be much better. When theirs arguments would go overboard someone could "correct" them, or others would have great laugh.
If I made DirectX bindings for Java, would that make Java less portable??
I'm assuming your answer would be NO. That is the same thing for C#. DirectX is not part of C#. The fact that you *can* make Windows-specific C# programs does not tie C# the language to Windows.
Also C# has portable bindings to SDL, OpenGL, Irrlicht, Ogre, and many other libraries, so you can make cross-platform games with it.
Also, it's kinda funny that you accuse me of being a Microsoft employee because when I was younger, I was extremely anti-Microsoft. I have only been tinkering with C# for a few months, but have never used the Windows-specific stuff.
I'm assuming your answer would be NO. That is the same thing for C#. DirectX is not part of C#. The fact that you *can* make Windows-specific C# programs does not tie C# the language to Windows.
Also C# has portable bindings to SDL, OpenGL, Irrlicht, Ogre, and many other libraries, so you can make cross-platform games with it.
Also, it's kinda funny that you accuse me of being a Microsoft employee because when I was younger, I was extremely anti-Microsoft. I have only been tinkering with C# for a few months, but have never used the Windows-specific stuff.
Quote:I'm not sure what you mean. Incorrect about what? I'm not incorrect about the fact that C# and CLI are open standards. I'm not incorrect about the necessity for native libs with all languages. I'm not incorrect about the fact that C# is the CLI analog of Java to the JRE. I'm not incorrect about the fact that Microsoft's inportable libs are not part of the CLI/C# standard, nor are they advertised as such.
Original post by Raghar
smitty1276
You are incorrect, and given the way with C# 3.0 moved we could see considerable bloat. ... Any selfrespecting compiler writer could sit to the chair get crunchies, music, and babe and then could watch the firework.
That's about all I have said, I think.
Quote:
Original post by Anonymous Poster
This language war bullshit isn't doing the OP any good at all...
OP: Use the language YOU know best and are most comfortable with. That is the language that will produce faster code for YOU.
Having used both C++ and Java for OpenGL development, I can tell you that the performance difference is fairly negligable. I daresay C# performs similarly. Remember that most of the workload for 3D graphics is done by dedicated hardware these days, providing you use OpenGL / Direct3D.
I agree 100%. I wasn't saying any language was better than any other. I just wanted to correct the misinformation that the anonymous dude was posting.
I enjoy doing 3D stuff with Java. The only real edge that I would give to C# is operator overloading, but that is something that isn't even necessary (and some would say is inadvisable anyway).
This is the last I'll say because thise thread, unfortunately, has been driven completely off topic. I did not intend to begin this course of events, but to simply provide a counterpoint to the AP.
Still you make an argument for which you have no evidence. I invite you to prove to me that Microsoft pays anyone to pose as a member of this board or to prove that spreading positive word-of-mouth here is part of their job description. Furthermore, what did your original post contain to answer the OPs concerns? All I heard was how much you love Java and hate Microsoft.
The OP asked for oppinions of C and Java. C# being somewhat of a middle-ground between the two, I think it was a perfectly valid option to bring up.
The spec is there for anyone to impliment. You can't fault Microsoft for being ahead of the curve or having more resources to throw at it. While Microsoft is the main entity pushing new features for .NET, anyone else can send up requests to the ECMA as well. Furthermore, any of these other entities can chose to keep themseves informed of what has been proposed to the ECMA, making them just as aware of what's going on as Microsoft. The only *slight* advantage Microsoft may have is that they know what they will soon be proposing (just as other entities know what they soon will be proposing,) however, said proposals may or may not be accepted. Microsoft knows something is accepted at the precise moment everyone else knows.
The standards DO cover everything that's needed; The Windows namespace is NOT standard. There ARE complex, cross platform applications completed and being developed using .NET with cross-platform libraries where necesary, typically UIs.
It does not further your cause to presume things. I've used many IDEs dating all the way back to DOS. To name a few of the more recent: Borland, Borland Builder, Eclipse, Code::Blocks, KDevelop, etc. I've simply never liked the 'feel' of these contenders or there was something they lacked.
Honestly though, none of this discussion about who's tools are better matters. Whatever tool allows you to be the most comfortable and productive is the right tool for you, and that may not be the same tool for the OP that it is for you or I.
---
To answer the ORIGINAL posting, which I should have addressed in my first post...
I would probably recomend C++ for what you seem to be after. I don't think you're at all concerned about cross-platform development. You seem to like Java because it is Object Oriented, making it (generally speaking) more modular and maintanable. You like C because it executes natively and is therefore faster.
C++ is similar in syntax to both Java and C so you should be comfortable with it almost immediately if you know Java, or C to a lesser extent, already. Your concerns about using Accessors are likely moot (at least with C++, not sure about Java) because the compiler will surely inline trivial accessors, removing the overhead of the method call.
As for your concerns about whether to write C++ as OO or procedural code, I'd say to go with OO most of the time. The whole point of using C++ over C is to gain the benefit from OO features. I have a software renderer/math lib/platform abstraction library which is almost completely object oriented. Everything in the math lib (vectors, matrices, quaternions) is a class. CErtain aspects of your coding will involve choices, pass/return by value, reference or pointer for instance, but most cases are pretty clear with a little thought, you just have to understand the pros and cons of each and decide what's best.
Quote:
Original post by Anonymous Poster Quote:
Original post by Ravyne
With fairness, Java fanatics are just as irritating. Especially the uninformed, tin-foil-hat-wearing conspiracy theorists such as the AP. Microsoft certainly has better things to do than hire people to pose as comunity members of Gamedev.net spreading pro-microsoft sentiment. Just accept that some people like Microsoft's tools and move on. God forbid, they may have even evaluated your personal favorite tool and STILL prefer Microsoft's offering.
You underestimate the power of "word of mouth". Besides this is not the first time that fanatics DON'T respond the users question and use the space to promote their favorite (employer's?) tool.
Still you make an argument for which you have no evidence. I invite you to prove to me that Microsoft pays anyone to pose as a member of this board or to prove that spreading positive word-of-mouth here is part of their job description. Furthermore, what did your original post contain to answer the OPs concerns? All I heard was how much you love Java and hate Microsoft.
Quote:
Original post by Anonymous Poster Quote:
Original post by Ravyne
The AP may take note that Guimo at no point stated as fact that C# was/is better than Java. Only that he has come to prefur it over Java personally. Presumably, this means that he has used and evaluated Java at some point and still prefers C#.
Which WASN'T what the user asked to begin with.
The OP asked for oppinions of C and Java. C# being somewhat of a middle-ground between the two, I think it was a perfectly valid option to bring up.
Quote:
Original post by Anonymous Poster Quote:
Original post by Ravyne
The AP's last paragraph is where he really swerves off into an alternate dimension.
Firstly, Microsoft only developed the C# language and .NET Environment. They have given control of both to an international standards body. To date, I believe there are 4 main .NET platform implimentations both closed and open source - Microsoft .NET/CLI(closed), Microsoft's ROTOR(open), Mono(open) and DOTgnu(open). These implimentations allow you to run .net applications on many platforms including Windows, OS X, Linux, *nix, *BSD, and many others. The implimentations are at various stages of completeness, granted, but all are functional and work is progressing steadily.
All incomplete, crappy and buggy and they will be playing catching up with MS. And even if they were complete still would be impossible to run applications developed in Visual Studio because the standards don't cover everything that's needed.
I have chalenged other times and I will chanlenge again, I still would like to hear a real developer, making real money, with real clients and real pissed off people if things break that has used .Net for crossplatform development of serious applications (that means "Hello Worlds" don't count).
The spec is there for anyone to impliment. You can't fault Microsoft for being ahead of the curve or having more resources to throw at it. While Microsoft is the main entity pushing new features for .NET, anyone else can send up requests to the ECMA as well. Furthermore, any of these other entities can chose to keep themseves informed of what has been proposed to the ECMA, making them just as aware of what's going on as Microsoft. The only *slight* advantage Microsoft may have is that they know what they will soon be proposing (just as other entities know what they soon will be proposing,) however, said proposals may or may not be accepted. Microsoft knows something is accepted at the precise moment everyone else knows.
The standards DO cover everything that's needed; The Windows namespace is NOT standard. There ARE complex, cross platform applications completed and being developed using .NET with cross-platform libraries where necesary, typically UIs.
Quote:
Original post by Anonymous Poster Quote:
Original post by Ravyne
Secondly, while AP is certainly entitled to his/her own oppinion. It is not at all fact that Java is 'more mature' - Slightly older surely, but as many human beings demonstrate: Maturity is not solely a function of one's age. As for whether Java has better tools, I will only say that Visual Studio is one of the oldest continuously developed/improved and currently used IDEs available and has many, many rich and usefull features. Personally, I have yet to find an IDE which I prefer to Visual Studio.
You have never used anything else then.
It does not further your cause to presume things. I've used many IDEs dating all the way back to DOS. To name a few of the more recent: Borland, Borland Builder, Eclipse, Code::Blocks, KDevelop, etc. I've simply never liked the 'feel' of these contenders or there was something they lacked.
Honestly though, none of this discussion about who's tools are better matters. Whatever tool allows you to be the most comfortable and productive is the right tool for you, and that may not be the same tool for the OP that it is for you or I.
---
To answer the ORIGINAL posting, which I should have addressed in my first post...
I would probably recomend C++ for what you seem to be after. I don't think you're at all concerned about cross-platform development. You seem to like Java because it is Object Oriented, making it (generally speaking) more modular and maintanable. You like C because it executes natively and is therefore faster.
C++ is similar in syntax to both Java and C so you should be comfortable with it almost immediately if you know Java, or C to a lesser extent, already. Your concerns about using Accessors are likely moot (at least with C++, not sure about Java) because the compiler will surely inline trivial accessors, removing the overhead of the method call.
As for your concerns about whether to write C++ as OO or procedural code, I'd say to go with OO most of the time. The whole point of using C++ over C is to gain the benefit from OO features. I have a software renderer/math lib/platform abstraction library which is almost completely object oriented. Everything in the math lib (vectors, matrices, quaternions) is a class. CErtain aspects of your coding will involve choices, pass/return by value, reference or pointer for instance, but most cases are pretty clear with a little thought, you just have to understand the pros and cons of each and decide what's best.
Christ, I go away for a few hours and this is what I find when I get back...
Edit: The OP asked me to post this closing note:
Edit: The OP asked me to post this closing note:
Quote:
Hi, I'm who have problems with which language choose to create my 3D libraries. Thanks for all people who wrote to give me their advices. I decided to use C++, I used sometime C, C++ no much and Java currently, and I must to review and study more about C++. Thank to alvaro, Raghar, Ravyne, Emilio and those Anonymous Poster who help me to decide, and all other people to wasted their time to write me.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement