954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to make a vb.net App faster(like C++ application)

Is it possible to make a vb.net application faster
Through code like using characters that the Computer already understands
Like coding in certain areas through y x (math) etc.
Will it be More faster since the compiler don't have to really do much work
But its still must be VB.NET
:-/

VB 2012
Junior Poster
154 posts since Jul 2010
Reputation Points: 15
Solved Threads: 1
 

I don't see how the compiler fits in this, as it's only used during creation and not execution (vs interpreter who is invoked at run-time).
I've seen an article about it, but was more about what to place in a loop and what not to or where to use vars/constants or calculations and if I remember correctly it concluded that unless you've done some serious design flaws or use extensively loops you won't get a much faster program by following these instructions.

What is your program supposed to do? Where are you facing delays?

adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149
 

No im not Facing any delays but im just thinking about how to program like a Pro

VB 2012
Junior Poster
154 posts since Jul 2010
Reputation Points: 15
Solved Threads: 1
 

Im thinking about when to use Certain code and how to Declare it

VB 2012
Junior Poster
154 posts since Jul 2010
Reputation Points: 15
Solved Threads: 1
 

and is there a difference when you declare something through words or Just chars

VB 2012
Junior Poster
154 posts since Jul 2010
Reputation Points: 15
Solved Threads: 1
 

Not everything programmed in C++ is faster than VB.NET. It is just matter of using the right data structure and the right algorithm for your problem.

invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

yes C++ really faster than VB.NET

ranawaqar
Newbie Poster
2 posts since Dec 2011
Reputation Points: 10
Solved Threads: 1
 

As VB.NET already says it in its name... your application need to inject .NET code at runtime (which C++ don't need to)
Beside that, the speed is also the result of a clean and productive coding style. Means if the coder have unnecessary loops, checks or using a hell of global variables the program will slow down of course.

GeekByChoiCe
Master Poster
721 posts since Jun 2009
Reputation Points: 208
Solved Threads: 168
 

Just a comment: Who said that pros write fast performing code? Nowadays most programmers don't really care about resources and execution time. In fact it's been a while since I've come across a programmer that took into account stuff like that or how to facilitate the user/ respect the flow of the process, etc.

On your programms keep it simple, well commented and recycle code whenever possible.

adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149
 
yes C++ really faster than VB.NET

I don't think you get my idea. Not everything written in C++ is faster then VB.NET. If C++ program is using the wrong algorithm for the problem, VB.NET that using the right algorithm will perform better. your application need to inject .NET code at runtime (which C++ don't need to)Indeed, C++ program is translated into native code, so do .NET program. The process of .NET gone like this:Every .NET program is compiled into CIL(Common Intermediate Language)
When .NET program is run, CIL code will get translated into native code (through Just-In-Time Compiler)
Then native code is executed.

The end result is the same which is in NATIVE CODE. To me, the reason that .NET program run slower because of garbage collector and other managed libraries. However, for safer program, there should be a trade-off.

So what is my point? My point is that VB.NET beginner programmer most of time will produce a faster program than C++ beginner programmer, because VB.NET beginner will use right tool provided my .NET libraries which is a wrapper of good implemented native code. Moreover, VB.NET beginner probably tend to make less optimization mistake. For example:

VB.NET version

Private Function IsPrime(ByVal n As Long) As Boolean
        For i As Integer = 2 To Math.Sqrt(n)
            If n Mod i = 0 Then
                Return False
            End If
        Next

        Return True
    End Function


C++ version assuming compiling with no compiler optimization

bool IsPrime(long n) {
    for(int i=2;i<sqrt(n);i++)
        if ((n % i) == 0)
            return false;
    return true;
}


As n grows larger, VB.NET will start to run faster.

invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

Reply to Adam_K and to the rest:icon_cheesygrin:

of course i like to balance my code in order
So that i know where things are and how they progress and i don't use comments
It might not be executed in the program but i like to think so :D :D :) :P
So yea but there's one thing is still like to know
Is there any difference how you declare some thing
So instead using long names myvidoechannel = "" or just use x = ""
Any difference People :D

and please if im wrong don't make me look like an ass :icon_evil:
some of the people on DaniWeb have the urge to do it :icon_mad:

VB 2012
Junior Poster
154 posts since Jul 2010
Reputation Points: 15
Solved Threads: 1
 

Naming your variable (long or short) does not affect the performance because once it is compiler, it will be just a piece of memory address.

invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

OH that's a shame :(
But still is there anything like what i suggested that can give performance problems
or some other to make it faster any kind of coding like the steps of making sure that it would not be memory thirsty like doing this when you not doing that like a vb guide. Please i would really appreciate it
:)

VB 2012
Junior Poster
154 posts since Jul 2010
Reputation Points: 15
Solved Threads: 1
 

I should really not dwell on this part because i don't know half of .Nets capabilities and its functions :D im still NEWBIE BEGINNER i should know more because i started in 2009
But im in High School Going to grade 11 Next Year omw :D its gonna be like Hell
Anyway any help or link is cool

VB 2012
Junior Poster
154 posts since Jul 2010
Reputation Points: 15
Solved Threads: 1
 

If I remember correctly it is slower to run:

for i= 1 to datagrid1.rows.count -1 'or whatever count that is

than

dim row_count as int 
row_count = datagrid1.rows.count
for i=1 to row_count


The explanation is that in the first syntax the number of rows has to be calculated in every loop, while in the second it doesn't.

adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149
 

So the second one is faster

VB 2012
Junior Poster
154 posts since Jul 2010
Reputation Points: 15
Solved Threads: 1
 


Your not going to learn how to write faster code from this thread. A good way to learn how to write faster code is to write more code. Learn whats faster by setting timers in your code.

The only thing I'll say to this is: Integer is the fastest. When ever you can use an integer use it. Select case can be faster than If block. If you use an If block then use short circuiting. Look at your code when your done. Try to eliminate wasted logic. If you need to calculate things more than once make sure it doesn't happen more than once. You will learn as you go.

Write a block of code you want faster. Lets see if we can make it faster.

Unhnd_Exception
Posting Pro
570 posts since Nov 2010
Reputation Points: 249
Solved Threads: 201
 
The explanation is that in the first syntax the number of rows has to be calculated in every loop, while in the second it doesn't.


The second does not run faster. In VB.NET, For Loop does pre-calculate for us. For example:

Dim ending As Integer = 10
Dim count As Integer = 0

For i As Integer = 0 To ending
   ending = 1
   count += 1
Next

Msgbox(count)

It will run from 0 to 10 even though you change the ending to 1. Unlike C++. That's why I said that C++ beginner programmer will more likely to make more mistake.

invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

Maybe you can try to play around with ProjectEuler problems . Each problem is fun to solve and you will learn how to optimize your code by looking at other people approach.

invisal
Posting Pro
562 posts since Mar 2005
Reputation Points: 350
Solved Threads: 64
 

Thanks for your help guys Thread Solved

VB 2012
Junior Poster
154 posts since Jul 2010
Reputation Points: 15
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: