Thread: C, C++ or C#?

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    1

    C, C++ or C#?

    I'm having a hard time choosing which of the C languages I should go for, asking which is best will probably get me nowhere as I bet there are some split opinions on that subject.

    But does anyone know the advantages/disadvantages with each one? As in what kind of programs the different languages are better than the other?
    I don't really care which is the easiest to learn or anything like that, I might aswell do it the hard way aslong as it's somehow rewarding in the end

  2. #2
    Beginner in C++
    Join Date
    Dec 2007
    Posts
    34
    I know almost nothing of C, I don't know many criticisms of C++ but I don't like C# Not necessarily because it's Microsoft, but it's largely not portable and as far as I know very similar to Java which is portable so I'd go with that.

    C++ is my favourite language by far though.

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    C++. You can do both C and C++ with it.

    C++ is all major platforms. That's my vote.

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    5
    I'm new to C++ and a long-time Java programmer, and as Caducer said, C# is very similar to it (I've studied a little bit of it), I'd say you better off with Java than C#... However, for the little time I'm studying C++, I already think it's much better than Java (hence, even better than C#). And as Todd pointed out, C++ is C-based, so you'll end up learning both. You can't go wrong with C++.

  5. #5
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Well the order of fastest running code is: C, C++, then C#.
    The order of easiest to use is probably the opposite: C#, C++ & C.
    The size of the language (smallest to biggest) would probably be: C, C++, C#.
    The portability (most to least) would be: C, C++, C#.
    The amount of code required to do a particular task (least to most) would probably be: C#, C++, C.

    http://en.wikipedia.org/wiki/Compari...ual_Basic_.NET
    http://en.wikipedia.org/wiki/Compari...ming_languages

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I'm having a hard time choosing which of the C languages I should go for
    C# is no more a C language than Java.

    >But does anyone know the advantages/disadvantages with each one?
    C is bare bones. If you want something, you have to write it yourself or find a library that someone wrote for you. Organizing large projects takes a lot of discipline to avoid a royal mess. However, you have absolute control, and that can result in very efficient software.

    C++ is only slightly better off than C in terms of available libraries. When you do anything in C++ you're still riding low in the saddle, so don't expect productivity to rival higher level languages. But C++ is as fast and powerful as C. Like C, it takes discipline to organize large projects, but not as much as long as you don't fall into the excessive-OO traps.

    C# is tied to a framework if you want it to be useful, and the framework is bulky and slow. However, the framework is very rich, so you can do a lot of complicated tasks with far less code compared to C and C++.

    >As in what kind of programs the different languages are better than the other?
    C is best suited to embedded systems or riding the hardware where C++ is either unavailable or overkill. C++ is best suited to back-end stuff like frameworks and compilers, or applications that need blazing speed. C# is best suited to rapid development Windows applications or Windows-based web projects that don't need amazing speed.
    My best code is written with the delete key.

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Probably the best thing really is to learn a bit of each one of them and then decide yourself, unless you have specific needs you would like to share with everyone.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Also bear in mind that programming is only 10% language and 90% programming skill. Yes, C++ is different from C, and C# is not like either of those two - but I have programmed in:
    C, C++, Pascal, Modula-2, Fortran, PHP, SQL, Lisp, Assembler (x86, 29000, 68000, VAX, PDP-11, 6502, Z80 and some others) - and it's largely about:
    1. Splitting the problem into manageable pieces.
    2. Solving the now manageable pieces in that language
    3. Presenting the results in a reasonable way.
    4. Finding and fixing any bugs in the code.

    Most of that is purely ability to understand the problem and solve small and large problems, and only a small part is about "How you express your algorithm in a particular language".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    > Well the order of fastest running code is: C, C++, then C#.

    I don't know anything about C#, but C++ isn't inherently any slower than C. It CAN be slower, if one decides to take advantage of easier ways of doing certain things in C++ without concern for speed, but that's a choice. The extra facilities can just be unused if need be. Some of them can help speed - for example, std::sort() can be significantly faster than qsort(). So overall I think code can be made faster with C++ than with C, if written with sufficient care.

    > The portability (most to least) would be: C, C++, C#.

    Almost any platform that has a C compiler also has a C++ compiler. Certain things can be done portably in C++ but not in C90, for example printing types such as size_t that lack a standard format specifier in C90.

  10. #10
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by robatino View Post
    > Well the order of fastest running code is: C, C++, then C#.

    I don't know anything about C#, but C++ isn't inherently any slower than C. It CAN be slower, if one decides to take advantage of easier ways of doing certain things in C++ without concern for speed, but that's a choice. The extra facilities can just be unused if need be. Some of them can help speed - for example, std::sort() can be significantly faster than qsort(). So overall I think code can be made faster with C++ than with C, if written with sufficient care.
    I agree C++ can be as fast as C for many things, but overall I think it's just slightly slower than C because it has some extra overhead that C doesn't have like exceptions, constructors/destructors...

    Quote Originally Posted by robatino View Post
    > The portability (most to least) would be: C, C++, C#.

    Almost any platform that has a C compiler also has a C++ compiler. Certain things can be done portably in C++ but not in C90, for example printing types such as size_t that lack a standard format specifier in C90.
    Yes, any "real" computer can use both, but embedded devices and such may not support C++, so depending on what you're using them for, C is a bit more portable than C++.

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by cpjust View Post
    I agree C++ can be as fast as C for many things, but overall I think it's just slightly slower than C because it has some extra overhead that C doesn't have like exceptions, constructors/destructors...
    I think you might mean that when writing "normal" C++ code, it's a little slower than C code
    But if you write C-typical C++ code, it's as fast or faster than C, depending on the algorithms you use.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    I'm not sure what you mean by "C-typical" code?

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    C code within C++, so to speak. Code where you mess around with pointers and arrays instead of std::vector and std::string and shared_ptr, etc.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Elysia View Post
    C code within C++, so to speak. Code where you mess around with pointers and arrays instead of std::vector and std::string and shared_ptr, etc.
    Well in that case you're not really using C++ are you? You're just compiling C code with a C++ compiler.

  15. #15
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by cpjust View Post
    Well in that case you're not really using C++ are you? You're just compiling C code with a C++ compiler.
    Not really. As long as it is part of the current standard defined for C++, it is C++. The language is clearly defined in the standard.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed