Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Moving from Java to 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.

  • You cannot reply to this topic
21 replies to this topic

#1 Moe091   Members   -  Reputation: 579

Like
0Likes
Like

Posted 29 October 2012 - 02:02 PM

I recently decided to start learning a second language now that I'm quite comfortable with Java. I'm just looking for a few opinions on which ide to use, what I'm looking for is something that's free, or 'free,' that is well documented/used in a lot of tutorials.

I feel like the ide will have a bigger impact when learning c++ than it did when I was learning Java as I'll be using features other than the text editor much more often(correct me if I'm wrong), so I'm looking for something that is widely used and therefore easier to google anything I might need to find out about it.

I'm familiar with eclipse using Java, I'm not sure how good it is for c++ I know it's an option though. Just from googling around I see a lot of people who love VS but also a small subset of people who absolutely hate it. Also I don't know how hard it'd be to get without spending hundreds of dollars/how good the express edition is.

What would you recommend for someone who wants to learn c++ and eventually use it for much more complex programming?

for the record; I love intellisense, and I'm using windows 7 on a reasonably fast computer


EDIT:
this is my reply I posted further down, I just wanted to include it here so more people see it because I'd like to get some more feedback on it but it doesn't really warrant a new thread.

Thanks for all the great replies everyone! I think I'm going with Visual studio 2012 express(is there any reason that I might use 2010 instead?). I tried a few tutorials already just using visual c++ express cause apparently I already had it, but it always got build errors. just from simple hello world programs. I'm assuming It's something to do with my setup because i tried several tutorials copying the code exactly and they all got the same error. even the default hello world program errored. hopefully I wont have that issue in VS

I would recommend not using an IDE at first, actually. Using a toolchain of separate tools (initially this can be just text editor and compiler, with build control, memory analyzer, static analyzer, debugger added into the mix later one by one) lets you learn faster what is going on. Also, while you have a small amount of code, like just a couple of thousand or ten thousand lines, I don't see an IDE actually doing anything for you over separate tools.

Hmmm. that actually sounds like a good idea, my main goal here is to learn everything thoroughly and properly from the beginning so I can be a good c++ programmer soon. I think forcing myself to do that will help me learn things that I'd usually just happily ignore and let my IDE do it for me. How important and how hard is learning all that? Anyone else think this is a good idea?
Also while I'm here, should I start with c++ 11? I know nothing about the different versions, is it backwards compatible? is it or will it be the standard soon? which version do you recommend I start with and why? The only concern I might have about that is that its new and might not be as well documented, I love have a wealth of resources when learning something new and complicated like c++.
Anyone have any other general suggestions for learning resources or tips? I wanna learn this as thoroughly and as well as possible but I'm also eager to get my hands dirty with some real programming as soon as I can

Edited by Moe091, 30 October 2012 - 10:37 AM.


Sponsor:

#2 frob   Moderators   -  Reputation: 22779

Like
6Likes
Like

Posted 29 October 2012 - 02:16 PM

Visual Studio is the industry standard. It is an assumed knowledge; game developers don't list "visual studio" for the same reason they don't list "Windows" as a technology they know.

The free Visual C++ Express Edition is only missing only a few features you probably won't miss.

Learn it, embrace it, because like it or not you will be using it during your career.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#3 e‍dd   Members   -  Reputation: 2105

Like
2Likes
Like

Posted 29 October 2012 - 02:24 PM

I'm just looking for a few opinions on which ide to use, what I'm looking for is something that's free, or 'free,' that is well documented/used in a lot of tutorials.

The most popular free IDEs for C++ are probably, in no particular order, Visual C++ Express, Code::Blocks and Qt Creator.

I feel like the ide will have a bigger impact when learning c++ than it did when I was learning Java

Perhaps. For Java, an IDE as pretty-much mandatory though, as the build process is difficult to manage without one. In C++, it's doable (though non-trivial) without using an IDE.

I'm familiar with eclipse using Java, I'm not sure how good it is for c++ I know it's an option though.

I only tried the Eclipse CDT plugin ~5 years ago. It was awful then (too slow to be useful), but it might have improved by now. You could of course take a look at a recent version if you're sufficiently attached to eclipse.

Just from googling around I see a lot of people who love VS but also a small subset of people who absolutely hate it.

I'm one of the people that hate it (though I like the Visual C++ toolchain). Vim has spoilt me.

Also I don't know how hard it'd be to get without spending hundreds of dollars/how good the express edition is.

The express edition is probably fine. It certainly won't hurt for starters.

