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

#1 Robin123   Members   -  Reputation: 100

Like
0Likes
Like

Posted 17 March 2012 - 05:02 PM

Hey guys.

Im new to programming. I only started learning about a week ago. My plan was to go through Java and then move on to C++. My goal is to be able to make games (all sorts of games for all sorts of platforms).

I was just wondering if I should bother with Java or just skip it and go straight to C++?

When dealing with engines such as Unity, Cry-engine and the UDK is Java at all useful to know?

Sponsor:

#2 Cornstalks   Crossbones+   -  Reputation: 6985

Like
0Likes
Like

Posted 17 March 2012 - 05:05 PM

Look at the last post.

For the record, I will say that if you're new to programming, do not start with C++. It's a beast of a language.
[ 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 ]

#3 randy23   Members   -  Reputation: 100

Like
-2Likes
Like

Posted 17 March 2012 - 05:46 PM

This really depends on what your goal is. If you want to target many platforms as you want, I would said go for Java. But it seems you want to use those engines, most of them have their own scripting language and have an API in C++,. So better learn C++ if you want to use them.

Personally, I would say start with C++ because there is no great difference between the two languages from beginner's perspective. Since you are going to learn them from the very beginning anyway. And select one platform first for your initial project before targeting another platform.

#4 Promit   Moderators   -  Reputation: 7177

Like
3Likes
Like

Posted 17 March 2012 - 06:05 PM

I do not think you should skip anything in favor of C++. It's a terrible starting point. I'm not fond of Java and would push for Python or C# instead, but definitely not C++.

#5 mhagain   Crossbones+   -  Reputation: 7959

Like
0Likes
Like

Posted 17 March 2012 - 07:04 PM

C++ will burn you and make you regret things. You need a fairly deep understanding of various concepts, including all the nasty little dark corners of memory management, before you should take it on.

C# and XNA is a commonly recommended good starting point. I've no direct experience of it but from what people who's opinions can be trusted say, I'd support that recommendation. For now your ambition of "all sorts of platforms" is too much. You need to focus on just learning and understanding how the basic things work, and piling multiplatform on top of that is just going to make things more difficult. Instead getting something that will work well on a single platform, and that does a lot of the messy heavy lifting for you, will be better in the longer run.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#6 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 17 March 2012 - 07:07 PM

I'd also recommend Python over Java and C++. Python is designed to be beginner friendly and easy to code in.
I trust exceptions about as far as I can throw them.

#7 learner45   Members   -  Reputation: 99

Like
-1Likes
Like

Posted 18 March 2012 - 04:26 AM

Even though Python is designed to be user friendly (which i still doubt), its syntax is very different than C++ or Java.
Therefor i would suggest you to go on either C# or Java, then move on to C++.

Both C# and Java are taking care of alot of programming aspect for you already, so you can skip things and keep learning, and when you feel ready, you can start learning C++ and learn all those "dark corners" as mhagain has mentioned.

Good luck.

#8 Robin123   Members   -  Reputation: 100

Like
0Likes
Like

Posted 18 March 2012 - 05:39 AM

Thanks for all the help guys. :)

#9 arfo90   Members   -  Reputation: 102

Like
0Likes
Like

Posted 18 March 2012 - 06:12 AM

I was in same limbo years ago, when I just started with programming in college. The thing that I learned is, you should learn a language that helps you to understand important concepts in Computer science ( such as OOP) faster and easier. So if you go with C++ at this stage it will be harder (painful in fact) for you instead of Java or C#.

Personally I suggest to start with C# or Java to learn important concepts and after that you can switch to C++ (with much better perspective) anyway you can also start with some framework such as XNA (C#) to get familiar with concepts and techniques in a game software (such as collusion detection or applying basic AI). At the end all C++, C# and java are from C family so they share lots of thing with each other so it will be easy for you to jump from C#/java to C++.

cheers

#10 Storyyeller   Members   -  Reputation: 212

Like
1Likes
Like

Posted 18 March 2012 - 08:25 AM

Even though Python is designed to be user friendly (which i still doubt), its syntax is very different than C++ or Java.
Therefor i would suggest you to go on either C# or Java, then move on to C++.

Both C# and Java are taking care of alot of programming aspect for you already, so you can skip things and keep learning, and when you feel ready, you can start learning C++ and learn all those "dark corners" as mhagain has mentioned.

Good luck.


