Jump to content

  • Log In with Google      Sign In   
  • Create Account


Java or C++?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
44 replies to this topic

#21 Hiiri   Members   -  Reputation: 111

Like
0Likes
Like

Posted 20 March 2012 - 04:26 AM

Actually, Python is strongly typed.


Ah sorry, you are right. I meant dynamical typing, if that would be good thing to have for someone that is just learning programming or bad?

Sponsor:

#22 Robin123   Members   -  Reputation: 100

Like
0Likes
Like

Posted 20 March 2012 - 06:43 AM

wow guys, far more replies than I expected...a hot topic apparently Posted Image. Thanks for all the help. I think I will continue with Java, now that I'm already into it. I will probably not head in the C++ direction straight away instead opting to take a look at C# first.

I have plenty of time to get onto C++.

Thanks!

#23 Vlad86   Members   -  Reputation: 130

Like
0Likes
Like

Posted 20 March 2012 - 09:48 AM

Question is, towards what do you want to target your programming?
You can make games in almost any language. If you want to develop for example games for PS3, C++ is a must.
If you want create games as a hobby, java and C# is an excellent choice. C++ will consume allot of time before you will be able to generate something useful (without major bugs).

#24 zoneweb   Members   -  Reputation: 92

Like
0Likes
Like

Posted 20 March 2012 - 10:57 AM

C++ will consume allot of time before you will be able to generate something useful (without major bugs).