I will say though, that regardless of the IDE you pick, it's absolutely essential, IMHO, that you get to grips with the C++ compilation model early on. Once you understand this, you'll be able to fix your own problems easily, regardless of which IDE you pick.

#4 EddieV223   Members   -  Reputation: 1407

Like
1Likes
Like

Posted 29 October 2012 - 05:57 PM

The new vs2012 express is VERY GOOD. Also Eclipse CDT is pretty good, actually the most feature complete IDE in existence, however can be a bitch to setup and get working. And can be slow.

QT Creator is the best cross platform IDE in existence.

VS2012 is the best windows IDE with QTCreator the close second.

Code::blocks is ok but lacks many features, such as real syntax highlighting, and hasn't been update for 2 years.

If this post or signature was helpful and/or constructive please give rep.

 

// C++ Video tutorials

http://www.youtube.com/watch?v=Wo60USYV9Ik

 

// Easy to learn 2D Game Library c++

SFML2.1 Download http://www.sfml-dev.org/download.php

SFML2.1 Tutorials http://www.sfml-dev.org/tutorials/2.1/

 

// SFML 2 book

http://www.amazon.com/gp/product/1849696845/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1849696845&linkCode=as2&tag=gamer2creator-20

 


#5 Yrjö P.   Crossbones+   -  Reputation: 1412

Like
1Likes
Like

Posted 29 October 2012 - 07:32 PM

What would you recommend for someone who wants to learn c++ and eventually use it for much more complex programming?

I would recommend not using an IDE at first, actually. Using a toolchain of separate tools (initially this can be just text editor and compiler, with build control, memory analyzer, static analyzer, debugger added into the mix later one by one) lets you learn faster what is going on. Also, while you have a small amount of code, like just a couple of thousand or ten thousand lines, I don't see an IDE actually doing anything for you over separate tools.

#6 superman3275   Crossbones+   -  Reputation: 2061

Like
2Likes
Like

Posted 29 October 2012 - 07:57 PM

Brace yourself for the horrors of memory management. That is all.
However in all seriousness, some pointers:

1) C++ Is Unforgiving. Your code's errors can be extremely weird.
Example:
I had my Breakout game. In debug mode everything worked fine, however in release mode whenever the cursor crossed a certain Y position on the screen the game would just close. I eventually found out that I had an undefined Boolean value that I was referencing in a Class. The bug was annoying because it was working fine on my machine, which made pinpointing the error extremely annoying. And of course, the IDE in debug mode didn't give me the error (Or even a warning message).

2) Memory Management Tips
First Tip: Delete dynamically allocated memory as soon as possible. Whenever you do, set the pointer to null.
Also, try to use the new operator as little as possible. Using auto-pointers is fine, and you generally don't need the normal new and delete operators.

Also, I use Visual Studio, however there are many good IDE's. The debugger in Visual Studio is amazing.
I've used Code::Blocks. It doesn't have precompiled headers and the library support is good, however a lot of the auto-linking libraries don't work (SFML 1.6, as of now, doesn't work correctly).

It really doesn't matter which IDE you use. Just try them all out and see which one you like.

I'm a game programmer and computer science ninja ph34r.png!

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

 

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here smile.png!


#7 joew   Crossbones+   -  Reputation: 3679

Like
2Likes
Like

Posted 29 October 2012 - 08:19 PM

And of course, the IDE in debug mode didn't give me the error (Or even a warning message).

The reason is because it is not a warning or error to the language. Also this is a big reason that you should use initializer lists in all constructors to initialize the class members, or in the rare case that you don't (say in a vector4 or matrix44) you need to be careful never to use it until it has been assigned a value. Note the reason it works fine in debug mode is that values will be initialized whereas in release mode they are not.

First Tip: Delete dynamically allocated memory as soon as possible. Whenever you do, set the pointer to null.

I disagree with both. It is actually much better to reuse dynamically allocated memory at runtime than to delete and reacquire. I would only delete when it is no longer needed. Although this is really a non-issue if you are using C++11 due to having std::unique_ptr, std::shared_ptr, and std::weak_ptr.

Regarding setting the pointer to null after deletion this is something I absolutely disagree with and is just inviting bugs to linger in your codebase. By setting to null you won't catch any double delete errors, etc which would be found and handled easily by attempted to delete something that has already been deallocated.

Edited by joew, 29 October 2012 - 08:20 PM.


#8 Cromulent   Members   -  Reputation: 392

Like
0Likes
Like

Posted 29 October 2012 - 09:06 PM

Regarding setting the pointer to null after deletion this is something I absolutely disagree with and is just inviting bugs to linger in your codebase. By setting to null you won't catch any double delete errors, etc which would be found and handled easily by attempted to delete something that has already been deallocated.


