Sign in to follow this  

What am I un-aware of?

This topic is 4373 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I started with c++ as my first language, so I really don't know of anything any other way. So many people talk about how c++ is a waste of time and how things can be done much quicker in other languages. Is there any way someone can enlighten me on this? Thanks, Massive-war

Share this post


Link to post
Share on other sites
In C++, you have to make sure that you don't overwrite the end of arrays, that you don't use pointers after you've deleted what they point at, and that you actually remember to delete what you've allocated when you're no longer done with it. If you do something wrong, you may crash at that point in your program -- or you may crash in some other, seemlingly unrelated point, sometime later during execution. Debugging these kinds of errors can be hard.

In some other languages (like Python, C#, Java, etc), those things are taken care of for you; if you have an error, it'll immediately be caught and shown to you, and garbage collection will make sure you never have a stale pointer or memory leak (although you may still have an unintentionally growing store). The draw-back is that the execution speed of those languates is generally somewhat slower than a C++ program written by a team of experts.

Share this post


Link to post
Share on other sites
Im in agreement with hplus.

In c++, you have to worry about a lot more things, but because of that, you have a lot more control over how things are run.

People use c++ for many reasons:
-they have always done so. C++'s predecessor c was vastly popular just because, and so is c++.
-c++ gives you almost 100% total control over memory, execution, etc., just like assembly would, but its "better" for humans to read.
-"pure c++", that is, c++ without api's, isnt platform specific, so knowing c++ allows one to program for many platforms.

Share this post


Link to post
Share on other sites
Quote:
Original post by massive-war
So why do people use c++ then? Granted, it's fast, but would it be worth the effort in game development?

Massive-war


C++ is good for some things, but it is not (in my opinion) the best for most of the things people use it for. I would guess that the main reason that people use it a lot is that it's popular and they think that must mean it's good. Or maybe because that's the language they know and they don't want to take the time to learn another one.

Share this post


Link to post
Share on other sites
Some of these points are not quite as big a problem anymore. At least the express version of the latest VC++ does a lot of runtime checks in debug builds. Of course that doesn't help much if you never run into any problems during testing, because the bad code is in some rarely called place. But the idea of having the same checks like Java and co. for debugging while still being allowed to turn them off seems like a good compromise.

Share this post


Link to post
Share on other sites
using C++ is like driving a stick shift.
C#, Java are like automatic.
:-)

If your main goal is to get to the destination, you would prefer to use the fastest/safest vehicle... Many people who like to ship products (and make money in the process) hate C++. Bad programming/understanding of C++ can lead to hours of time wasted tracking and fixing bugs which could have been saved by using C# or Java or whatever...

Some people just drive stick shifts for the fun of it. Some people use C++ for the same reason.

Share this post


Link to post
Share on other sites
People learn C++ because for most coding JOBS it is still the standard. Or because most people use it (and so most tutorials and articles assume C++ knowledge).

You might like to just get a book or something on C# which you'll find pretty similar to C++ but with some useful additions as others have already said. It's getting more and more widely used in the (no-game) industry, and also lots of people on these forums are starting to use it so you'll still get lots of useful advice!

Share this post


Link to post
Share on other sites
Every language has its balance. If you want the best performance, learn assembly, but it will take the longest to develop. If you want to throw it together quickly, learn DarkBasic, but it will perform the slowest. In between, there's a whole myriad of languages, but each has its vices and virtues.

It seems that C++ may be going the way of assembly (not yet, but coming soon). It's just too much work to get the end result. I've programmed in C++ for years and have most of the functionality I need implemented, therefore, I'm comfortable with C++. On the other hand, starting out, it seems a bit much to be bothered with. If I were starting out right now, I'd probably go with C#.

Share this post


Link to post
Share on other sites
Personally, C++ wouldn't be the best language to learn programming with except for the wealth of referance materials. As an example, at least to me, Pascal is easier to read. What I like with C++, or really C in general, is that it is compact without being cryptically so, i.e. APL. It is a very simply language in that knowing every keyword and operator doesn't require much memorization while still being quite powerful and flexible. So it's a good distillation of the elements of application logic.

