C# vs C++

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 6954 Views - Last Post: 18 September 2011 - 08:15 PM

#1 tsotne1990  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 230
  • Joined: 01-November 10

C# vs C++

Posted 12 February 2011 - 12:21 PM

Why would you prefer C# over C++????

From the math point of view if possible

Thanks
Is This A Good Question/Topic? 1
  • +

Replies To: C# vs C++

#2 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1251
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: C# vs C++

Posted 12 February 2011 - 01:13 PM

I suck at math but I can't wait to see the responses the veterans have. :) I just hope they are factual answers and not the typical, C++ is faster and managed code is slower.
Was This Post Helpful? 1
  • +
  • -

#3 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4317
  • View blog
  • Posts: 7,486
  • Joined: 08-June 10

Re: C# vs C++

Posted 12 February 2011 - 02:02 PM

*
POPULAR

Frankly, I don't give a crap about math. I use almost no math in my day-to-day programming. I write business applications. C# is, in my opinion, is easier to work with, and more efficient when it comes to my time.
Was This Post Helpful? 7
  • +
  • -

#4 Jeff H  Icon User is offline

  • D.I.C Regular

Reputation: 112
  • View blog
  • Posts: 307
  • Joined: 30-January 11

Re: C# vs C++

Posted 12 February 2011 - 02:22 PM

Guess it would depend on the problem. I would use which ever one someone has created a Library that would make it easiest. Also the development of F# and LINQ, C# keeps getting more functional style capabilities
Was This Post Helpful? 0
  • +
  • -

#5 MATTtheSEAHAWK  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 137
  • View blog
  • Posts: 782
  • Joined: 11-September 10

Re: C# vs C++

Posted 13 February 2011 - 09:55 AM

Majority of computer owners own a windows computer. And C# is built for windows and already has all of the built in classes of the .Net framework. As said, it just saves a ton of time.
Was This Post Helpful? 0
  • +
  • -

#6 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 463
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: C# vs C++

Posted 13 February 2011 - 10:42 AM

To be honest the only time i will choice C# over C++ is if i got to make some kind of GUI(speaking not for VS C++). Otherwise C++ is easier and more clear the C# to write codes for me at least.
Was This Post Helpful? 1
  • +
  • -

#7 Martyr2  Icon User is online

  • Programming Theoretician
  • member icon

Reputation: 4194
  • View blog
  • Posts: 11,871
  • Joined: 18-April 07

Re: C# vs C++

Posted 13 February 2011 - 10:50 AM

*
POPULAR

From a math stand point there really is no difference. Functions and formulas can be coded in either. C# was built on many of the ideas of C++ but built from the ground up to support the .NET framework. The code it generates is transformed into the MSIL or Micrososft Intermediate Language... a type of bytecode that the common language runtime (CLR) converts to the native language of the machine. This is not what happens with C++ which is directly compiled to native code... and often times the reason why C++ is said to be a bit speedier.

Why would you choose C# over C++? If you need to code in the .NET framework, C# is going to be your choice. If you need classes to save time, better GUI features and an event driven type of language C# is better suited for that. If you need something that is a bit speedier, needs to get down at a low level to handle memory or device hardware (like video cards and its memory) then C++ may be a better route.

But as for math, they are virtually identical. :)

This post has been edited by Martyr2: 13 February 2011 - 10:51 AM

Was This Post Helpful? 10
  • +
  • -

#8 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1292
  • Posts: 2,868
  • Joined: 30-January 11

Re: C# vs C++

Posted 13 February 2011 - 11:51 AM

I learnt programming first through C++ and i must say my experience with it was horrible. The syntax is outdated, and because you have to manage your own memory and use memory pointers for everything, the workload soon rises. Since i've moved to C# and have recently done some mathematical projects i can see in my opinion at least that C# is so much better.

But as Martyr2 has said, if you want more spped (even though the differences are slimming) go with C++, but for everything else i would advise sticking with C#.
Was This Post Helpful? 0
  • +
  • -

#9 jens  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 67
  • View blog
  • Posts: 430
  • Joined: 09-May 08

Re: C# vs C++

Posted 14 February 2011 - 07:03 AM

Which one has most pre defined mathematical functionality...
Which one has the best tested mathematical functionalities...
Which one executes faster...
Which one saves you most often from introducing erraneous results...
Is there any "smart" functionality built in to either one that might "save" you when you do somthing stupid like ln(0) - in effect sabotageing your calculations?

I don't know but I sure would try to get answers to the above before desciding.

Personally I like C# because it's comparably easier to work with. :)
/Jens
Was This Post Helpful? 0
  • +
  • -

#10 sk8ermeb  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 20
  • View blog
  • Posts: 111
  • Joined: 23-March 10

Re: C# vs C++

Posted 14 February 2011 - 09:54 AM

for low level bit arithmatic...I have done bitwise arithmitice with C (firmware) for communications and then c# for the gui interface...I say go with c# if you can its got all the same capabilities and the .net is easier for everything else...but I dont have much c++ experience specifically. O ya c# has the Parrallel task library for multicore threading that I have been hoping someone on this forum would try :P incase you calculation aren't as fast as c++... I would try it but Im stuck on a p4 :(
Was This Post Helpful? 0
  • +
  • -

#11 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1292
  • Posts: 2,868
  • Joined: 30-January 11

Re: C# vs C++

Posted 14 February 2011 - 10:42 AM

To be honest they are both practically exactly the same in terms of what you can do maths wise. Their in built built math libraries can handle most things. For creating more complex mathematical scenarios i would say that C# is beter as most say the code is easier to get to grips with. However you can most of the time create the exact same programs in both languages.

As was said before C++ will give you slightly more performance due to the fact that it isnt managed at runtime like C#. However this will only become apparent with programs that require a lot of computational power. For most jobs they will be practically the same.

Both languages have try/catch blocks that catch errors yet C++ has the added task of managing your own memory that can lead to serious memory leaks for inexperiences programmers.

As for 'smart' features neither really has any. However there's nothing that a simple if statement cant fix.

Its completely your choose but bascically if you want more work for a bit more speed then choose C++, but if you want to create complex mathematical structures etc and have memory managed code then C# is better.
Was This Post Helpful? 0
  • +
  • -

#12 marinus  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 135
  • View blog
  • Posts: 575
  • Joined: 14-April 10

Re: C# vs C++

Posted 24 March 2011 - 10:27 AM

I will keep it short and sweet ,

C# = GUI , WEB, Data Access .

C++ = Drivers , Devices , OS , Games, engines.


C# and C++

The magic comes here ,

you can create a Windows application in C# , then use native C++ for accessing Hardware or where low-level,memory access is required with unmanaged code .

These 2 languages can work together in harmony , and for this reason is why i want to learn more about programming in C++.


I think XNA was programmed this way , some C# and some C++ . A perfect combination :chef:

This post has been edited by marinus: 24 March 2011 - 10:29 AM

Was This Post Helpful? 0
  • +
  • -

#13 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 773
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: C# vs C++

Posted 24 March 2011 - 09:20 PM

As it was already mentioned, there is no actual difference between C# and C++ math-wise. As long as you understand what you're doing, you can create the same program with both languages. Performance overheads? That already depends on the implementation. Also, you should be aware that there is managed and unmanaged C++.

Managed C++ is using the same core .NET libraries as C# does with the benefit that you can use the regular C++ calls and general syntax. It has some support for WinForms and native interop (as any other .NET-compatible language). The end result will be either way transformed to MSIL, so whether you choose C# or managed C++ is a question of personal preference and experience.

Unmanaged C++, on the other hand, is going to be much more performant in many situations, but if you aren't really focusing on optimizations and performance control (add to that the usage of very simple functions), the performance gain/drop will not be significant. More than that, it won't be even visible without a profiler attached.

Think about your specific case - what are the tasks you need to accomplish? How much experience you have with both languages? If you decide to go the managed way, a lot of "plumbing" will be already done for you, while if you decide to implement your project in unmanaged code, expect to do more work (going back to the experience point).

Quote

C# = GUI , WEB, Data Access .

C++ = Drivers , Devices , OS , Games, engines.


You will probably want to write drivers in pure C. As of games and engines, you can make those in C# too. I would bring XNA to the table, but there are lots of third-party independent implementations added to that too.
Was This Post Helpful? 2
  • +
  • -

#14 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 996
  • View blog
  • Posts: 2,409
  • Joined: 04-October 09

Re: C# vs C++

Posted 26 March 2011 - 03:10 PM

View PostCore, on 24 March 2011 - 08:20 PM, said:

As it was already mentioned, there is no actual difference between C# and C++ math-wise. As long as you understand what you're doing, you can create the same program with both languages. Performance overheads? That already depends on the implementation.


This isn't true. C++ is still faster than C# math-wise. You can read all about my current testing here.

My next step is to implement Strassen algorithm and optimize it for C#.
Was This Post Helpful? 0
  • +
  • -

#15 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 773
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: C# vs C++

Posted 24 April 2011 - 08:52 PM

Math-wise as in term of mathematical operations, not performance. With managed code you will have small performance overheads compared to unmanaged code because there is an intermediary compilation layer (MSIL).
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2