Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Learning C/C++

What are the advantages to learning C++ over some of the other

languages out there? What applications/software groups use

C++?


Comments

  • : What are the advantages to learning C++ over some of the other

    : languages out there? What applications/software groups use

    : C++?




    C++ is popular right now. Whether or not it will survive depends on how much code gets written with it that must be maintained that way.


    C++, C... these are being used for damn near everything (including for things that they're not suited to).


    FORTRAN is still used quite a bit in heavily mathematical systems and modelling.


    COBOL is used quite heavily in mainframe business systems for databases and data processing.


    Pascal shows up every so often and has been made more popular by linking it indirectly with SQL and database manipulation.


    Visual Basic is quite popular for putting together a relatively stable visual user interface in very short order, but suffers a little from being a tad slow. Networking and database apps have a lot of support with this language.


    Java, of course, is the so-called language of choice for the web, at least for now. Shares many properties with C and C++, but is supposed to be 'safer' in terms of memory and resource management.


    There are lots and lots of others in active use.


    What are the advantages? Every language has its strengths. I could write a logical proof generator in C or C++, but having done one in Prolog, I must say that Prolog is far more appropriate. On the other hand, I wouldn't want to write a 3-d modeller in Prolog even though it's probably possible.


    To talk about the 'advantages' implies that certain features in C++ shine over all other languages in all situations. This really isn't true. However, we can discuss some of the properties that it has that make it _DIFFERENT_.


    C++ is only a little less efficient than C for most generated code. It is a compiled language, so differs from interpreted languages like classic BASIC and Java. (Okay, there ARE just-in-time compilers and the like for Java, but Java _was_ originally a p-code interpreted language and continues to be for most web situations). This means some source code gets turned into instructions that the machine on which it will eventually run actually understands directly.


    It however has 'classes', which differ from traditional C structures and Pascal records in that classes can have member functions that operate on 'instantiations' of the class. In the abstract sense, then, instead of giving a structure to a function to operate on, you call a member function inside the instantiation of the class that you want to operate on itself. In the actual generated code there is very little difference. It's sort of a convenience.


    Let's see...


    C++ classes also provide 'inheritance', where one class can 'inherit' the member variables and member functions from an 'ancestor' making extending a class or slightly altering the behaviour of a class possible without mucking with the original class.


    C++ classes also provide 'polymorphism', where a collection can be made of many different types of 'descendants' from a common base class and be able to interact with all of them in a uniform manner but elicit different behaviour.


    Classes, inheritance, and polymorphism aren't unique to C++ by any means. It's age-old. Smalltalk, for example, is a language used quite a bit that is even more flexible and powerful in these features, even if it is interpreted (as far as I know).


    C++ shares the property of exceptions with many advanced languages which are 'emergency measure' mechanisms (again a convenience for error handling rather than some unique property).


    C++ also improves on C's I/O a little bit (I like iostream classes a little more than C's printf/scanf family of functions).



    I think that the best language to _use_ is the one that is most convenient to solve the problem that you are given. C++ provides many conveniences over C, but quite often at the cost of run-time overhead in space and speed, for example. I've already mentioned my example of C++ vs. Prolog for logical processing, for another example.


    What is the best language to first learn? I'd like to say 'Pascal' because it is, in my opinion, much MUCH easier to read. For practical reasons, though, C or C++ might be better.


    I don't think one should ever stop at one language, however. I have long since stopped thinking in C or C++ when I want to solve a problem. I think in sort of abstract algorithms, or mechanisms, or ways of organization. Okay, okay, I do express it in C or C++ terms, even to myself, because it _is_ after all the language I'm most familiar with. However, I can envision a solution to a problem and apply the available language to it, or try to determine which language to apply to it.


    Languages aren't that different from a problem-solving point of view. A counting loop is pretty much the same in any language abstractly speaking even if you have to do something strange like implementing it recursively. A recursive descent of a binary tree is pretty much the same in any language even if you have to do something strange like implement the stack by hand instead of using function-calls.


    Learn C or C++ for this reason: They're popular, and people will be able to answer questions easily. Just don't make the mistake of assuming that they're the end-all and be-all of languages for all possible situations. It ain't. It's pretty good, mind you, but it ain't. It's the underlying solution that an implementation expresses that's important.


    End dissertation! =)




  • : What are the advantages to learning C++ over some of the other

    : languages out there? What applications/software groups use

    : C++?


    C++ is faster than other languages.

    Every kind of games can use C++ and

    also for example Win95 was coded with C++.


    Yo-Yo





  • : : What are the advantages to learning C++ over some of the other

    : : languages out there? What applications/software groups use

    : : C++?


    I agree with Mark (as I usually do), but wanted to point out something else about learning C++. In C, and other languages as well, you can pretty much see what kind of assembly code the compiler is going to generate, because C is a fairly low level language. In C++, it is much easier to use lots of the high level features of the language, and quickly lose grasp of what kind of code is really being generated. Lots of things are done that isn't explicitly in your code, such as constructors/destructors, dynamic binding, ..... You know they occur, but is easy to overlook these things and create a less efficient/elegant program. This even goes a step further with VC++, and is out of control with VB. Good programs can be written in these languages of course (though they have trade-offs as Mark showed), but it is much easier to write sloppy programs in higher level languages if your not careful.

    IMO, unless you just want to work on VB front-ends or SQL or the like, I would suggest starting in C. The language is high level enough to learn FAIRLY easily, and if you work with it some you'll start to see the 'tricks' that C++ uses, and how they actually work behind the scenes. If your aware of how a compiler structures the program, you will become a more efficient coder, both in terms of program efficiency and code maintenance. And these techniques can be applied to other languages afterwards as well.


    This stuff is a little more specific to C/C++, but that's my opinion. But when all is said and done, learning to structure algorithms abstractly and cleanly is what programmers should strive for. This only comes from time and experience with various languages, but it will happen. You'll love it when it all starts to click.


    Rock




  • : C++ is faster than other languages.


    This is not guaranteed to be true by any stretch. It depends on the compiler/interpreter implementation (general output and optimizations), the processor the executable is running on, and above all, the algorithms and techniques being used.


    A poorly written program in a compiled language can be outperformed by a well written program in an interpreted language.


    C++ is not inherently faster than any other language, because languages themselves don't have speed. Most compilers will produce C++ code that is in fact slower than comparable C programs because of overhead in some of the C++isms (especially if you don't turn off the features you don't need).




    : Every kind of games can use C++ and


    Any kind of game can be written in Pascal, or Perl, or Assembly, or Visual Basic, for that matter. It's a matter of using the right tool for the right job. Admittedly, most games today are probably written in a combination of C, C++, and assembly for the more time sensitive bits.



    : also for example Win95 was coded with C++.


    This is not, in my opinion, necessarily a feather in the cap of C++.





  • Hehe, sorry I work with a Mark Jones. Of course I meant Michael.


  • : Hehe, sorry I work with a Mark Jones. Of course I meant Michael.



    =)




Sign In or Register to comment.