That only happens when you scale it up. Hobby games are still doable in C++ without much hassle (if you know what you're doing). You just have to avoid the gimmicks that other programmers sometimes use to make their programs appear more sophisticated than necessary (e.g., excessive use of inheritance, pointers, and unnecessary datatypes when simplier methodology would suffice). The key is to follow a programming paradigm that allows smooth porting of the program between platforms and languages.

#25 Cornstalks   Crossbones+   -  Reputation: 6974

Like
1Likes
Like

Posted 20 March 2012 - 11:28 AM


C++ will consume allot of time before you will be able to generate something useful (without major bugs).

That only happens when you scale it up. Hobby games are still doable in C++ without much hassle (if you know what you're doing).

That's the problem. Obviously, the OP is a beginner, and obviously he wouldn't know what he's doing with C++... That's the same for any beginner. Hence why C++ would consume a lot of the beginner's time before he/she even gets a semi-working simple game.
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#26 daviangel   Members   -  Reputation: 600

Like
1Likes
Like

Posted 20 March 2012 - 01:13 PM



C++ will consume allot of time before you will be able to generate something useful (without major bugs).

That only happens when you scale it up. Hobby games are still doable in C++ without much hassle (if you know what you're doing).

That's the problem. Obviously, the OP is a beginner, and obviously he wouldn't know what he's doing with C++... That's the same for any beginner. Hence why C++ would consume a lot of the beginner's time before he/she even gets a semi-working simple game.

Yup according to one of Stroustroup's latest talks one of the reasons there is so much bad C++ code is:

Bad style is the #1 problem in real-world C++ code

Makes progress relatively easy

Only relatively: bad code breeds more bad code

Lack of focus on style is the #1 problem in C++ teaching

A “quick hack” is usually the quickest short-term solution

Faster than thinking about “design”

“They” typically teach poor style

Many are self-taught

Take advice from

Decades old books

Posted Image Other novices Posted Image

Imitate

Other languages

Bad old code
Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe

#27 MichaBen   Members   -  Reputation: 481

Like
0Likes
Like

Posted 20 March 2012 - 02:01 PM

C++'s syntax is just... tedious, especially for a beginner, and even more so when the compiler gives very non-beginner-friendly error/warning messages. That's the main issue with C++'s syntax and beginners.

You must be using a really crappy compiler then, mine simple says:
"Main.cpp:54: error: 'class std::vector<std::basic_string<char> >' has no member named 'begiin'"

And as for missing a semicolumn in a header:
"Component.h:25: error: expected ';' at end of member declaration"

#28 Cornstalks   Crossbones+   -  Reputation: 6974

Like
0Likes
Like

Posted 20 March 2012 - 02:20 PM


C++'s syntax is just... tedious, especially for a beginner, and even more so when the compiler gives very non-beginner-friendly error/warning messages. That's the main issue with C++'s syntax and beginners.

You must be using a really crappy compiler then, mine simple says:
"Main.cpp:54: error: 'class std::vector<std::basic_string<char> >' has no member named 'begiin'"

And as for missing a semicolumn in a header:
"Component.h:25: error: expected ';' at end of member declaration"

If you consider g++ a crappy compiler then... sure, I guess I am. But that's even another issue: different compilers give different errors, and inconsistency is a disservice to beginners.
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#29 Aluthreney   Members   -  Reputation: 256

Like
0Likes
Like

Posted 20 March 2012 - 04:48 PM

Maybe it's because I've only been using C++ for about 2 years now (and probably because I've never really studied any other language as deeply as C++), but I really don't see what the big deal is with C++ it's just something you gotta learn. In my opinion you should start with C and evolve to C++ (atleast that's what I did and I haven't regretted it so far), after you have a good understanding of both start developing basic console games (like tic-tac-toe) and after your skills have grown try making simple 2D games (with programs like Game Editor or libraries like SDL) or if you're feeling really adventurous go straight to basic 3D games (again, with the help of programs and libraries); obviously you wont produce any commercial, mind-blowing games, but you will absorb a lot of knowledge about programming.

I hope I haven't scared or confused you. Basically all I'm saying is to jump into the difficult stuff (cause your gonna have to learn it eventually), cry for a few days because you don't understand it (not literally), after you've calmed down, go back to it and eventually (without realizing it) you'll start learning stuff about programming.

Anyway, that's how I've been doing it since I've started learning.

Cheers :D

Aluthreney -- the King of sheep.


#30 Washu   Senior Moderators   -  Reputation: 5041

Like
2Likes
Like

Posted 20 March 2012 - 05:00 PM

Maybe it's because I've only been using C++ for about 2 years now (and probably because I've never really studied any other language as deeply as C++), but I really don't see what the big deal is with C++ it's just something you gotta learn. In my opinion you should start with C and evolve to C++ (atleast that's what I did and I haven't regretted it so far), after you have a good understanding of both start developing basic console games (like tic-tac-toe) and after your skills have grown try making simple 2D games (with programs like Game Editor or libraries like SDL) or if you're feeling really adventurous go straight to basic 3D games (again, with the help of programs and libraries); obviously you wont produce any commercial, mind-blowing games, but you will absorb a lot of knowledge about programming.

You've only used it for two years? That's really barely enough time to get to know the language. C++ is a huge and horrible beast of a language, with lots and lots and lots of lovely corner cases just waiting to bite you. That's not to say one can't start with it, but its a bad idea. You never have to learn C++ unless you decide to become a professional game developer. If you work indie, XNA, mobile phones, or similar, you can avoid C++ for almost the entire time. C is only slightly better than C++, having fewer of the more tricky corner cases, while still having plenty of lovely undefined behavior just waiting under the hood. I'm not trying to be mean, but even after 20 YEARS of using C++, I still find nasty corner cases that introduce fun. C++11 certainly didn't help in that regard.

Basically all I'm saying is to jump into the difficult stuff (cause your gonna have to learn it eventually), cry for a few days because you don't understand it (not literally),


More like a few months, and even then you probably still won't understand the exact reasons why certain things are or are not valid.

There is a reason we recommend managed languages (like Java, C# and python) to beginners: Your goal, as a beginner, is to learn the art of programming. This is not something that is bound to a single language, it is a method of thinking, a set of paradigms, and the problem solving skills required to take a problem and produce a solution. As such, the language you choose to learn on your initial forays into the field should be one that encourages learning, provides results quickly, and does not require you to understand low level concepts before you can implement high level ideas. You will eventually learn lower level concepts, and you will eventually move on to other languages, many other languages. Each language has problems it is good at solving, and problems that it is terrible at solving. Eventually, when you have a tool chest of languages and paradigms you will find problem solving to not just be significantly simpler, but also significantly cleaner.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#31 daviangel   Members   -  Reputation: 600

Like
0Likes
Like

Posted 20 March 2012 - 06:34 PM



C++'s syntax is just... tedious, especially for a beginner, and even more so when the compiler gives very non-beginner-friendly error/warning messages. That's the main issue with C++'s syntax and beginners.

You must be using a really crappy compiler then, mine simple says:
"Main.cpp:54: error: 'class std::vector<std::basic_string<char> >' has no member named 'begiin'"

And as for missing a semicolumn in a header:
"Component.h:25: error: expected ';' at end of member declaration"

If you consider g++ a crappy compiler then... sure, I guess I am. But that's even another issue: different compilers give different errors, and inconsistency is a disservice to beginners.

Yup. They don't even seem to agree on the simplest of errors as the following shows:
C:\Temp>type meow.cpp
#include <iostream>
using namespace std;
int main() {
cout < "Hello, world!";
}
C:\Temp>cl /EHsc /nologo /W4 meow.cpp
meow.cpp
meow.cpp(5) : warning C4130: '<' : logical operation on address of string constant
meow.cpp(5) : warning C4552: '<' : operator has no effect; expected operator with side-effect

This is actually required to compile by C++98/03, as cout has operator void *(). Comeau 4.3.10.1 also accepts this.

GCC 4.4.1 emits hard errors but I don't know what they're doing.

In C++0x, this should fail to compile due to changes in the Core Language and Standard Library. (While VC10 implements portions of C++0x, it doesn't implement the relevant changes here.) - Stephan T. Lavavej
Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe

#32 way2lazy2care   Members   -  Reputation: 782

Like
1Likes
Like

Posted 21 March 2012 - 07:24 AM

One thing on C# vs Java that hasn't been mentioned is that C# has amazing developer tools. Every time I decide to use C# the first thing I think is, "MY GOD THIS IDE IS BEAUTIFUL!" as a single tear of happiness rolls down my cheek. Even moreso everything that is beautiful is also totally functional whereas in VC++/VS it's almost a tossup on whether something will work the way you expect it to.

That would be my biggest reason for choosing C# tbh. You can install VC# Express and you're pretty much good to go instantly. Almost every other language/IDE has more setup than click setup.exe->start programming. Also the xna site has tons of great tutorials for a beginner that wants to jump straight into games. There are some good java tutorials, but they are generally lost among the flood of crappy java tutorials.

#33 www.gamegugu.com   Members   -  Reputation: 73

Like
-1Likes
Like

Posted 21 March 2012 - 08:16 AM

learn java before c++ is a good choice, java can let you master an important language more easier, after that you will find what c++ really is. If you learn c++ straightly, you may be halt by many disgusting and unuseful stuff.

#34 Memories are Better   Prime Members   -  Reputation: 769

Like
0Likes
Like

Posted 21 March 2012 - 07:08 PM

There is something that has been on my mind for quite some time, why is C++ often considered as a primary language to beginners? and has anyone actually gotten far enough making a content rich game in C# with SlimDX / SharpDX similar to AAA quality games out today, where performance was so bad due to it being managed that C++ would have made a noticeable difference?

Sure theres benchmark threads, a tonne of comparison threads and a lot of opinions but has there ever been a case where a C# project using SlimDX / SharpDX has come to a halt because C# just wasnt good enough to perform and if there is how did they deal with it, something tells me it wasnt "port everything to C++".

#35 LePhantom   Members   -  Reputation: 100

Like
0Likes
Like

Posted 21 March 2012 - 08:45 PM

I would reccomend C#. If your goal is games then XNA is a great tool

#36 Ripiz   Members   -  Reputation: 529

Like
-2Likes
Like

Posted 22 March 2012 - 07:59 AM

wow guys, far more replies than I expected...a hot topic apparently Posted Image. Thanks for all the help. I think I will continue with Java, now that I'm already into it. I will probably not head in the C++ direction straight away instead opting to take a look at C# first.

I have plenty of time to get onto C++.

Thanks!

As far as I remember Language1 vs Language2 always brought wars, especially when it comes to C++ vs Java vs C#.

But I guess I can provide my own point of view:
C++ is hardest out of those 3 because it has memory management, pointers and other weird stuff, however it has high performance because it's not virtual machine like Java, and doesn't require dynamic linking for everything like in C#. Therefore it's best suited for demanding applications (database, AAA games, simulations, etc).

C# allows easy Windows UI development, together with XNA it can create nice games too (not only for PC).

Java is very cross-platform therefore is best suited for applications that target wide audience, however it's quite big letdown when it comes to performance. Huge amount of packages allows rapid development as well, but inability to create overloaded pointers can make game development complicated because of heavy math involvement.


Also I don't consider Java and C# true programming languages because they cannot run on machine without OS/extra libraries, like Assembly/C/C++ can, therefore I consider both of them to be scripting languages.

#37 rip-off   Moderators   -  Reputation: 8164

Like
2Likes
Like

Posted 22 March 2012 - 09:49 AM

But I guess I can provide my own point of view:

This is For Beginners. Try to stick with facts, rather than opinions.

Just to quickly refute some of your points:

C++ is hardest out of those 3 because it has memory management, pointers and other weird stuff, however it has high performance because it's not virtual machine like Java, and doesn't require dynamic linking for everything like in C#. Therefore it's best suited for demanding applications (database, AAA games, simulations, etc).

Virtual machines have nothing to do with performance, nor does dynamic linking. The fact that current implementations of these might incur performance overhead is not a particularly interesting argument.

Consider virtual machines, if you look back a few years and see the performance difference between what they were then and where they are now - you will see that most of the "performance issues" are actually implementation issues. In addition, language implementations that have some kind of hypervisor/compiler functionality have lots of opportunities for advanced optimisation that we're only scratching the surface of (e.g. V8 javascript engine compiling dynamic function calls to inline assembler - no current C++ compiler can do this).

As for dynamic linking performance, I imagine any performance issues are most likely related to Microsoft attempting to keep backwards compatibility with their existing DLL systems. I've never looked into C#'s dynamic linking, so I cannot comment for certain, but if you were free to design a new dynamic link system from scratch, I see no reason one would have to pay a heavy runtime price for it. Indeed, again the nature of these languages could serve as a benefit, the abstract instructions here could be fully inlined into the caller when they are dynamically linked (possibly but considerably more difficult for fully native code).

Java is very cross-platform therefore is best suited for applications that target wide audience, however it's quite big letdown when it comes to performance. Huge amount of packages allows rapid development as well, but inability to create overloaded pointers can make game development complicated because of heavy math involvement.

Overloaded pointers?

Java's main performance pitfall is the memory structure - it suffers because it doesn't allow explicit value objects and AFAIK little or no memory layout optimisations are done automatically. This is where 95%+ of modern performance issues are - memory layout problems causing the busy loops to fall outside the cache.

Also I don't consider Java and C# true programming languages because they cannot run on machine without OS/extra libraries, like Assembly/C/C++ can...

Standard C++ and C cannot run on their own without an OS. Arguably, no program can run without an OS, without also being an OS.

In any case, C and C++ operate in their own kind of "virtual machine", just one that happens to map more or less directly to hardware very often. This abstraction insulates you from the processor just enough that you would need some assembly or language extensions to bootstrap you and/or to accomplish certain tasks.

And of course if you allow C or C++ that, then surely you must allow Java, C# or even Javascript the same, and you are back to where you started.

However unless you are in the business of writing operating systems I don't see any relevance of this line of reasoning.

... therefore I consider both of them to be scripting languages.

Arbitrary, line in the sand nonsense. The classification of a programming language as a "scripting language" (the latter usually considered a subset of the former, not a disjoin set), even under a definition of scripting language as unusual as yours (typically scripting language is more or less synonymous with dynamic typing), is irrelevant.

#38 zoneweb   Members   -  Reputation: 92

Like
-2Likes
Like

Posted 22 March 2012 - 12:18 PM

Try to stick with facts, rather than opinions.

Posted Image

Consider virtual machines, if you look back a few years and see the performance difference between what they were then and where they are now - you will see that most of the "performance issues" are actually implementation issues.

It's so easy to blame everything on implemention. It's a catch-all phrase for defending anything that's wrong with a particular tool. One could argue that the performance issues of C/C++ is related to implementation too. If the compilers were made better, C/C++ would always be extremely far ahead of Java in performance.

Java's main performance pitfall is the memory structure - it suffers because it doesn't allow explicit value objects and AFAIK little or no memory layout optimisations are done automatically. This is where 95%+ of modern performance issues are - memory layout problems causing the busy loops to fall outside the cache.

Regardless of whether or not the percentage is correct, you've admitted yourself that Java is an inadequate language, performance-wise.

And of course if you allow C or C++ that, then surely you must allow Java, C# or even Javascript the same, and you are back to where you started.

However unless you are in the business of writing operating systems I don't see any relevance of this line of reasoning.

There's a huge difference between a little abstraction and 100% abstraction. And if Java is so good, it would've been used for coding commercial operating systems

#39 way2lazy2care   Members   -  Reputation: 782

Like
0Likes
Like

Posted 22 March 2012 - 12:23 PM

There is something that has been on my mind for quite some time, why is C++ often considered as a primary language to beginners? and has anyone actually gotten far enough making a content rich game in C# with SlimDX / SharpDX similar to AAA quality games out today, where performance was so bad due to it being managed that C++ would have made a noticeable difference?

Sure theres benchmark threads, a tonne of comparison threads and a lot of opinions but has there ever been a case where a C# project using SlimDX / SharpDX has come to a halt because C# just wasnt good enough to perform and if there is how did they deal with it, something tells me it wasnt "port everything to C++".


I've seen a handful of games that were released on XBLA (not XBLIG) that started as C# projects but were ported to C++ in order to squeeze those extra couple drops of juice out.

#40 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 22 March 2012 - 12:37 PM

I think that Java is good enough for most applications on a modern system. However, if you are doing something that is low level or requires extreme performance, Java is out of the question. For example, I'm not aware of any GBA homebrew games written in Java.
I trust exceptions about as far as I can throw them.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS