Ben,

I used to work on C++ before i moved to .NET too. I am very impressed
with the abilities of the framework and the ease with which you can
write the same code in a shorter time. But, then again, IMO any
framework cannot be generically used for all purposes and situations.
Since my situation demands the use of matrices, vectors and solving
them, over and over again, the data structure would be prime but
beyond that, the algorithm used is trivial. It then boils down to
which code can run faster.

I am midway on my C# version of a basic code that i already have on
MATLAB. I am using Mapack for .NET by Lutz Roeder for my matrix
operations. Although the code isn't exactly 'optimized', i just want
to see how comparably faster the code is going to perform. Will post
the results of my test tomorrow !

Ritchie,

I agree with you. I believe that benchmarks are subjective in
themselves and that there are different parameters that need
consideration. Every language should not be used in every scenario. It
is not meant to be ! I believe in personally benchmarking the actual
test code on different platforms and then comparing the results for
your scenario before a decision is made.

>> Any high-level language hides aspects of implementation that may have a 
>> performance impact.  That doesn't mean logic can't be "correctly"
written so no
>> performance issues are introduced, in comparison with other languages. 

I have to disagree on the statement that any OO language can perform
equally and as efficient as a procedural language like C. Any
indirection in the execution of a procedural code is an overhead and
it can never be compensated with a better logic or algorithm ( because
you could write the same efficient algo in the procedural language too
! ). If your logic is not the same in different languages, then the
benchmark or comparison is meaningless.

All higher level languages work on the principle of indirection,
thereby creating another abstraction in the execution of the code.
There could be several reasons and uses that come out of that but the
speed of execution will be definitely lower. 10 calls instead of 50
calls on the same cpu is going to be lesser anytime !

Anyway, i will post my results from my C# code tomorrow. Thanks for
the suggestions and tips again guys !

On 7/11/05, Peter Ritchie <[EMAIL PROTECTED]> wrote:
> All the comments I've seen so far comparing C/C++ and .NET (specifically
> C#) have been *very* subjective.
> 
> Lack of pointers in a language does not guarantee an improvement in
> quality.  C# may remove dealings with pointers in the general case; but,
> that does not mean programmers working in "pointer-full" language always
> leave them dangling.  There are many good "smart" pointer classes in C++
> that deal with the garbage-collection for you.
> 
> There's also no guarantee that GCed languages remove all allocation-
> related performance issues.  There are cases where GC actually reduces
> performance.
> 
> Similarly, there's no guarantee using C# will reduce your development
> effort.  If you have to deal with OS calls that aren't directly supported
> by .NET, and PInvoke rears it's head; you can probably throw development-
> time increases (and performance) out the window.  OS-based SNMP support is
> a good example.  Try doing that in C# (out-of-the-box) in less time than
> C++.
> 
> There's also no direct correlation to object-oriented languages and an
> automatic reduction in performance.  Any high-level language hides aspects
> of implementation that may have a performance impact.  That doesn't mean
> logic can't be "correctly" written so no performance issues are
> introduced, in comparison with other languages.  Any language will allow
> you to compromise many aspects of an efficient program (memory usage,
> performance, resource usage, etc. etc. etc.).
> 
> There's nothing inherent in C# or .NET that would suggest an application
> utilizing complex mathematical calculations would be slower than C++ or
> C.  Your choice of libraries in C#/.NET may have different performance
> footprints than similar C/C++ libraries; but, you're comparing apples and
> oranges.
> 
> Language comparisions are always a meal best served with a grain of salt.
> 
> http://www.peterRitchie.com/
> 
> On Mon, 11 Jul 2005 16:01:33 +0300, Kamen Lilov <[EMAIL PROTECTED]>
> wrote:
> 
> >Also, the bug rate when not using pointers drops dramatically.
> >
> >-----Original Message-----
> >From: Unmoderated discussion of advanced .NET topics.
> >[mailto:[EMAIL PROTECTED] On Behalf Of Ben Kloosterman
> >Sent: Monday, July 11, 2005 3:11 AM
> >To: [email protected]
> >Subject: Re: [ADVANCED-DOTNET] Is C++ better over .NET Math library ?
> >
> >Hi Vijay,
> >
> >I used to be a C++ programmer, but hate it now as I much prefer C#. The
> >framework is always slower than native though the rate varies between 1
> >and 80%.  The normal rate I see quoted is about 14% slower.  When it is
> >slowest is when there is no API Ie if you want to work with a bitmap you
> >need to make a call to get each pixel , hence it is best to pinvoke a
> >native here.
> >
> >The thing about programming in .Net though is it takes you half the time
> >or less.  You can use the extra time to think up smarter algorithms, use
> >caching etc giving you an overall better performance.
> >
> >
> >Regards,
> >
> >        Ben
> >
> >
> >
> >> -----Original Message-----
> >> From: Vijay M [mailto:[EMAIL PROTECTED]
> >> Sent: Saturday, 9 July 2005 4:02 AM
> >> To: [email protected]; Ben Kloosterman
> >> Subject: Re: Is C++ better over .NET Math library ?
> >>
> >> Ben,
> >>
> >> Thanks for the tip. Performance is very important for the code i am
> >> writing but thought that a OO programming platform would ease the
> >> development a little bit. Oh well. Guess i do have to do it in C or
> >> Fortran.
> >>
> >> I imagined that .NET 2.0 would bring in lots of performance
> >improvements
> >> in the framework or that's what i remember reading in one of the blogs
> >at
> >> MSDN. But like you said, a procedural language will definitely be
> >faster
> >> than any of the OOP languages, anytime !
> >>
> >> Thanks for all the help guys.
> >>
> >> On Fri, 8 Jul 2005 12:47:26 +1000, Ben Kloosterman
> >> <[EMAIL PROTECTED]> wrote:
> >>
> >> >If you are doing lots of iterations and care about performance you
> >are
> >> >probably best of writing in C . I once converted a compression
> >program
> >> >from C to C++ and the performance halved because of the class call
> >> >overhead (even trying to maximise in lining) .
> >> >
> >> >Ben
> >> >
> >> >> -----Original Message-----
> >> >> From: Unmoderated discussion of advanced .NET topics.
> >> >[mailto:ADVANCED-
> >> >> [EMAIL PROTECTED] On Behalf Of Vijay Mahadevan
> >> >> Sent: Friday, 8 July 2005 12:38 PM
> >> >> To: [email protected]
> >> >> Subject: Re: [ADVANCED-DOTNET] Is C++ better over .NET Math library
> >?
> >> >>
> >> >> Dixon, Thanks for the link. The article was useful but very broad
> >> >> based on all scientific applications. It has some good tips on
> >> >> maximizing and optimising the memory used in a virtual environment
> >> >> while using arrays, vectors and matrices. Though it is part of what
> >i
> >> >> need, it doesn't answer my question entirely. I am also looking for
> >> >> improving performance in Math section of .NET libraries and if it
> >can
> >> >> be made to perform comparably to C++.
> >> >>
> >> >> William, Math.NET is a general mathematical library to perform
> >> >> operations of wide range. I already had a look at the Math.NET code
> >> >> and think that the library is not designed with speed in mind but
> >to
> >> >> be a helper for applications that need to utilize some of the
> >advanced
> >> >> math functions.
> >> >>
> >> >> Here is something that interested me.
> >> >> Extreme Optimization Mathematics Library for .NET
> >> >> http://www.extremeoptimization.com/Mathematics/Performance.aspx
> >> >>
> >> >> It is a commercial product but a look and an option to change the
> >code
> >> >> would be much more helpful.
> >> >>
> >> >> Has anyone dealt with Vectors and Matrices extensively in any of
> >your
> >> >> projects ? Do you have a C# implementation of the same and can you
> >> >> redirect me to a place where there is any info on that ?!
> >> >>
> >> >> Anyway, thanks a lot for the replies guys !
> >> >>
> >> >> On 7/7/05, William Bartholomew <[EMAIL PROTECTED]> wrote:
> >> >> > You may want to look at:
> >> >> >
> >> >> > http://www.cdrnet.net/projects/nmath/
> >> >> >
> >> >> > On 7/8/05, Vijay M <[EMAIL PROTECTED]> wrote:
> >> >> > > Hi everyone.
> >> >> > >
> >> >> > > I currently have a numerical simulation code working in MATLAB.
> >> >The
> >> >> code
> >> >> > > is for a scientific application and the complexity involved
> >till
> >> >now
> >> >> has
> >> >> > > not been much. The simulation is based on solving a non-linear
> >> >system
> >> >> > > which involves lots of iterations, the primary method being
> >> >Newton's
> >> >> > > method or Fixed point method. Since the complexity has been
> >> >minimal,
> >> >> > > MATLAB did support all the requirements but the speed was an
> >> >issue.
> >> >> > >
> >> >> > > Moving on, the next set of requirements involves heavy
> >computation
> >> >> with
> >> >> > > over millions of iterations. I am concerned about the usage of
> >> >MATLAB
> >> >> for
> >> >> > > this scenario and would like to move on to a faster platform. I
> >> >first
> >> >> > > considered C++ and then C#. I have worked on .NET for 2 years
> >but
> >> >> havent
> >> >> > > done much work on the Math side of the framework.
> >> >> > >
> >> >> > > Now is there a specific reason to choose C++ over .NET for such
> >an
> >> >> > > application ? Speed being a important consideration, what would
> >> >you
> >> >> guys
> >> >> > > suggest from your personal experience ?
> >> >> > >
> >> >> > > I have lots of calculations with vectors and matrices. So i am
> >> >also
> >> >> > > looking for a good implementation of BLAS/LAPACK in C# (If .NET
> >> >works
> >> >> > > better !) with comparable performance to its native predecessor
> >!
> >> >> Anyone
> >> >> > > know any ??
> >> >> > >
> >> >> > > Although i do believe benchmarks are useless without the
> >> >parameters,
> >> >> all
> >> >> > > of them do suggest that VC++ is much better than VC#.
> >Intuitively
> >> >i
> >> >> > > guessed that but are there any specific compiler options to
> >> >optimize
> >> >> the
> >> >> > > execution of certain math operations in C# to maximize the
> >> >performance
> >> >> ?
> >> >> > >
> >> >> > > Sorry for such a long background on what i was doing but felt
> >that
> >> >it
> >> >> was
> >> >> > > necessary. Thanks for any help you guys can provide.
> >> >> > >
> 
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
> 
> View archives and manage your subscription(s) at http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to