I think it is generally a good idea to do a survey of languages. Visual Basic since it is the macro language for MS Office and virtually every other Microsoft product. Python and LUA because of their widespread use as scripting languages. Java because of it's widespread use in web pages. SQL because it is simply so handy for data analysis such a making sense of performance data. Perhaps a bit of assembler so you understand what the compiler does for you and so you can look at the generated code to understand why a statement didn't do what you thought it should.

You'll find in your career that you need to use many proprietary languages for differant packages. Once you learn the basics of 10-12 languages and how to use a couple fairly well then yet another is no biggie. I've easily used over 100 languages over the years. Physician heal thyself? Programmer automate thyself! I program because I'm lazy and I will go to great lengths to get the computer to do mundane, repetitive and boring tasks for me. So any and all means to automate anything that I really don't want to do.

As far as what more should you know? The Standard Template Langauge (STL). Know the language? Good for you, but know the library that comes standard with it as well. You might as well learn MFC as well. It's a good way to learn how to use classes effectively in a program. Pariticularly since how to do everything it does without it is well documented, i.e. use Windows facilities. Learn how to use libraries and DLL's to reuse your code. Learn your IDE to full effect as well. With many applications it is often the shear weight of the functionality in total and not the complexity of individual functions that is the challenge, i.e. the 100k lines of code. The organization of the code and automation of the actual coding process becomes critical to getting done in a timely manner.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by massive-war
So why do people use c++ then? Granted, it's fast, but would it be worth the effort in game development?
Depends on your game. It's not worth it for some game genres. But things get trickier when there are parts in your game that really need the speed. Then you could write part of the code in C or C++ and part of it in some easier language. But you'd need to know two languages well (assuming you're a lone indie developer) and you'd need to write wrapper code so that C++ and the other language can communicate. Many think that it's not worth the hazzle and just write everything in C++. If their game ends up requiring lots of processing power, they need not worry about speed since they're already developing in a language that allows one to write almost as optimized code as possible.

Share this post


Link to post
Share on other sites
I think if you learn C++ well you can learn any other languages easily, because C++ is a relatively low level language. Having control of everything let's you have the flexibility of doing anthing. But of course your purpose is one of the most important parameter in determining which language to learn. If you need to communicate with hardware in your programs than I would exactly recommend c++ however if you have nothing to do with hardware than c++ would be a heavy burden for you.

Share this post


Link to post
Share on other sites
In the end most languages are compiled to machine (or byte for java) -code

The fact that C++ requires you to start with a lot of basic things lengthens development time rapidly this is why a good coder should try to reinvent the wheel all the time but in stead should look for libraries that feature the desired functionality


ok C# has its garbage collector and some other nice features, but if you design your software carefully you won t have trouble with memory leaks or horrible pointer crashes that seem to appear random


Since I use the STL I hardly have such bugs anymore. Its just a question of the right libraries and their proper usage

One think speaking for C++ is its huge source of reference code and the still huge community and a lot of people even in the industry still use c++ and will for still quite some time

What about the MONO project for linux? did they implement a good .net framework?
or did microsoft already try to stop it?

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
In C++, you have to make sure that you don't overwrite the end of arrays, that you don't use pointers after you've deleted what they point at, and that you actually remember to delete what you've allocated when you're no longer done with it.


Comments like the above usuallly come from people that try to use C++ as they did C. Proper C++ design techniques actually make C++ a very safe and robust language to use, without sacrificing much or anything in terms of efficiency. Using std::string instead of arrays of characters, using std::vector and other containers instead of raw pointers to new'ed arrays, using smart pointers instead of raw pointers, and using iterators to iterate over a container make C++ a very elegant, safe, and efficient tool. Couple all of that with templates and generic programming and you add type-safety and the ability to catch more errors at compile time instead of runtime compared to other languages and you've got one sweet programming experience.

Unfortunately, many people aren't well versed in proper C++ design and implementation, and it could be said that it's difficult to become an expert. I believe it's more difficult to find good resources like books to learn from, but after they are found and exploited, it's not much harder to become competent than many other languages.

Unfortunately, many people still think of C++ as "C with classes", and they end up doing more harm than good by passing on their faulty knowledge.

Share this post


Link to post
Share on other sites
yeah, i was surprised at university as they wanted to teach use c++

the gave us a cvs repository with prebuild classes and we had to enhance their code

it was really a mess, they used pointers all over, i think they have never heard of references *cough*

and what made me fed up was they repeated use of c strings with pointers

man whats the STL for then if they don t use it

that should just serve as an example why c++ is sometimes said to be c with classes

Share this post


Link to post
Share on other sites
C++ is somewhat faster and more portable than other languages (c# etc). I'm not going to get into a holy war on the subject, just to say that C++ is useful for game development since you are more or less coding to the metal (since often you want to use your own memory allocation routines, and other nasty optimisation tricks) . It also has far more opensource libraries and code examples available than any other language, which does make things a lot easier during development.

C++ has obvious pre-compiled inflexibility problems, however most people circumvent these by integrating a scripting language (ie, lua, squirel, python etc), so on the whole you still get flexibility at runtime (assuming you've designed the engine properly).

On the whole, C++ allows you to adopt strategies that may not be great examples of correct software engineering, however are nessecary to squeeze a few extra CPU cycles out for your engine, that are not possible with higher level languages.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by RDragon1
Unfortunately, many people still think of C++ as "C with classes", and they end up doing more harm than good by passing on their faulty knowledge.


I agree 100% with your entire post.

It really amazes me the way some people (especially on gamedev) talk about C++ as if it were some incredibly dangerous, low-level language. Admittedly, C++ forces you to make a conscious choice to go down the safe route (pointers are still available even though you have referencens as well, using the STL over C-style alternatives, etc.), but those safer choices are there and they do work.

What I find even more baffling is the way people suggest huge gains in development time through the use of other "higher-level" languages like C#. That's very true if you're primarily developing native GUI apps, but there isn't a huge difference when it comes to game development. Most of your core code is going to be logic and neat, compact C++ code can actually be a boon for development time there.

Don't take this the wrong way: I'm not saying C++ is inherently better than any other language, but it's certainly not worse. If you're already familiar and comfortable with C++, I really don't think there's any compelling reason to switch to another langauge for large projects. Personally, most of my projects are done in C++, with tools in C# and scripting in Python. Use the right tool for the right job.

Share this post


Link to post
Share on other sites
I find that if you are a decent C++ programmer, you've written your own ways to manage memory, etc or used a 3rd party library like boost. After the first or second project, those shouldn't be an issue. After that I think the time savings between game development in C++ vs Java isn't much if any. I personally don't believe language specifics to be the most difficult aspect of game development. Unless you are learning the language and game development at the same time. If that's the case, then ya, C++ has a slight learning curve in the memory management department. For a seasoned developer, this should be neither hear nor there.

Some of the issues I've had with Java are making sure that the user has a VM installed and also what version of the VM is installed. This can get tricky. For instance, lets say someone installed the oracle demo, which will install it's own jvm implementation and throw itself into the path. Now your game is trying to load with the oracle vm implementation and who knows what type of crazy results you'll get. You could spend hours trying to help a user debug this. It's a turnoff for people who get frusterated because they can't get your game to work, thinking they've installed the latested VM but really that old one was never removed and is still taking priority.

I imagine .net is a little better because you don't have all these implementations of the framework floating around. Though I'm sure there are some users who don't have the framework installed and won't want to install it just to try your game.

Share this post


Link to post
Share on other sites
Quote:
Original post by d000hg
People learn C++ because for most coding JOBS it is still the standard. Or because most people use it (and so most tutorials and articles assume C++ knowledge).

You might like to just get a book or something on C# which you'll find pretty similar to C++ but with some useful additions as others have already said. It's getting more and more widely used in the (no-game) industry, and also lots of people on these forums are starting to use it so you'll still get lots of useful advice!


Is it really fair to say that "MOST" coding jobs use C++?

The entire web development field, for example... does NOT use C++... and that is a VERY large field - not just for ecommerce sites, but also for all the enterprise applications sitting on the servers of all the businesses that need them in the WORLD... think of how many of these are out there...

Then you have to think about other business software (shipping applications, etc.) and even pre-packaged software. A lot of this stuff uses Java and C#, etc.

In fact, from my (small amount of) experience in the business world,when it comes to do a task - C++ is typically the last language you consider, unless there are some weird circumstances (like a true need for every last bit of juice - and no need for a GUI (e.g. a server application)).

Share this post


Link to post
Share on other sites
Keep in mind I am not attempting to state which is better, I am only mentioning here what I have seen from personal experience as a hobbyist programmer :)

While there are many arguments against C/C++ development taking a long time, there are loads of utilities to prevent developers from reinventing the wheel each time they work on a project.

Memory management/linked lists? STL
Media API for access to sound/video/input? SDL
Network access? Raknet, SDL_net, and others
XML parser/utilities? TinyXML
Scripting language? Lua, and others

Certainly these by themselves do not constitute a game engine (and by far there are many other libraries which fit into these categories), but consider too that (unless there are licensing issues involved), when a feature-set is required for a particular facet of the game engine, an existing library will be used to cut down on development time and to save reinventing the wheel. C and C++ are by far the most common and most accessible of the programming languages out there, thus it is in the budding game developer's interest to learn these languages.

Selecting a newer language (C#) or a scripted language (Python), or one which is (generally) unavailable on a platform other than Windows (Visual Basic), may result in limitation of options, tutorials, discussion groups, support, guides, walkthroughs, and source code examples.

While the number of lines of code may be more in a C/C++ program compared to other languages, I don't think this has much bearing on the "learning curve" difficulty factor, particularly considering the difficulty later faced when a programmer seeks out community support or online documentation!

Share this post


Link to post
Share on other sites
Thank you everyone

Massive-war

Note: And it's kind of weird. We're learning Java in our Computer Science class at school, and Java is relatively hard for me. I just love c++, no matter how hard/confusing/long it is to use, and it comes to me almost like native english. I don't know, I just get that feeling like I know what I'm doing with c++, and learning another language on more of a less-strict level might be more difficult.

Share this post


Link to post
Share on other sites
Quote:
Original post by massive-war
Thank you everyone

Massive-war

Note: And it's kind of weird. We're learning Java in our Computer Science class at school, and Java is relatively hard for me. I just love c++, no matter how hard/confusing/long it is to use, and it comes to me almost like native english. I don't know, I just get that feeling like I know what I'm doing with c++, and learning another language on more of a less-strict level might be more difficult.


I'm not sure what you mean by a "less-strict level," but once you start using higher-level languages more often I bet you'll find that you'd rather use them than C++.

Share this post


Link to post
Share on other sites
Quote:
Original post by Roboguy
Quote:
Original post by massive-war
Thank you everyone

Massive-war

Note: And it's kind of weird. We're learning Java in our Computer Science class at school, and Java is relatively hard for me. I just love c++, no matter how hard/confusing/long it is to use, and it comes to me almost like native english. I don't know, I just get that feeling like I know what I'm doing with c++, and learning another language on more of a less-strict level might be more difficult.


I'm not sure what you mean by a "less-strict level," but once you start using higher-level languages more often I bet you'll find that you'd rather use them than C++.


It's funny, because when I read that post, it reminded me ALOT of myself a year or two ago. For some reason I just thought C++ was easier to use..... the reality is though that you just feel more comfortable in C++, for whatever reasons (your used to it, or whatever....). Now that I'm comfortable in C#, I cringe when I look at C++ code [grin].

Share this post


Link to post
Share on other sites
Quote:
Original post by massive-war
So many people talk about how c++ is a waste of time and how things can be done much quicker in other languages. Is there any way someone can enlighten me on this?


You should choose the langauge you're going to use based on the problem you're trying to solve.

If you need to do something involving textfiles or repetitive system administration tasks, the quickest way to get an app up and running is to use a language like perl. If you want to make a text adventure (interactive fiction) like Zork, you should consider using a lanaguage like Inform or TADS. These languanges tend to be centered on solving a specific set of problems, while C++ is a much more general language.

Personally I don't think C++ is a waste of time - but you should investigate languages like Java and C#, so you can determine what language you should use on a project based on your needs.

Share this post


Link to post
Share on other sites

This topic is 4373 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this