Java syntax is also very different from C++. C# is a lot closer. But I don't think there's a problem anyway. If you're going to C++ from a managed language, you're going to have to relearn a lot anyway, so a different syntax doesn't make things any harder. And it might even be an advantage because it stops you from trying to just do the same things, which is usualy a bad idea. (Ever seen Java coders write C++ which is full of void pointers and pointless dynamic allocations everywhere)?
I trust exceptions about as far as I can throw them.

#11 Kalner   Members   -  Reputation: 120

Like
-1Likes
Like

Posted 18 March 2012 - 08:07 PM

Listen to evreybody here, I made the mistake of starting with c++, probably going to c# because I will probably forget all syntax's for c++ if I go java. If you wanna go c++ later c# would probably be better because you will have a headstart with the different syntax's.

#12 Storyyeller   Members   -  Reputation: 212

Like
1Likes
Like

Posted 18 March 2012 - 09:33 PM

I don't see what the issue with different syntax is. I regularly program in both C++ and Python, and occasionally do Java too, and I don't have any troubles.
I trust exceptions about as far as I can throw them.

#13 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 18 March 2012 - 11:59 PM

Ok now I'm confused. I was notified of a reply to this topic, but there's no reply. What happened?
I trust exceptions about as far as I can throw them.

#14 Hiiri   Members   -  Reputation: 111

Like
0Likes
Like

Posted 19 March 2012 - 04:02 AM

I think most of the posters above are far more experienced programmers, but I aswell recommend going to anything else but C++. There are some things, that are good to understand from C++ though. References, pointers and copying variables is something, that C++ actually forces you to learn which I think is pretty useful.

I started learning programming from C++, but I honestly think Java and C# are a lot more better choises. A lot of people in this thread seems to suggest Python aswell, this is a language I never touched myself, but for some reason I honestly think you shouldn't start with Python, because there is huge possibility, that you will make too much mess with it, just because of the untyped nature of the language. At least I think you should learn the difference between ints, strings and not being able to write function in same way. I think this will be nightmare for new programmer, when there is like nothing guiding the programmer into good ways of programming, although this is only personal preference. I am pretty sure some people, who started learning programming from untyped language can easily tell, why it is better way of learning programming, than me who kind of hate untyped languages, because it is less error proof, but more painful at the same time.

So my recommendation is to start from Java or C#. Learn the concept of programming from either of the languages, because of the very strong object oriented way of programming. These languages give very good base of learning programming as a concept. Once you have an idea how to program, I personally think, you should look at C++ pointer/reference/arrays, and try to learn the idea behind of pointers. Once you grasp the concept of them, you'll learn why Java / C# passing of ints work differently than passing of object. Why changing stuffs in objects from one place affects the data seen from other places too(same instance, same values), and why it sometimes does not(different instanes with same values).

After this, it is not exactly hard to move from one language to another, except some of languages that base on completely different way of thinking like Haskell, which I haven't ever tried to learn tho.

Edit: Oh yeah, and I personally think if you go with Java/C#, you should start with console-programming, not the win forms / java swing.

#15 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 19 March 2012 - 08:59 AM

Actually, Python is strongly typed.
I trust exceptions about as far as I can throw them.

#16 Memories are Better   Prime Members   -  Reputation: 769

Like
0Likes
Like

Posted 19 March 2012 - 11:23 AM

I don't see what the issue with different syntax is. I regularly program in both C++ and Python, and occasionally do Java too, and I don't have any troubles.


Theres nothing wrong with C++ syntax, the syntax is fairly straight forward and easy to learn, I dont think anyone would have an issue with the syntax.

Theres a old book called 'Writing Secure Code 2nd Edition', I decided to get it a few months ago for the sake of writing secure code in .net, out of the whole book only one chapter was dedicated to managed languages while the rest was heavily focused on unmanaged languages and the problems associated with C/C++, ranging from buffer overruns, dangerous APIs, exploits etc

I only skimmed through the unmanaged sections as I wasnt that interested in C++ then and one thing I noticed the author say over and over was how easy it was for developers to forget about certain everyday problems and even worse how difficult it was to track it later. The book is about 10 years old so im not sure what rules still apply but from what I remember the managed section rules still applied even till this day and even then the chapter was mainly focused on SQL Injections more than anything with ASP.NET

E: Dont get me wrong I am not saying C++ is a bad language, I think it is a great language and reading C++ books has helped me greatly in ways I couldnt imagine with C#, but as for a first language it isnt a very good choice. In terms of ease, C# is a fantastic language and with the next features that will be available in the future (C# Scripting (Roslyn) like python, php etc, Async programming with minimum effort etc) it really does make it a easy, fun and efficient language to work with

