c++ or not c++ thats the question

Started by
28 comments, last by NLDEV 18 years, 2 months ago
Quote:Original post by Takaloy
c# is like a CRV, easy to drive, easy to use, easy to learn.

C++ is a F1 Ferrarri. It's difficult to grasp, but much better in terms of performance compared to c#.


Define preformance.

For a business app, I'd most likely define this to be "how fast can I get it to the shelves/my employer". A RAD (Rapid Application Development) toolset, and simple-to-use language win here, not C++, with it's big can of "undefined".

For a typical FPS, I'd most likely define this to be "how fast can I get my framerate with the latest graphics". Most of this work is done by your graphics card. Hardware engineering and shader languages win here, not C++.

For some AI-heavy strategy games, or some games with whackilly expensive physics simulations, or scientific number crunching, C++ may win. CPU or Memory tends to be the main factors here.

Languages that are not C++ have some or all of the following advantages in those two categories:

CPU:
* Garbage Collection: No need to clean up blocks if the program terimnates before running out of memory. Can relocate memory blocks used at the same time together, reducing time spent waiting for pages to load. No counter (de)incrementation for reference counting multi-owner objects.
* Platform-specific JIT: No need to target the lowest common denominator of CPU instructions and optimization techniques, can be custom tailored to local system.

Memory:
* Garbage Collection: No memory leaks. Can reduce fragmentation by similarly relocating memory blocks.

Thus, C++ may still be a loose for systems with both of those problems as limiting factors.

There are few reasons I still use C++. Among them:
1) It's the language I'm most familiar, and thus comfortable, with.
2) RAII for non-memory resources seems harder with many GCed languages (see 1).
3) I hate that the garbage collector can run at basically any time, for an unbound length of time.

I will eventually stop using C++ except for legacy support, reason being:
1) I'm working on learning other languages, if only to steal their ideas.
2) RAII for non-memory resources is quite doable with many/most/all GCed languages.
3) Garbage Collectors are becomming freakin' uber.

Quote:with that said, I think C++ is the best beginner's language. The most important thing is to build up the type of mind set, avoiding sloppy programming because C++ is , err... less forgiving.


I'll disagree here!!! Define "less forgiving". For me, to finish that sentance, I'd say "less forgiving means random undefined behavior at runtime and hard-to-track bugs instead of compiler errors and a system which dosn't allow many bugs to surface in the first place". This would be a definate disadvantage for C++, taking time away from learning to avoid sloppy habbits by forcing you to invest in learning how to use a memory leak detector, among many other bits of knowledge required to get your program running once more.

Quote:If you are already fairly good in C++, other languages come in a click.


Is this because C++ is a superior learning instrument, or because C++ is simply the hardest to learn, and the relative ease of learning another language simply the contrast between learning C++, and said other languge?

Quote:Assume that you're learning to ride a bike on 2 wheels instead of the 4-wheeled type (the ones you see on kid's bike), when you can ride pretty well the 4-wheeled bicycle should be a piece of cake.


I learned to ride a trike before a bike-with-training-wheels, and a bike-with-training-wheels before a bike. I had a lot of fun being able to go places before I was able to learn how to balance, which helped fuel my motivation to learn how to do the same thing without said training wheels. Being able to steer and turn the pedals made learning to balance a whole lot easier. Maybe if you're masochistic, falling a lot while you learn how to steer and turn the pedals would be your idea of better. Certainly not mine though.
Advertisement
Quote:Original post by Enselic
But when you started to ride a bike, you didn't start with 2 wheels, right? You hade 2 other smaller wheels mounted on the sides. Then when you learned how to hold your balance pretty well, you removed these.


Nope, I never had training wheels, and I started when I was 4. Fell of about twice before I learned how not to fall off when I lost my balance. EDIT: And that's the point isn't it. Not learning how to balance, but learning what to do when you lose it, as is bound to happen.

