C++ or C?

Started by
97 comments, last by Promit 14 years, 11 months ago
Been debating on which language to learn? C++ has OOP, but im not a big fan of it. There seem to be less resources for learning regular old C however so that is why I am a bit worried about it. I am looking to program for fun, and do a few games too. I am going with C or C++ becasue they are lower level, faster, and more powerful than the other options. I have some programming knowledge with perl but its limited to the basics. If you guys know any good books to pick up too feel free to list them.
Advertisement
There's no reason you couldn't use C++ to write C code with some niceties. For your purposes, something like Python or C# might be a better though. Any difference in speed is minimal and likely will never be an issue for you. Consult any of a number of "what language should I learn?" threads for more info.
[size=2]
It seems you have already narrowed down your choice to C or C++. I am going to give some general advise about why that might not be a great idea.

Quote:
I am going with C or C++ becasue they are lower level, faster, and more powerful than the other options.

Well, you have the "lower level" part right, but the others are not guaranteed. Simply put, a beginner probably will not be able to write the fastest code, in any language. Powerful doesn't have any precise meaning when applied to programming languages, so you would have to clarify what you mean when you say a language is "more powerful".

How well do you know Perl? The general consensus here is that sticking to one language until you know it well is a good idea. When you are a beginner, jumping between languages can cause confusion. I don't know if there are any good game programming libraries in Perl, but I am sure there are some.

If I had to choose between learning C and learning C++, I would learn C++. Not just for object oriented programming, but for its standard library, generic programming and RAII, exceptions, references and many more features. There are a lot more differences between C and C++ which you may not be aware of.

But if I had to choose between C++ and a more modern language then I probably would choose the modern one, something like C# or Python.
Quote:Original post by Sheepz
Been debating on which language to learn? C++ has OOP, but im not a big fan of it.

Why? OOP is a lot easier than plain old C. You may not yet be at the stage where you can see the benefit, but i can tell you it would be a lot easier to write a large application (like a game) in an OO language. Sure, it can still be done in C (GIMP is written entirely in C) but OOP just allows everything to come together a lot nicer.

Quote:I am looking to program for fun, and do a few games too. I am going with C or C++ becasue they are lower level, faster, and more powerful than the other options.

I think that's probably the other way around. low-level programming, while some find it fun, is generally a pain in the ass. Just look at string manipulation in C compared to C++ (with std::string). That is an example of how OO makes things a lot easier.
[Window Detective] - Windows UI spy utility for programmers
One more thing, I have been using the Bloodshed Dev-C++ complier and im running vista 64bit. I seem to be having issues with getting my programs to run. They compile fine and it ran fine once and now it just won't work. Any other compliers that are more compatible or should I just use commandline and notepad?
Quote:Original post by Sheepz
I am going with C or C++ becasue they are lower level, faster, and more powerful than the other options. I have some programming knowledge with perl but its limited to the basics.


1) Please tell me why you think being "lower level" is a benefit.
2) Please tell me what you think you're going to accomplish where being "faster" is going to be in the slightest bit useful.
3) Please tell me what you think "more powerful" even means in the context of programming langauges.
4) Please tell me what you think is "limited" about perl, or any other programming language for that matter.
Quote:Original post by Sheepz
One more thing, I have been using the Bloodshed Dev-C++ complier and im running vista 64bit.
Why you shouldn’t use Dev-C++.

The problems you're describing are probably not the fault of Dev-C++, though. I suggest you download Visual Studio 2008 Express Edition, try to compile/run your program there, and if you're still having problems, come back with a more complete description of the problem and people will be more than willing to help you out.

I would still second what everybody else says, though. C and C++ are complex languages that require a certain level of understand of programming in general before you can make the most of them. It's better to get an understand of general programming on a "simpler" language first. That's just my opinion of course, and if you're really set on C++ then nothing anybody here can say will stop you trying, I'm sure :-)
Quote:Original post by Sheepz
One more thing, I have been using the Bloodshed Dev-C++ complier and im running vista 64bit. I seem to be having issues with getting my programs to run. They compile fine and it ran fine once and now it just won't work. Any other compliers that are more compatible or should I just use commandline and notepad?


Use Visual C++ Express. Its free from Microsoft has the same compiler, and debugger as the professional edition and all the documentation you would need when first starting out. It's also the simplest to use, and its debugger is the best I've seen.

I would recommend C++, and I would recommend starting out with character arrays before trying out the string class contrary to Zahlman's quote. Yes, it will be harder than a language like C#, Python, or Java, but I find the results are much more rewarding from learning the harder way to do things before learning the easy way. It is much harder to go from knowing the easy way, to learning the hard way (and you are much less inclined to bother) - better to have a clean slate, and make sure to get a good solid foundation. I don't have a recommendation for a starting book, but I do think it's better to find a decent book than try to learn from tutorials.

I still usually use character arrays more often than strings, or if I want a string, I'll write my own class - the standard string class isn't that great. But, the point is, I learned a lot about the details of how memory is stored, accessed, and what pointers are by starting with the harder way first. In the end, you'll know more about why and how things work. But if you want the instant pay off, sure, go with an easy language that will handle all of your memory and bounds checking for you.

Still, there is really no benefit to starting with C as far was I can tell, unless you are interested in getting into systems programming, writing device drivers, and operating systems - that sort of thing. It is fairly straight forward to learn those areas from a C++ background as well. Either way, the first programs you write won't be object orientated even if you do try to use a class or two. I wouldn't even think about that sort of thing until you have basic syntax down after writing a few short programs and working with some data structures. Oh, and I wouldn't try to use any of those things rip-off mentioned either - not in your first programs. It's really important to learn the details well, than to learn everything poorly by trying to do too much too soon. Don't just learn the syntax and basic idea - know it, and know what it's actually doing - before moving on to higher concepts. Write lots of short, pointless programs. Reinvent the wheel every chance you get. Then, once you know it all, you can start to use libraries and fancy IDE's and all those other luxuries.

I'm really just giving this reply because I'm so tired of so many people always advocating the easy way, quick way.
Quote:Original post by Zahlman
4) Please tell me what you think is "limited" about perl, or any other programming language for that matter.


I think he means that his knowledge of perl is limited to the basics. Not that perl itself is limited.

This topic is closed to new replies.

Advertisement