Moving from VC++ 6.0 to VC++.NET
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 33

Thread: Moving from VC++ 6.0 to VC++.NET

  1. #1
    Join Date
    Aug 2010
    Posts
    37

    Question Moving from VC++ 6.0 to VC++.NET

    I have, what to me, looks like a large project. Originally written about 90% in VB6 and the remainder in VC++ (Visual C++ 6.0 Enterprise Edition). There are maybe 2,000 lines of code written in VC++ which constitute a DLL with about 80 functions (81 to be precise)

    There are two reasons I have used VC++. The first is that speed is of the essence - the program may literally run for weeks finding solutions and the speed of the central loop is crucial. From experience it seems like the routines in VC++ run about three times quicker than the equivalent written in VB6

    Secondly, I have written a lot of bit handing routines using inline ASM.

    I have spent several months converting the VB6 stuff into vb.net (which run at about half the speed of VB6) and am now looking at the VC++ stuff

    Some questions:

    1. Is VC++.net going to run at the same speed as vb.net as I understand they both translate into an Intermediate language? If so, it will be a LOT slower than VC++ 6.0?

    2. Can I use inline ASM in VC+.net?

    3. Can I view (somehow) the disassembled code as I can in VC++? This is very handy when you are trying to optimise speed

    4. What version of VC++.net should I use (I am currently using VB 2010 but am happy to spend money and upgrade if necessary)

    5. Any general observations from people who have already experienced this transition will be very much appreciated

    Many thanks!
    Last edited by wavering; August 1st, 2014 at 02:52 AM.
    MOPEKS - a freeware program that generates programs that use each other to solve problems

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,295

    Re: Moving from VC++ 6.0 to VC++.NET

    Quote Originally Posted by wavering View Post
    1. Is VC++.net going to run at the same speed as vb.net as I understand they both translate into an Intermediate language? If so, it will be a LOT slower than VC++ 6.0?
    Let's clear up some misconceptions. Understand that the versions of Visual Studio since VC/VB 6 still offer native VC++ coding - and they offer VC++.Net (which is managed).

    In other words, you can still create non-managed native C++ applications in Visual Studio.

    If you don't mind upgrading, I'd suggest upgrading to VS2013 before starting your porting project. VS2013 C++ supports C++11 features that 2010 does not. Why start with a 4 year old compiler?

  3. #3
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,889

    Re: Moving from VC++ 6.0 to VC++.NET

    Quote Originally Posted by wavering View Post
    Secondly, I have written a lot of bit handing routines using inline ASM.
    probably not needed, potentially this is going to slow down your app rather than speed it up.

    if as functions, you're forcing calls, and restricting the compiler to manage registers on it's own best interest.
    if as inline functions, may still incur a call, still restricts the compiler to manage registers
    if as inline defined asm, still restricts the compiler to manage registers

    Except for a few 'oddball' bit routines (such the the rotates), the compiler optimizer will probably do most of your 'bit handling' in c++ better than your asm.

    2. Can I use inline ASM in VC+.net?
    no for .net (managed) code, you can write an unmanaged section, but in this case the change from managed/unmanaged is going to ruin any kind of speedup you hoped to achieve.
    for unmanaged code: yes

    I'm not sure if the express edition supports inline asm.


    3. Can I view (somehow) the disassembled code as I can in VC++? This is very handy when you are trying to optimise speed
    1) you can create an asm listing.
    2) don't try to bother. If you want to do better than the compiler, you need to think about different algorithms/strategies to solve the problem rather than trying to micro.

    5. Any general observations from people who have already experienced this transition will be very much appreciated
    start by getting your program to WORK first.
    worry about optimizing after, rather than starting by what you think needs to be optimized.

    profile your app and optimize only where it matters.
    if you make the bit of code that takes 1second of time in the entire duration of your app 100% faster, you'll have made your entire program 1 second faster, that's not a good investment of time.
    if you make the routine that is executed 1 million times 0.001 second faster, you'll have made your program take 1000s faster.

  4. #4
    Join Date
    Jul 2013
    Posts
    281

    Re: Moving from VC++ 6.0 to VC++.NET

    Quote Originally Posted by wavering View Post
    The first is that speed is of the essence - the program may literally run for weeks finding solutions and the speed of the central loop is crucial.
    Or rather the central algorithm is crucial. Why not take this opportunity to have a hard look at it?

    Maybe it can be replaced altogether with a more efficient alternative. Or maybe it can be improved for example by replacing the innermost loop with a table lookup. Or maybe it can be parallelized at the CPU level or by making use of the massive parallelism offered by todays GPUs.

    First lower the algorithmic complexity to a minumum and only then start fiddling with micro-optimizations.
    Last edited by razzle; August 1st, 2014 at 09:57 AM.

  5. #5
    Join Date
    Aug 2010
    Posts
    37

    Re: Moving from VC++ 6.0 to VC++.NET

    Firstly, many thanks for the detailed replies - very much appreciated. Just to clarify a few points ...

    Development: The project is already up and working (MOPEKS - see signature below) so I am trying to do a straight transfer to vb.net and vc++.net. There is no element of development or optimisation at this stage but there will be later ...

    ASM: I am using it for complex bit manipulation, not for speed. It may be possible to do this in C++ but I would not know where to start and the great advantage of ASM is that you are right inside the engine and it is very easy to check exactly what is happening line by line

    Disassembled code: I want to view this not to try and outdo the compiler but so that in certain cases I can see what is really happening - what I am doing is hideously complicated (to me anyway - MOPEKS generates computer programs and provides an environment in which they run and call each other - my output is not data but computer programs) and I need all the help I can get making it work during transfer to .net and later during development in years to come.

    Speed: Obviously, I have given huge thought to this given that it may take weeks to find a solution on occasion. The central routine runs to well over a thousand lines of code and actually calls itself (up to about ten layers deep in practice) but with many "if" tests so it runs through about 20 million times per second using one core. I have 10 machines with 8 cores each so can use 80 cores where necessary. The central routine literally runs trillions of times (ie 10 ^ 12). The next step may be using FPGA and multicore hardware (I have a friend who is a hardware guy who tells me you can have up to 500 cores on a single chip but this is very early days for that) but that will be in maybe two or three years time.

    Complexity: Having been built over a 25 year period I am close to losing control of the code so I need to transfer to vc++.net as simply as possible. Is the transfer going to be difficult - are there any fundamental changes in the way vc++.net works? Although the logic is hideously complicated the code itself is really just simple C and C++. It does not really call any C or C++ functions as such. Sample below of the recursive part ...

    Code:
    // This is the part where it calls itsefl
    intLevelGL++;
    dblTotalMethodsRunGL++;
    dblReturn = ScorerKernel(dblObjectArray,
                             dblEnvPropValues,
                             intEnvPropNumber,
                             intMethodArray,
                             intMethodLines,
                             intMethodNumberCalled,
                             intMethodClass,
                             0,
                             intMethodClassSignal,
                             dblR1,
                             dblR2,
                             dblAnswer, 
                             intTrialNo,
                             intStep);
    
    
    // Stop if duff
    intLevelGL--;
    if(dblReturn != 0){
      dblErrorNumber = dblReturn; 
      goto notgood;
    }
    
    result:;
    // Put the answer into the LHS (UNLESS it is NextStep)
    if(usiMethodCalledHash != 2732976079){
      dblStorit[intInstruction2] = dblAnswer[0][0];
    }
    intLine++;
    }  // end of "if(intInstructionType == 7)"
    
    //                                                  Calling a Method ENDS here
    
    endofloop:;  
    intLinesRunPerScorerKernelVisit++;
    intLinesRunTotalGL++;
    	if(intLevelGL == 1)intTopLevelLinesRunGL++;
    
    // Check NOT run too long
    if(intLinesRunPerScorerKernelVisit > LRM_PER_SK_VISIT){
    	  {dblErrorNumber = 160; goto notgood;}
    }
    if( (intMethodClassSignal != 34 ) && (intLinesRunTotalGL > LRM_PER_TRIALS) ){
    	  {dblErrorNumber = 161; goto notgood;}
    }
    if( (intMethodClassSignal == 34 ) && (intLinesRunTotalGL > LRM_PER_SIMULATION) ){
    	  {dblErrorNumber = 162; goto notgood;}
    }
    So, how hard is this going to be?!
    MOPEKS - a freeware program that generates programs that use each other to solve problems

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,097

    Re: Moving from VC++ 6.0 to VC++.NET

    Why .Net? Wouldn't regular C++ work for you?

  7. #7
    Join Date
    Aug 2010
    Posts
    37

    Re: Moving from VC++ 6.0 to VC++.NET

    Quote Originally Posted by GCDEF View Post
    Why .Net? Wouldn't regular C++ work for you?
    Yes, it would but I assume that VC++ 6.0 will be dropped in due course. I am using Win XP but assume that I cannot use VC++ 6.0 on Win 8 etc. What do you suggest?I used to use Quick C last century ...

    Suggestion(s) welcomed - I need to build a DLL so any GUI and Compiler that can do that would be perfect ...
    .
    MOPEKS - a freeware program that generates programs that use each other to solve problems

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,977

    Re: Moving from VC++ 6.0 to VC++.NET

    It seems you don't get it. Despite the fact that VS name includes .NET part, you are still allowed to create pure native C++ projects. Or just make use of convertion from VC 6.0 C++ project to the latest format.

    Unlike the situation with VB6.0, pure old C++ is not banned in contemporary VS versions.
    Last edited by Igor Vartanov; August 2nd, 2014 at 01:39 PM.
    Best regards,
    Igor

  9. #9
    Join Date
    Aug 2010
    Posts
    37

    Re: Moving from VC++ 6.0 to VC++.NET

    Quote Originally Posted by Igor Vartanov View Post
    It seems you don't get it. Despite the fact that VS name includes .NET part, you are still allowed to create pure native C++ projects. Or just make use of convertion from VC 6.0 C++ project to the latest format.

    Unlike the situation with VB6.0, pure old C++ is not banned in contemporary VS versions.
    Understood but if there is an easier or better way then I will take that route ...
    MOPEKS - a freeware program that generates programs that use each other to solve problems

  10. #10
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,977

    Re: Moving from VC++ 6.0 to VC++.NET

    I hardly could say anything except maybe pretty obvious things like "you should go with the language you are comfortable the most with", or "language hardly could help in a case when it's more about algorithms", or "you should stay away from ASM as much as possible in case chances are for your SW to run on more than one HW platform", etc.
    Best regards,
    Igor

  11. #11
    Join Date
    Aug 2010
    Posts
    37

    Re: Moving from VC++ 6.0 to VC++.NET

    What I am asking right now is whether there is a good alternative to vc++.net (with emphasis on the IDE aspect with ease of use and versatility being the criteria) that I should consider. For example, a quick search comes up with the following that are useable under Win 8

    1. Turbo C++ 3.0 from Borland

    2. Intel® C and C++ Compilers

    3. codeblocks

    4. C-Free - C++ Compiler for windows 7 , 8 .

    5. CodeLite

    6. Digital Mars

    7. MinGW

    And now doubt many others - so now I really am confused as to the best way forward. Cost is not a major factor - I just want the best and easiest to use ...

    Edit:
    Since writing the above I have found this definitive article but people's experiences here would be very useful

    http://en.wikipedia.org/wiki/Compari...t_environments

    Thanks ..
    Last edited by wavering; August 3rd, 2014 at 07:12 AM. Reason: Found Wiki Article
    MOPEKS - a freeware program that generates programs that use each other to solve problems

  12. #12
    Join Date
    Jul 2002
    Posts
    2,513

    Re: Moving from VC++ 6.0 to VC++.NET

    Quote Originally Posted by wavering View Post

    2. Can I use inline ASM in VC+.net?

    3. Can I view (somehow) the disassembled code as I can in VC++? This is very handy when you are trying to optimise speed
    2. Yes, in native C++, but not in x64 build. You can, however, compile Assembly modules and link them with C++ modules. As mentioned before, it is much better to write this stuff in C++.

    3, Yes, by printing Assembly listing, and during debugging, in Disassembly window.

    Regarding your last post - most options are not C++ compilers, but IDE or frameworks. Talking about compilers, serious candidates are VC++ (of course, latest version available), g++ (part of MinGW package) and Intel C++ compiler. VC++ looks like an optimal choice. If performance is really critical, all Intel software products are known by very good performance and optimization.
    Last edited by Alex F; August 3rd, 2014 at 07:08 AM.

  13. #13
    Join Date
    Aug 2010
    Posts
    37

    Re: Moving from VC++ 6.0 to VC++.NET

    Quote Originally Posted by Alex F View Post
    VC++ looks like an optimal choice
    Yes, looks like I will probably stick with Microsoft!

    Two questions:

    1. Do you know if there is a version that offers conversion from VC++ 6.0? I ask this because in vb.net the 2008 Express offers a conversion facility but the 2010 Express does not. Or can I just open it and it will sort of work ie are there major changes like there are from vb6 to vb.net (that conversion has taken me 6 months so far)?

    2. It appears that the latest free version is 2013 - is that correct?

    Once I am happy I will buy the latest full version as I believe that will enable me to use extensions (particularly MZ Tools in vb.net)

    Thanks Alex - or others who may answer
    MOPEKS - a freeware program that generates programs that use each other to solve problems

  14. #14
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,977

    Re: Moving from VC++ 6.0 to VC++.NET

    Quote Originally Posted by wavering View Post
    What I am asking right now is whether there is a good alternative to vc++.net (with emphasis on the IDE aspect with ease of use and versatility being the criteria) that I should consider. For example, a quick search comes up with the following that are useable under Win 8
    ...
    Cost is not a major factor - I just want the best and easiest to use ...
    As for me, VS is the most attractive IDE for Windows. I really love it's debugger, though Whole Tomatoe's add-in is still a recommendation for improving its editor. Express edition, which is free, but equipped with the contemporary compiler, would be fine for your needs, as Pro version is required only in case you use MS libraries like MFC or ATL, or need an integrated resource editor.

    As for ease of use and versatility, I would say these are too vague criteria to ask for recommendations from people you never know. Again, according to what I got from your post, your main problem is algorithm's complexity, where IDE hardly could be of any help.

    As for compiler's quality, VC++ is really good, and its only competitors are Intel and g++.
    Best regards,
    Igor

  15. #15
    Join Date
    Jul 2002
    Posts
    2,513

    Re: Moving from VC++ 6.0 to VC++.NET

    Quote Originally Posted by wavering View Post
    1. Do you know if there is a version that offers conversion from VC++ 6.0? I ask this because in vb.net the 2008 Express offers a conversion facility but the 2010 Express does not. Or can I just open it and it will sort of work ie are there major changes like there are from vb6 to vb.net (that conversion has taken me 6 months so far)?

    2. It appears that the latest free version is 2013 - is that correct?
    1. Unlike VB6 - VB .NET, C++ remains the same language. Conversion is pretty straightforward - open old VC++ project in new Visual Studio, fix all compilation, build and runtime errors. I don't know any conversion tool, I think it doesn't exist. There is only project conversion wizard, which is executed automatically when old project file is opened. It doesn't change anything in source code.

    2. Yes.
    Last edited by Alex F; August 3rd, 2014 at 09:04 AM.

Page 1 of 3 123 LastLast

Tags for this Thread

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