What am I coding in? Visual C++? .net? CLI???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BahatiSiD
    New Member
    • Oct 2008
    • 9

    What am I coding in? Visual C++? .net? CLI???

    it's as noob as it gets, but i'm having trouble finding information on the internet because i don't know what to look for.

    i'm using visual studio 2008. i click on file>new>projec t, select visual c++ in project types and windows forms application in templates.

    if i use "visual c++" as a keyword in my searches i get a lot of mfc stuff. ".net" takes me to c#. "windows forms" also. so far i've managed to extrapolate the information i needed, but as i progress to more serious code i find it more difficult.

    can someone please clarify things?

    i would also appreciate directions to some good, comprehensive online/printed material on the subject.

    is it possible that i just chose a "wrong" language, and that everyone is doing either win32 or c#, and that's the reason for the lack of information? there just isn't any, because no one cares, and all this is even more tragic then someone simply, and very literally, not knowing what he's doing?! :)

    thanks!
  • l034n
    New Member
    • Oct 2008
    • 15

    #2
    Hello BahatiSiD and welcome to the programming world :)
    MFC (Microsoft Foundation Classes) is windows library that wraps some portions of the Windows API in C++ classes. You have many graphical components in MFC that you ay use if you choose "MFC Application" (or anything starting with MFC for that matter) as a template. It was introduced in 1992 with Microsoft C/C++ 7.0 compiler, so it's older that Windows Forms, but is still in use and is pretty good (not to mention faster, because it's not manageg by CLR).
    Windows Forms is the GUI API introduced with the .NET framework, so it is part of it and is managed by the CLR (Common Language Runtime, that is virtual machine component of the .NET framework). It's relatively easier to work with than MFC, but i would suggest to try both.
    Than, you also have WPF (Windows Presentation Foundation) which was first introduced with the .NET 3.0 framework and works with vector graphics using XAML (Extensible Application Markup Language). It's supposed to be the main graphical subsystem, but Windows Forms are still used a lot and are really fitting for nice desktop applications.

    So, to code in .NET, you may use C++/CLI (C++/Common Language Infrastructure) which is managed C++ (managed by the .NET framework). Heck, you may use unmanaged code in .NET as well, but i guess when you get more advanced because now it may just mix up everything.
    On the other hand, C# was developed as part of the .NET initiative, so it goes along with .NET, hence it's always managed by the CLR.
    So, if you want to code in C++ (unmanaged) you may use MFC. If you want managed code w/ .NET framework, you would choose either C++/CLI or C# (or any other .NET language and there are plenty of them to choose from).

    I wouldn't say that you chose a wrong language. I mean, is there any wrong language? Well, it's true that the majority is using either C++ or C#, but i wouldn't agree that the language you chose (btw, it's C++/CLI) is wrong. Actually, it's really good language and worth studying (as is any other programming language if you ask me).

    As for material.. well there are plenty of good books on the subject and it will depend on the language that you'll choose (i don't even know your level). But if you're real newbie (meaning... can you write a function? a class? a structure?) i don't think you should start right away with visual programming, but get good knowledge of the basic concepts of the language that you'll be using and then build up on that.

    Hope this helps

    Comment

    • BahatiSiD
      New Member
      • Oct 2008
      • 9

      #3
      Originally posted by l034n
      As for material.. well there are plenty of good books on the subject and it will depend on the language that you'll choose (i don't even know your level). But if you're real newbie (meaning... can you write a function? a class? a structure?) i don't think you should start right away with visual programming, but get good knowledge of the basic concepts of the language that you'll be using and then build up on that.

      Hope this helps
      it does indeed, thank you very much!

      in terms of time passed from my first 'application' (that is, the first piece of code that does something useful, and is not an exercise in something) i'm an absolute newbie, and it can be measured in months. i did some native c++ code for school and stumbled on windows forms when i needed my output to be graphical. i liked it very much because i could immediately apply my newly gained familiarity with the c++ language, as many of the classes are readily available and i would just "assemble" my programs like a puzzle. i guess you could say i'm an extreme proponent of the "learn by doing" concept and the .net framework seems to facilitate this very well. and probably a 'best practices' purist's worst nightmare, as my only concern is to make my program do what i want by any means available.

      so far i've been successful in my goals, but as i started making more of my own classes, inheriting, overriding and 'pointing' every which way i came across some annoying syntax differences from native c++ and, as i've said, had to resort mostly to interpreting the relevant information about c# i could find.

      what i'm trying to say is that i am a noob experience wise, and in terms of what kind of problems am i running into, but i do have a good grasp of things, even if i don't know them. i usually just imagine that something should exist, and it usually does. i use the intellisence feature of VS2008 extensively. ;)

      my latest problem had to do with pointers/references so i couldn't really solve it like i used to. can you formulate a search i could've used for that particular problem? "managed c++ pass by reference"? "clr c++ pass by reference"?

      i just hate having to bother people with something that probably has a simple solution, which i can't find, because i don't know what to look for... :)

      Comment

      • l034n
        New Member
        • Oct 2008
        • 15

        #4
        Originally posted by BahatiSiD
        my latest problem had to do with pointers/references so i couldn't really solve it like i used to. can you formulate a search i could've used for that particular problem? "managed c++ pass by reference"? "clr c++ pass by reference"?
        You could search for it like this:
        managed c++ pass by reference

        It's really managed by the CLR, but it's usually called just Managed C++ instead of C++/CLR and if you search for anything about it, use the term "managed C++".

        As for your problem with passing by reference, i saw the thread and i believe you have solved it by now, but here is a simple pass-by-reference example:

        C#:
        private void Swap(ref int x, ref int y)
        {
        int temp = x;
        x = y;
        y = temp;
        }

        C++/CLI:
        private: System::Void Swap(int& x, int& y)
        {
        int temp = x;
        x = y;
        y = temp;
        }

        So, Managed C++ is pretty much like native (ANSI) C++ in many aspects.

        Originally posted by BahatiSiD
        i just hate having to bother people with something that probably has a simple solution, which i can't find, because i don't know what to look for... :)
        BahatiSiD, the only stupid question is the one that goes unasked. I am not saying you should ask for every single problem you have. But after you spend enough time trying to figure it out, google about it, check forums etc, if you still can't find a solution than just post it.
        Don't forget that it will make your life easier and will help to many other people that might have that problem in the future.

        Btw, as i see you're in C++ and C++/CLI programming, i highly recommend to you the book: Ivor Horton's Beginning Visual C++ 2005. It's really great and comprehensive book about both C++ and C++/CLI.

        Cheers

        Comment

        • BahatiSiD
          New Member
          • Oct 2008
          • 9

          #5
          l034n, thank you very much for all the help. "Managed c++" keyword does seem to get me more relevant search results.

          I know there should not be too much of a difference between native and managed syntax, but I am getting errors if I don't make changes to the code you supplied. I made a new post in the other thread about it.

          It’s probably due to a very basic error on my part. And that's the issue that makes me embarrassed. :) I jump in head first, guns blazing, and when I get into trouble I have to bother people that took the time to learn the basics.

          I agree, there are no stupid questions, but there are ones that have been answered many times and are just a waste of resources for everyone involved. The keyword issue was stopping me from finding answers that are most probably already out there.

          Comment

          Working...