#17 Cornstalks   Crossbones+   -  Reputation: 6985

Like
0Likes
Like

Posted 19 March 2012 - 08:39 PM


I don't see what the issue with different syntax is. I regularly program in both C++ and Python, and occasionally do Java too, and I don't have any troubles.


Theres nothing wrong with C++ syntax, the syntax is fairly straight forward and easy to learn, I dont think anyone would have an issue with the syntax.

One big problem with syntax and beginners is templates. Especially when you have:

std::vector<std::string> vector;
vector.begiin(); // or some other small error with the type

And then the compiler spits out the intimidating error:

error: ‘class std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >’ has no member named ‘begiin’

And the beginner goes, "WTF is class std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >??? What's going on!?" And that's just a simple example.

Another common one is misplacing a semicolon (maybe not putting it at the end of a struct or class) or brace, and the compiler spits out thousands of errors, none of which tell you that line 99 should have a semicolon or brace that you've forgotten.

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. Its general form really isn't that bad, but only once you get the hang of it and can understand what it is the compiler is complaining about.
[ 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 ]

#18 SimonForsman   Crossbones+   -  Reputation: 6107

Like
1Likes
Like

Posted 19 March 2012 - 09:45 PM



I don't see what the issue with different syntax is. I regularly program in both C++ and Python, and occasionally do Java too, and I don't have any troubles.


Theres nothing wrong with C++ syntax, the syntax is fairly straight forward and easy to learn, I dont think anyone would have an issue with the syntax.

One big problem with syntax and beginners is templates. Especially when you have:

std::vector<std::string> vector;
vector.begiin(); // or some other small error with the type

And then the compiler spits out the intimidating error:

error: ‘class std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >’ has no member named ‘begiin’

And the beginner goes, "WTF is class std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >??? What's going on!?" And that's just a simple example.

Another common one is misplacing a semicolon (maybe not putting it at the end of a struct or class) or brace, and the compiler spits out thousands of errors, none of which tell you that line 99 should have a semicolon or brace that you've forgotten.

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. Its general form really isn't that bad, but only once you get the hang of it and can understand what it is the compiler is complaining about.


I'd suggest that you take a look at the error messages and warnings that clang spits out, They are far more useful (Telling you exactly where you forgot that ; , preserving templated typenames as they are written and even correctly pointing out errors and warnings when macros are involved.

consider this:
template<class T>
  class a {}
  class temp {};
  a<temp> b;
  struct b {
  }

gcc spits out:
t.cc:3: error: multiple types in one declaration
t.cc:4: error: non-template type 'a' used as a template
t.cc:4: error: invalid type in declaration before ';' token
t.cc:6: error: expected unqualified-id at end of input

clang spits out:
t.cc:2:11: error: expected ';' after class
  class a {}
			^
			;
  t.cc:6:2: error: expected ';' after struct
  }
   ^
   ;

same language but the difference in the error message quality you get is huge. (clang however is still fairly new and has poor IDE support so its not really recommended for beginners, but it does show that the quality of error messages has far more to do with the compilers than the language and hopefully other compilers will follow suit in the near future and improve the way they report errors)
I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#19 daviangel   Members   -  Reputation: 600

Like
0Likes
Like

Posted 20 March 2012 - 12:12 AM

(clang however is still fairly new and has poor IDE support so its not really recommended for beginners

Actually, it's the default compiler in latest versions of XCode, so if you got a Mac you have no excuse Posted Image
On the other hand on windows I had to build it from the source and it was painful.
Speaking of Clang, if you want to know why C++ is a bad choice just watch this excellent video:
Clang: Defending C++ from Murphy's Million Monkeys

In regards to the original post you probably want to go with Java since it's pretty close to C# which is one of the supported languages for Unity, the other being Javascript which is even easier to learn.
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

#20 cignox1   Members   -  Reputation: 723

Like
1Likes
Like

Posted 20 March 2012 - 01:36 AM

If you want to target C++, then IMHO you should just decide between Java and C#. Python is nice and easy, but is too different (different syntax, different compilation model ...)

Usually this is not a problem at all, but if you want something that simplifies your path toward c++, then C# or Java.

And among these two, I would suggest Java: C# is a very beatiful language, but too much bound to Visual Studio: you could miss important steps performed by its features under the hood.
I suggest Java (notepad++ + javac at first) and then try NetBeans or Eclipse.

Mind you, that's just my opinion: if you pick C# instead that will work nonetheless.




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