Should a WPF application be written in C++/CLI or C#?
Asked Answered
A

6

10

WPF applications are, at its core, managed applications? Right? So, I have to choose between using managed C++ or managed C#. I experimented with managed C++ years ago. It seemed to be not quite be ready for primetime. I'm guessing Microsoft has put more effort into managed C# than managed C++. So, it seems like using managed C# is the best alternative between the two. Is this the case? What experiences have you had with WPF in either language? Thanks in advance.

Anesthesiologist answered 12/8, 2010 at 12:15 Comment(0)
P
14

Managed C++ has been replaced by C++/CLI, and "managed C#" is just C#.

I would strongly recommend you to use C# for a new project, and use C++/CLI only when needed. C# has a better support, has a larger user base, and is easier to work with inside Visual Studio 2010.

Additionally, keep in mind that C++ and C++/CLI are two different languages. For my first .Net project, I chose C++/CLI because I already knew C++, and this was a very bad idea: the learning curve from C++ to C++/CLI is similar to learning C# from C++: don't fall into that trap.

Powder answered 12/8, 2010 at 12:20 Comment(0)
I
4

C++/CLI was only really made to support writing interop layers between unmanaged code (i.e. native C/C++) and managed code. For "heavy lifting", you should definitely use C# (or VisualBasic.NET).

Instrumentalism answered 12/8, 2010 at 12:24 Comment(0)
F
2

You can use managed C++ for your backend but, on inspection, VS (I'm using 2010 Ultimate) doesn't have any in-built templates for a C++ WPF application - only C# or VB.

I'm sure you could force it to work if you wanted to, but I'd suggest you use C#.

Fischer answered 12/8, 2010 at 12:22 Comment(0)
A
1

In terms of the backend, they both run on the CLR and both capable of the job. Really it just comes down to what you're most comfortable with. If you're not sure, experiment with both. Use whatever feels most productive.

Edit:

As has just been pointed out to me though, it seems support for WPF templates (and possibly even intellisense) just isn't there for C++. So in that case I guess I'd have to recommend C#.

Agentive answered 12/8, 2010 at 12:17 Comment(2)
Not really: Visual Studio has IDE features to support WPF development with C# (and VB.NET) but not for C++/CLI. And then there's this: #2682499Vitrify
Thanks for bringing that to my attention. I didn't realise support was that lacking.Agentive
V
1

C# is the most used, so if you have trouble, there is more online support for C#. C# also has better support by Microsoft. It's overall just a more finished product, even now. If you really don't care yourself, i'd go with C#.

Vinni answered 12/8, 2010 at 12:20 Comment(2)
Not true. C++/CLI is a finished and wonderful product, especially with C++0x specifications and the ability to use C++ header-only template libraries. However it is seldom the right tool for the job.Charade
I think C++ is better for games, where you need to get to a basic level often. WPF is trying to do the exact oposite; 'get away from drawing and let me do everything for you'. C# just fits that concept better.Vinni
C
1

IMO without a doubt C# (or VB/F#).

C++/CLI is great when crossing the border of managed world and a c++ library. Complexity is higher though as subtle issues arises from the fact that one combine a managed language and an unmanaged.

Compile times are longer though as well in C++/CLI especially since the code templates are modelled after how the C# compiler works not on how the C++ compiler works.

Chemical answered 12/8, 2010 at 14:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.