Which Is Closer To This Type Of C++ (C# Or CLI)?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Which Is Closer To This Type Of C++ (C# Or CLI)?

  1. #1
    Join Date
    Jan 2012
    Posts
    11

    Which Is Closer To This Type Of C++ (C# Or CLI)?

    In my previous class we used the text book "Starting Out With C++ Early Objects (7th Edition)".

    Here is a link to the book (to view the code within this book):
    http://www.amazon.com/Starting-Out-E.../dp/0136077749

    I've played around with both C# and CLI in Visual Studio, and I've gotten the hang of both.

    I'm about to write a program, and I'm trying to decide which type of C I should write it in.

    My question is which type of C++ is "more closely" related to the C++ taught from this course book?

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,585

    Re: Which Is Closer To This Type Of C++ (C# Or CLI)?

    I couldn't find any code samples from the book behind the link you posted, but the probability of any textbook about C++ used in any given course actually being about C++/CLI is very close to zero (in particular if the students taking the course aren't even sure whether it's native C++ or C++/CLI). So the language taught can be assumed to be native C++.

    Keep in mind my words from the comparatively extensive breakdown on programming languages in http://www.codeguru.com/forum/showthread.php?t=519948:

    Quote Originally Posted by Eri523 View Post
    [...] Developers using C++/CLI must be aware that, despite the similar name, it is not just a C++ compliler for .NET; it rather is an entirely different language of its own. [...]
    So the bottom-line answer to your question in this thread here most probably is: If you want something akin to native C++ as much as possible, take native C++ (and in particular neither C++/CLI nor C#).
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Jan 2010
    Posts
    1,099

    Re: Which Is Closer To This Type Of C++ (C# Or CLI)?

    Unlike C++/CLI, C# is not another type of C++, it's a completely different language. (Although similar in syntax, as it belongs to the same family of languages, the C-language family. So does Java, to whom C# is more related in terms of general language design principles. But quite a lot better, if I may be so bold... )
    You can't write C/C++ code in C#.

    It's a common misconception: often here on the forums, you'll see people asking questions about "C/C++/C#" or "C/C++/CLI/C#", but there is no such thing.
    There's C, there's C/C++ (what we normally call C++; it was built on top of C), there's C++/CLI (managed C++ (.NET)).
    And there's a completely different, although in some ways similar language called C#.

    Now, all that said, if you want to do .NET development, you would either go with C++/CLI or C#. Learning the syntax and the basics of the language in either case is not such a big deal - what you need to learn in order to do .NET development is the basics of .NET (what are value types and what are reference types, what fundamental types are there, basic design philosophy regarding classes and interfaces, etc...), and of course to obtain a working knowledge of the .NET framework library.

    Other that that, how you use the .NET library is pretty much the same across both C++/CLI and C# (except for some language specific nuances). However, there's another thing you have to be aware of: when it comes to the latest .NET technologies (those built on the basis of .NET 2.0, like LINQ, WPF, WCF...), only C# provides direct IDE support, or syntax support in case of LINQ (Eri523 will correct me if I'm wrong for some specific case), making development of those types of applications quite cumbersome in C++/CLI.
    A major disappointment on Microsoft's part, if you ask me...

    Nevertheless, C++/CLI is a great language, and is quite powerful.
    People mostly use it to bridge native (usually legacy) and managed code, since C++/CLI "walks in both worlds".

    Now, if you want to do native development, you'll be working with C++. You'll only use C++/CLI if you (1) want to interact with managed (.NET) code, or (2) want to develop .NET apps.

    Finally, regardless of the language, native or managed, once you have a good grasp of the tools at your disposal, it's pretty much all about using them in a good way, being able to apply OOP design principles, Design Patterns, and best practices, in order to solve problems. And these are language-independent (more or less, but usually more).

  4. #4
    Join Date
    Jan 2012
    Posts
    11

    Re: Which Is Closer To This Type Of C++ (C# Or CLI)?

    Thanks for the replies guys (they were very informative).

    At the very least though, I hope someone could please tell me everything I learned in that class wasn't pretty much useless : )

    I always had a feeling it was anyway (my previous class).

    I mean, I enjoy making quick snazzy GUI's in VS, but that console programming stuff from that class just seemed a bit old school to me. I couldn't help but think who would use this (or write this for that matter) when they could use a program with um..... clickable buttons?

    I know programming isn't necessarily 'all' about graphical cool looking interfaces, but that's all I really wanted to do in the first place.

    I chose C++ because I thought it would be a great start (which it is), but little did I know C++ this wasn't C++ that, and VS isn't even that or this, and none of that is actually this, and you can't take a course on this, but you can take a course on that, even though that has nothing to do with this or anything else : )

    Forgive my frustration. I just wish there was only one type of C++, and a college course taught you how to use exactly that one type in addition to using that one type in VS as well.

    After a lot of thinking, I think I'm just going to pick C# & VB.Net in VS and run with it. I'm honestly just tired I guess from trying to learn everything about everything (because it's never gonna happen).
    Last edited by Alyssa Saila; February 16th, 2012 at 08:41 PM.

  5. #5
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,585

    Re: Which Is Closer To This Type Of C++ (C# Or CLI)?

    No, most probably what you've learned was not useless. After all, despite the many competitors, C++ still is a widely used and highly established language, in particular much more established than C# or VB.

    And in fact there is only one C++! (I'd like to emphasize again that I'm not accounting for C++/CLI here, which, as already pointed out, is a distinct language.) Tha catch is, though, that this language as such completely lacks any support for writing GUI apps. (Strictly speaking, it doesn't even support console I/O, but discussing that here would be pretty nit-picking...) That's why C++ always is used in combination with some framework when writing GUI apps, which may lead to the (not so uncommon) misconception that there's more than one flavor of C++, but there isn't: The GUI framework is not part of the language as such.

    Writing console apps when learning the language has one big advantage: That way you learn the language as such, without all the glamour, variety and complexity of GUI frameworks distracting you from the central topic. Later, when you've got a firm grasp on the concepts of C++ itself, you may make your decision for one or more GUI frameworks and platforms (which often are highly interdependent, BTW).

    Outside of the educational sector, console apps aren't useless either. Some really established members around here keep emphasizing that many good and arrived programmers out there never have written a single GUI app in their entire programming life. I myself, I guess, have written my first GUI app after about one decade of programming, but, admittedly, that were different times. And you, yourself, probably are using much more console apps than you're aware of: For instance, I don't know of any single C++ compiler that is not a console app. All the fancy IDEs used for developing C++ programs like VS, Code Blocks and whatnot just call the command line compiler for you behind the scenes and then present you the results when it's done. A very simple example of such a GUI wrapper (in C++/CLI) has been discussed in http://www.codeguru.com/forum/showthread.php?t=519546.

    Finally, when writing fancy GUI apps actually is your only requirement, using C# is a quite pragmatic approach that's definitely worth considering. OTOH, with "the real" C++ you have a much greater variety of directions you may proceed in. However, this wealth of choices requires you to make a decision for one, which is much simpler in C# (just Windows Forms vs. WPF) and may lead to increased complexity, thereby likely not making things simpler.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  6. #6
    Join Date
    Jan 2010
    Posts
    1,099

    Re: Which Is Closer To This Type Of C++ (C# Or CLI)?

    Don't get me wrong, C# is a great language, but so is C++ - and the things you learned most definitely won't go to waste. And, as Eri523 said, there's one C++, but there are many ways to do something with it, and many available tools to use it with (and by this I mean not only IDEs, but things like libraries and frameworks). But that's more or less true for any language.
    The thing is, many of the fundamental concepts and constructs are pretty much the same in any imperative language, with features even vaguely similar design principles. They all have statements, conditionals, loops, functions, parameters, and (if they are OO) classes, polymorphysm, inheritance, composition... You just have to learn the syntax. And, most of things you learn can be applied in some form in some other language, especially when it comes to design of your code/applications.

    C++/CLI (previously known as Managed C++) is a sort of hybrid native-.NET language, I understand how this can introduce confusion. So, try C++, try C#, get a feel for both, and pick what you feel more comfortable with (unless you already know you want to do native development (C++), or .NET development (C#)).

  7. #7
    Join Date
    May 2009
    Posts
    2,413

    Re: Which Is Closer To This Type Of C++ (C# Or CLI)?

    Quote Originally Posted by Alyssa Saila View Post
    I couldn't help but think who would use this (or write this for that matter) when they could use a program with um..... clickable buttons?
    It's beacuse a college education is for life. You're supposed to learn deeper more profound stuff that will last. Chances are when you graduate no one wants to click buttons anymore. Then your Masters Degree in Button Clicking won't be worth anything.

    College education is not vocational training. To prevent students from concentrating on the wrong stuff (like button clicking) many computer science programs take the quite drastic measure to teach the first programming courses with Lisp as model language. In my view that's a good idea.

    That aside C++/CLI is a C++ extension (in the same way as C++ is a C extension). It was quite controversial when it was first introduced and Microsoft was accused of trying to hijack C++ for their own evil purposes [1]. Anyway if you're using C++/CLI but stay away from the CLI part you'll be using standard C++. It would be like using C++ to program in C - possible if you're not making use of the extension. And since C++/CLI is a .NET language its standard C++ part will be a .NET language too.

    In my view C++/CLI is a very interesting example of what standard C++ could've evolved into hadn't Java and C# come along [2]. The problem with C++/CLI at this point is that although it's an excellent language it's lacking active Microsoft promotion and a large user community. As C++/CLI programmer you'd be very much on your own. For that reason C# or Java or standard C++ are much better choises in the modern general purpose language category. They're popular and widely used.

    [1] In fact Microsoft has done it again this time without drawing flak from C++ purists. Their latest C++ language extension is called C++/CX and targeted towards Windows 8/Metro developments.

    http://blogs.msdn.com/b/vcblog/archi.../10228473.aspx

    So if you want to be in the frontline of button clicking C++/CX is the language for you.

    [2] It's still possible that some of the C++/CLI stuff will make its way into standard C++ eventually. Microsoft's Herb Sutter was the lead architect of C++/CLI and is also on the C++ standards committee,

    http://herbsutter.com/
    Last edited by nuzzle; February 23rd, 2012 at 12:57 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center