This is something that is important in C so many C programmers carry this habit over to C++.

#9 SuperVGA   Members   -  Reputation: 1118

Like
1Likes
Like

Posted 30 October 2012 - 04:41 AM

As you're coming from eclipse i would recommend Code::Blocks and Netbeans. Eclipse CDT is ok,
but I don't like it's gdb integration. It doesn't keep the hook properly, and that makes threading even more of a pain.
Both Netbeans and Code::Blocks are fairly lightweight. VS is great too, but for small projects like mine, VS just seems too heavy.

#10 Moe091   Members   -  Reputation: 579

Like
0Likes
Like

Posted 30 October 2012 - 10:35 AM

Thanks for all the great replies everyone! I think I'm going with Visual studio 2012 express(is there any reason that I might use 2010 instead?). I tried a few tutorials already just using visual c++ express cause apparently I already had it, but it always got build errors. just from simple hello world programs. I'm assuming It's something to do with my setup because i tried several tutorials copying the code exactly and they all got the same error. even the default hello world program errored. hopefully I wont have that issue in VS

I would recommend not using an IDE at first, actually. Using a toolchain of separate tools (initially this can be just text editor and compiler, with build control, memory analyzer, static analyzer, debugger added into the mix later one by one) lets you learn faster what is going on. Also, while you have a small amount of code, like just a couple of thousand or ten thousand lines, I don't see an IDE actually doing anything for you over separate tools.


Hmmm. that actually sounds like a good idea, my main goal here is to learn everything thoroughly and properly from the beginning so I can be a good c++ programmer soon. I think forcing myself to do that will help me learn things that I'd usually just happily ignore and let my IDE do it for me. How important and how hard is learning all that? Anyone else think this is a good idea?

Also while I'm here, should I start with c++ 11? I know nothing about the different versions, is it backwards compatible? is it or will it be the standard soon? which version do you recommend I start with and why? The only concern I might have about that is that its new and might not be as well documented, I love have a wealth of resources when learning something new and complicated like c++.

Anyone have any other general suggestions for learning resources or tips? I wanna learn this as thoroughly and as well as possible but I'm also eager to get my hands dirty with some real programming as soon as I can

#11 alnite   Crossbones+   -  Reputation: 2133

Like
1Likes
Like

Posted 30 October 2012 - 12:16 PM

Hmmm. that actually sounds like a good idea, my main goal here is to learn everything thoroughly and properly from the beginning so I can be a good c++ programmer soon. I think forcing myself to do that will help me learn things that I'd usually just happily ignore and let my IDE do it for me. How important and how hard is learning all that? Anyone else think this is a good idea?


A command-line compiler is a great tool to learn. You will use it at some point in your career, and I'd recommend using that over an IDE at this point in time. IDE like VS can spout out error because of IDE config errors, not your code. This can confuse beginners a lot, thinking that their code is wrong while in fact, the IDE is messed up.

Also while I'm here, should I start with c++ 11? I know nothing about the different versions, is it backwards compatible? is it or will it be the standard soon? which version do you recommend I start with and why? The only concern I might have about that is that its new and might not be as well documented, I love have a wealth of resources when learning something new and complicated like c++.


I don't know much about C++ 11, but last time I tried to use it, the compilers have yet fully support all the features of C++ 11. You will get different results depending on which compiler/IDE you use (GNU, VS). I would suggest that you stay away from it for now. It's an extension of the language, not a whole redesign, so you won't miss a thing.

Anyone have any other general suggestions for learning resources or tips? I wanna learn this as thoroughly and as well as possible but I'm also eager to get my hands dirty with some real programming as soon as I can


I would focus on pointers, ctors, and dtors, as that's one of the main differences between Java and C++. When objects are allocated/deallocated in C++ is a whole different thing.

#12 Yrjö P.   Crossbones+   -  Reputation: 1412

Like
0Likes
Like

Posted 30 October 2012 - 01:53 PM

Also while I'm here, should I start with c++ 11? I know nothing about the different versions, is it backwards compatible? is it or will it be the standard soon? which version do you recommend I start with and why? The only concern I might have about that is that its new and might not be as well documented, I love have a wealth of resources when learning something new and complicated like c++.

It's "backwards compatible" in the sense that pretty much all older C++ code is valid C++11 code as well.
I would say yes, use C++11 features as much as your compiler of choice supports. It makes the code more readable, more compact and more efficient. GCC as well as Microsoft's compiler both have decently wide support and are constantly getting more. Clang is getting there too, but slower.

#13 Moe091   Members   -  Reputation: 579

