Java or C++?
#1 Members - Reputation: 100
Posted 17 March 2012 - 05:02 PM
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?
#2 Moderator* - Reputation: 5400
Posted 17 March 2012 - 05:05 PM
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.
#3 Members - Reputation: 98
Posted 17 March 2012 - 05:46 PM
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.
#5 Members - Reputation: 3828
Posted 17 March 2012 - 07:04 PM
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.
#7 Members - Reputation: 99
Posted 18 March 2012 - 04:26 AM
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.
#9 Members - Reputation: 102
Posted 18 March 2012 - 06:12 AM
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 Members - Reputation: 212
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)?
#11 Members - Reputation: 120
Posted 18 March 2012 - 08:07 PM
#14 Members - Reputation: 111
Posted 19 March 2012 - 04:02 AM
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.
#16 Members - Reputation: 537
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 Moderator* - Reputation: 5400
Posted 19 March 2012 - 08:39 PM
One big problem with syntax and beginners is templates. Especially when you have:
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.
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.
#18 Members - Reputation: 3714
Posted 19 March 2012 - 09:45 PM
One big problem with syntax and beginners is templates. Especially when you have:
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.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)
The voices in my head may not be real, but they have some good ideas!
#19 Members - Reputation: 600
Posted 20 March 2012 - 12:12 AM
Actually, it's the default compiler in latest versions of XCode, so if you got a Mac you have no excuse(clang however is still fairly new and has poor IDE support so its not really recommended for beginners
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.
#20 Members - Reputation: 698
Posted 20 March 2012 - 01:36 AM
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.
This topic is locked





