Java or C++?

Started by
43 comments, last by rip-off 12 years, 1 month ago
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.
Advertisement
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.

int (&fn1(int (&arr)[4]))[4] {
typedef int (&fn(int (&)[4]))[4];
return arr;
}

???
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.
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.
Actually, Python is strongly typed.
I trust exceptions about as far as I can throw them.

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

[quote name='Storyyeller' timestamp='1332128000' post='4923185']
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.
[/quote]
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.
[size=2][ 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 ]

[quote name='Dynamo_Maestro' timestamp='1332177824' post='4923352']
[quote name='Storyyeller' timestamp='1332128000' post='4923185']
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.
[/quote]
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.
[/quote]

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)
[size="1"]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!

(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 biggrin.png
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.
[size="2"]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

This topic is closed to new replies.

Advertisement