Like
0Likes
Like

Posted 30 October 2012 - 01:54 PM

ah I see, I was confused about c++ 11 thanks for clearing that up. I'll definitely just stick to 'regular' c++. I'm gonna download a compiler and just get started with that and notepad, does it matter much which compiler I use? Which would you guys recommend I'm just looking for something popular and standard. I didnt look into compilers much yet so sorry if that's a stupid question

#14 Álvaro   Crossbones+   -  Reputation: 13933

Like
0Likes
Like

Posted 30 October 2012 - 02:39 PM

I like g++, but I am not sure how people normally use it under Windows (I have used it under Linux, Solaris and Mac OS/X).

About memory management:
* Don't do your own dynamic memory allocation: Use local variables and standard containers instead.
* If you really need dynamic memory allocation, use a smart pointer like std::shared_ptr.

If you feel tempted to use `new' (which I know is a common tendency in Java programmers), resist your urge. You probably don't need it. If you can't figure out how to avoid it, post here and we'll probably be able to help.

#15 DoctorGlow   Members   -  Reputation: 836

Like
0Likes
Like

Posted 30 October 2012 - 03:10 PM

I like g++, but I am not sure how people normally use it under Windows (I have used it under Linux, Solaris and Mac OS/X).

About memory management:
* Don't do your own dynamic memory allocation: Use local variables and standard containers instead.
* If you really need dynamic memory allocation, use a smart pointer like std::shared_ptr.

If you feel tempted to use `new' (which I know is a common tendency in Java programmers), resist your urge. You probably don't need it. If you can't figure out how to avoid it, post here and we'll probably be able to help.


I'm sorry alvaro, my fat finger clicked on "down" arrow rather than "up" for your reputation points.

#16 Moe091   Members   -  Reputation: 579

Like
0Likes
Like

Posted 30 October 2012 - 03:31 PM

I can tell this is gonna be fun already lol, it is surprisingly hard to google how to use c++ without a compiler. I tried winging it, I wrote a hello world in notepad and saved it as hello.cpp, navigated to the directory in command prompt and typed the command i finally found on google (c++ hello.cpp -o hello.exe) and I get an error saying 'c++' isn't a recognized command, so I'm assuming I have some more setup to do with my compiler(using the c++ compiler i downloaded with the microsoft sdk) in order for it to recognize the command. Can anyone help me or tell me what to google, I'm having trouble getting results related to my problem, just a bunch of stackexchanges about much more complicated questions than mine, ill be searching in the meantime.

EDIT: forget all my edits, I found the path to the VC compiler by running the VC command prompt, it's the default path for it.

Thanks again for all the help everybody

I like g++, but I am not sure how people normally use it under Windows (I have used it under Linux, Solaris and Mac OS/X).

About memory management:
* Don't do your own dynamic memory allocation: Use local variables and standard containers instead.
* If you really need dynamic memory allocation, use a smart pointer like std::shared_ptr.

