Results 1 to 13 of 13

Thread: C++ is only slighter faster than VB

  1. #1

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394

    C++ is only slighter faster than VB

    Hello,

    I used GetTickCount API and i found out that my two equal programs written on C++ and VB, had VB version was only 196 points slower than C++ and VB had window intilized while C++ was running in Console.

    Is this realy true? I heard that C++ was much faster and efficient than VB :B

    C Version (took 6783 points):
    PHP Code:

    #include "stdafx.h"
    #include <iostream.h>
    #include <windows.h>

    int main(int argccharargv[])
    {
        
    int x;
        
    int ticks;

        
    8;
        
    ticks GetTickCount() / 1000;
        
    cout << ticks;
        
    cin >> x;
        return 
    0;

    VB Version:

    VB Code:
    1. Dim x As Integer
    2. Dim ticks As Integer
    3.  
    4. x = 5 * 8
    5. ticks = GetTickCount / 1000
    6. Me.Caption = ticks

    made_of_asp,
    VS.NET 2003

    Need to email me?

  2. #2
    Lively Member
    Join Date
    Feb 2001
    Posts
    102
    Well, technically C++ is much faster than VB, but your example really doesnt prove it well. On small programs/functions, like the one you specified, the speed difference is relatively insignificant. But on much larger programs, VB can get to be a little bogged down and will run algorithms and long processes much slower because of various crap.

    Here is a language comparisonC++ vs. Visual Basic

    Later
    Last edited by boscord; Jan 4th, 2002 at 08:31 PM.

  3. #3
    jim mcnamara
    Guest
    Plus, none of his code is shwoing how long it took to execute

    should be:

    [code]
    #include "stdafx.h"
    #include <iostream.h>
    #include <windows.h>

    int main(int argc, char* argv[])
    {
    int x;
    int ticks;
    ticks=GetTickCount();
    x = 5 * 8;
    ticks -= GetTickCount();
    cout << ticks;
    cin >> x;
    return 0;
    }

    [code]

    Code:
    Dim x As Integer
    Dim ticks As Integer
    Ticks = GetTickCount
    x = 5 * 8
    ticks = ticks -GetTickCount
    Me.Caption = ticks

  4. #4
    jim mcnamara
    Guest
    While we are at it: On average C++ is an order of magnitude (10 times faster ) than VB code.

    why? VB executes inside a virtual machine, just like java does in IE. It does not run as native image code.

  5. #5

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    10 times faster? You are kidding!

    C++ is sooo hard
    VS.NET 2003

    Need to email me?

  6. #6
    Tygur
    Guest
    Originally posted by jim mcnamara
    While we are at it: On average C++ is an order of magnitude (10 times faster ) than VB code.

    why? VB executes inside a virtual machine, just like java does in IE. It does not run as native image code.
    VB does not run inside a virtual machine when it is compiled to Native Code.

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    That's one of the best solutions if the VB runtime dependencies aren't a problem.

    It means you don't have to learn much of the API which takes quite a while to learn well.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8
    Zaei
    Guest
    Also, VB is all COM, which adds overhead as well.

    Z.

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    WinAPI: bad paradigm
    COM: performance hit
    VB: very bad paradigm polluted slowmoving fat bastard
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10
    Zaei
    Guest
    Originally posted by kedaman
    WinAPI: bad paradigm
    What are you going to do when you have to accomodate languages that arent OOP?

    Z.

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Originally posted by Zaei
    What are you going to do when you have to accomodate languages that arent OOP?
    Z.
    Me or microsoft? microsoft is the one accomodating for function based languages, I'm for new innovations
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I'm doing the wrappers between the API and whatever you're using...in this case it's a functional->OOP layer.

    I don't understand what Ked's doing at the moment
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  13. #13
    Zaei
    Guest
    MS of course =).

    Z.

Posting Permissions

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



Click Here to Expand Forum to Full Width