Similarly language wise. Started at 12 or 13 (can't remember) with c++. Took a bit to get the hang of, but I think it was worth it.
___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!
Quote:Original post by pulpfist
Quote:
So, I get rated negatively for expressing opinion?


If I was here with the sole purpose of making my rating shine, rating you down would be a good start :D


LOL!!!
I can't stop laughing at this.
Quote:Original post by Takaloy
Quote:Original post by pulpfist
Quote:
So, I get rated negatively for expressing opinion?


If I was here with the sole purpose of making my rating shine, rating you down would be a good start :D


LOL!!!
I can't stop laughing at this.


Umm... Ditto. (It's bold :D.)
MM, you are most probably right. Development time is essential these days, like Benjamin Franklin once said "Time is Money". I won't say though GC is the most perfect thing on earth. For example, in a simple Library System we usually reference books to their titles instead of sub-classes. Say, if one of these classes are no longer in use, but still being referenced to, they will never-ever-be-deleted.

The advantage of C++ has over C# is you have more control over your program, you know exactly what your program is going from A-Z. Basically the difference between manual and auto-pilot I guess. I think it all depends on which language is most suitable for a specific situation. For example, if my employer has a tight constrain on development time but can afford good machines then C# is the way to go. If say, my hardware constraints are that the machines that are running this program are the 486s, and PIs then I have to think about maximizing performance. I don't remember seeing any C++ code declaring every member a virtual for a reason ;), not that I've seen alot of coding in the first place.

Personally I started off with 2 wheels, but I'd assume if I started off with 4 wheels I'd still trip and fall on 2 wheels during the transition process. I might have picked up some really nasty habits like the tendency to hold the handle stiff or turn too quickly which might be difficult to break.

Amongst all the languages I've came across (pascal,c,VB,C++,Java,C#), I agree with you C++ is the hardest. But in terms of efficiency, C++ is a mile ahead of C#. In terms of development time, I don't see Java losing any ground to C#, infact the 2 programming languages are almost similar I'd lean more toward Java because it's platform independent (or rather I might be BIAS because it's my main language).

Then again, we're in this forums ... called gamedev.net. At the moment, the gaming industry are the pioneer users of top-end hardware and I dare say that it'd be atleast 6-7 years before the hardware catches up to the level where micro-management of your code can be negligible.

Even so, if you're potent with C++, C# should be a piece of cake for you. But, if say the thread starter want to join the gaming industry and the "change" everyone is predicting did not happen - he won't make the cut. I heard of companies who reject applicants getting 97% for their C++ test.
Speaking as a moderator, can I remind people that a thread in 'For Beginners' is not the place for long-winded language discussions? I don't think all the complexities and religious issues help the original poster, and the comment on ratings is way off-topic.
I think the primary concern for the OP is whether or not he/she plans to pursue a professional game development career, in which case C++ is likely your best choice. If it's strictly hobby, go with something you can be more productive with like C#. Very few game developers use non C++ languages. Hobby programmers shouldn't feel restricted.
Quote:Original post by tldalton1622
Hello everyone.

I've been learning c++ on and off for a year or so. I've seen several posts that say someone shouldn't learn that language first. Now im curious if i should give up on it for now and try something else like darkbasic. Or just stick with it. I don't really care about how long it'll take me to consider myself a "good" programmer. I just like to learn how to make games and maybe down the road get a job as a programmer. Also, i dont want to just jump to another language but if it'll be easier to produce games......


Well, as you've probably realized by now, C++ isn't the easiest language to get started with. That doesn't mean you shouldn't start with it however, just that you might get started faster if you start with another language.

But whatever you do, *don't* pick the language you start with based on "what will I need later on?". All you'll need is *programming* expertise. And that can be learned from any language.
C++ knowledge is relatively easy to add on once you've got the general programming experience. So don't feel that you'd be "wasting time", or taking a "slower" route if you switch to a language like Python, C# or Java (All of which are a lot easier to work with). All you're doing is saving the pointless language quirks for later, allowing you to focus on actual programming to begin with.

But in the end, I'd just say that no, "C++ or not C++" is definitely *not* the question. It's not as big a deal as beginners always think it is (and will happily tell each others it is).
The more languages you learn, the better, and the faster you'll be able to pick up something new. If you think it's slow going with C++, then take a look at another one. You'll definitely be able to use your knowledge of C++ to kickstart that. And then you can use what you learned from that other language, to help you when you go back to C++ later on.

So basically, don't worry. Switching languages doesn't mean you're chickening out or giving up. It won't even slow you down, most likely. But if you feel you're making good progress with C++, then you might as well stick with it.

And finally, I just want to toss in a few quick remarks here:
Quote:
If you are already fairly good in C++, other languages come in a click.

Yes, in the same way that if you're fairly good at driving a Toyota, Ford will come in a click too.
Yes, it's perfectly true, but it's completely useless because the reverse is just as true. But of course, someone who started with C++ will only see that "Hey, I started with C++, and other languages come easy. Hence, C++ must be the best starting language". Big flaw in that logic...

Quote:
with that said, I think C++ is the best beginner's language. The most important thing is to build up the type of mind set, avoiding sloppy programming because C++ is , err... less forgiving.

Not true. C++ is quite forgiving in many ways.Half the time, it forces you *into* sloppy programming, or at the very least allows you to get away with it (or even worse, allows you to compile, but then forces you to spend the next week debugging an error that other languages would have been caught at compile-time)
This is another typical "I started with C++, hence C++ must be best"-comment.
You're right, the most important thing is the mindset, but that is something all languages teach. And in fact, they teach it best when they allow you to actually *program*, not when they force you to spend 3 days tracking down a random crash
So no, there are many languages that are better at letting you build up a programming mindset, mainly because they allow you to actually *program*, that is, attempt to break up problems into small enough chunks to feed to a computer. If you can do that in one language, you can do it in any language. And it has nothing to do with C++ being more or less "forgiving".
Hi,
You mention you might switch to Dark basic to make games. Programming games with Dark Basic is alot easier than using C++. With Dark Basic, you can set the screen resolution with one line of code, create an object with another line of code, texture the object and display it with another couple of lines of code. But how many game companies employ Dark Basic programmers? Do not throw away your years C++ programming. Try both languages and see which one really suits you. I am sticking with C++, but the choice is yours. Goodluck!
Quote:Original post by h3r3tic
Quote:Original post by Enselic
And besides, you will have to compromise runtime speed for developing speed. The higher you go in programming languages, the more speed you will sacrifice. To me, and I guess most hobbyists, this sacrifice is worth it.


This is not necessarily true. C# compromises runtime speed because it's an interpreted language.


Incorrect. C# is not interpreted. It is compiled to CIL (Common Intermediate Language); which on execution, on any runtime worth its salt, will be JIT compiled to native machine language.

This topic is closed to new replies.

Advertisement