If you feel tempted to use `new' (which I know is a common tendency in Java programmers), resist your urge. You probably don't need it. If you can't figure out how to avoid it, post here and we'll probably be able to help.


thanks, I probably would have been using 'new' like crazy haha. These are the kind of tips I need

Edited by Moe091, 30 October 2012 - 04:17 PM.


#17 Yrjö P.   Crossbones+   -  Reputation: 1412

Like
1Likes
Like

Posted 30 October 2012 - 04:20 PM

First, I reiterate you'll definitely want to use C++11, even more so if you want to keep things 'regular'. If you try to keep your code conforming to the ancient C++98 standard, you'll need to use much more nonstandard libraries like Boost to accomplish basic things that in C++11 are in the standard library, and there's really no reason to do that.

The tools you get in MinGW are the most standard, best documented stuff you can find. Initially you just need to use the gcc compiler, but you'll also have the gdb debugger and make build tool waiting for you for later.
With gcc installed, you'll want to use
g++ -Wall -Wextra -std=c++11 -o hello.exe hello.cpp
to compile your Hello World. If the gcc is slightly older version, you'll need to use -std=c++0x instead of -std=c++11.

As for editors, Notepad is terrible. At the least, use Notepad++ or equivalent. The heavy hitters, Vim (my favorite) and Emacs are great but take some learning to use. Sublime Text is both easy and powerful, but is only free for evaluation, and continued use requires buying a license. The license is cheap, though.

Edited by Stroppy Katamari, 30 October 2012 - 04:24 PM.


#18 Altruist   Members   -  Reputation: 135

Like
2Likes
Like

Posted 31 October 2012 - 01:17 PM

I recommend, assuming you're on Windows, NetBeans/C++ on MinGW. Eclipse/CDT is more professional, but NetBeans is just friendlier for beginners.
MinGW is the Windows implementation of GCC. You can get vanilla MinGW or The Dragon MinGW which supports x64. GCC which is currently the de facto compiler of choice for *nix users, though LLVM is starting to come up strong.
For the (mostly) complete *nix experience, I'd get the MSYS setup available from the main MinGW distribution. Your new favorite phrase will become
[source lang="bash"]./configure --prefix=/mingw && make && make install[/source]
For a complete MinGW setup, I'd check out this site: (Warning: LENGTHY, BUT WORTH IT.)
http://ingar.satgnu....gw32/index.html

Moving from Java though, as stated above, the biggest issues is memory management. Every object you allocate NEEDS to be deleted. Pointers go hand in hand with this one. Are you sending to a pointer to an object or a pointer to a pointer to an object? This will become important later on in your explorations.
For leaks, I found this, but haven't gotten around to using it (I tend to do things by hand - and consequently rarely get things done.)
MPatrol (Setup for MinGW)

As for libraries, the best things in life are free, or so I've been told.
For standard everything but the kitchen sink library needs, the Boost Libraries will cure what ails you.
SDL is the game library everyone starts with. (You'll also want SDLImage, SDLNet, and SDLMixer.)
SFML is an excellent "next-step" game library.
For pure 3D, you've got Irrlicht and Ogre3D.

Edited by Altruist, 31 October 2012 - 01:20 PM.


#19 ChaosEngine   Crossbones+   -  Reputation: 2502

Like
1Likes
Like

Posted 31 October 2012 - 04:39 PM


Hmmm. that actually sounds like a good idea, my main goal here is to learn everything thoroughly and properly from the beginning so I can be a good c++ programmer soon. I think forcing myself to do that will help me learn things that I'd usually just happily ignore and let my IDE do it for me. How important and how hard is learning all that? Anyone else think this is a good idea?


A command-line compiler is a great tool to learn. You will use it at some point in your career, and I'd recommend using that over an IDE at this point in time. IDE like VS can spout out error because of IDE config errors, not your code. This can confuse beginners a lot, thinking that their code is wrong while in fact, the IDE is messed up.


I disagree. Do you want to learn the language or the toolchain? If you're learning a language, the error is far more likely to be in your code than the IDE config. The same cannot be said of command line compilers. I'm not saying they're not a useful tool, but I don't feel they're helpful for beginners.

Regarding setting the pointer to null after deletion this is something I absolutely disagree with and is just inviting bugs to linger in your codebase. By setting to null you won't catch any double delete errors, etc which would be found and handled easily by attempted to delete something that has already been deallocated.


I disagree with your disagreement Posted Image
Deleting an object doesn't necessarily overwrite the memory. It's quite common for code like this to work
struct Thingy
{
    int Something;
};

Thingy* thing = new Thingy();
thing->Something = 42;
delete thing;
ASSERT(thing->Something == 42);
If you set the pointer to null, this will blow up (a Good Thing™). If not, then you have an intermittent runtime problem that's a nightmare to debug. I'd argue that's a more serious error than a double deletion, as deleting a null pointer is officially safe.

Of course, as you said, you should really be using smart pointers and avoid the whole mess anyway!Posted Image
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

#20 e‍dd   Members   -  Reputation: 2105

Like
4Likes
Like

Posted 31 October 2012 - 06:14 PM

If you set the pointer to null, this will blow up (a Good Thing™). If not, then you have an intermittent runtime problem that's a nightmare to debug. I'd argue that's a more serious error than a double deletion, as deleting a null pointer is officially safe.

I think the point is that it's a very good idea to ensure that cleanup of a resource (e.g. deletion) coincides with the lifetime of the handle to that resource. So, there shouldn't even be a pointer to dereference once the resource's destructor has been called and memory deallocated e.g.

{
	scoped_ptr<X> px(new X); // or shared_ptr/unique_ptr/...
	// ...
}
// Can't even use px here because the lifetime of the resource is bound to the lifetime of an object.
// Access to a deleted object via a dangling pointer is impossible.

In other words, if there's an opportunity to ensure you're doing something that's correct-by-construction, rather than correct-by-convention, take it.

Somewhat more on topic, I have a lot of sympathy for the suggestion that you start without an IDE. It will certainly help you understand C++'s compilation model sooner, which as I said is a good thing for diagnosing build problems. But I personally might not go so far as to recommend an IDE-less approach, initially.

Edited by e‍dd, 05 November 2012 - 12:45 PM.





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