Visual C++/CLI  
Author Message
IntMain





PostPosted: Visual C++ General, Visual C++/CLI Top

Hi all.Is it fine if i use visual C# .net tutorials and resources for creating windows forms apps and incorparate the code into C++/CLI .net I mean, C++/CLI uses the .NET Framework also to create windows forms apps right So the only thing to change is the syntax(the "." to "::" or "->", variable declarations, conditional statements, classes etc etc) if i am correct here. Meaning whatever ever code in C# has been written e.g: to make a paint prog, i could just change the variable declarations,ways the functions are declared, and other things like that involving the language syntax, correct

Help would be appreciated :D

Thanks



Visual C++2  
 
 
David Anton





PostPosted: Visual C++ General, Visual C++/CLI Top

We've actually developed a tool for this purpose. Our Instant C++ utility converts C# or VB syntax to C++/CLI. You might find the demo useful (converts up to 1000 line projects and 100 line code snippets).

Regards,

David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# Converter
Instant VB: C# to VB Converter
Instant C++: C# to C++ Converter
Instant C++: VB to C++ Converter
Clear VB: Cleans up VB code



 
 
Ben Anderson MSFT





PostPosted: Visual C++ General, Visual C++/CLI Top

In case you were wondering - that means yes ;).

(you can use the examples)



 
 
n0n4m3





PostPosted: Visual C++ General, Visual C++/CLI Top

Hi,
to answer your question short: everything should work fine.

Describing a bit more of the .net framework:
When you compile a program in c# or c++/cli, it will be converted to CIL (common intermediate language) and this gets executed by the CLR (common language runtime, the "virtual machine"). There's also the CLI (common language infrastructure) that define the rules that allow other languages like c++/c#/vb, etc. to run in multiple platforms; of course, CLR is written by the CLI specification and there are also other CLI implementations like mono or dotgnu.

Since both languages (c# and c++/cli) run through the same mechanism you'll be able to (almost linearly) convert a c# program into a c++/cli one.

I usually do that often when I need something done with the .net framework, I search for an example in c#, since we can find those better than the c++/cli ones, and convert it to c++/cli.



 
 
IntMain





PostPosted: Visual C++ General, Visual C++/CLI Top

Thanks so much for the fast replies guys :D

The main reason im wanting to do this is because i want to be able to create Windows Forms app's in C++/CLI .NET and seeing that there arent alot of tutorials or books covered on this, i thought i'd use other tutorials for Visual C# ,VB.NET and sometimes even Visual C++ .NET(Microsofts visual c++.net step by step book describes alot of the common event handlers for windows forms apps) and implement it into Managed C++/CLI. I would learn C#, but everyone is saying that C++/CLI is the most powerful language in the .NET(Even Microsoft say it in MSDN ), especially for windows forms :P

 

 

Thanks again


 
 
David Anton





PostPosted: Visual C++ General, Visual C++/CLI Top

You'll probably start seeing more and more C++/CLI samples. The C++/CLI momentum is starting to build.

David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter
Instant C++: VB to C++ converter
Clear VB: Cleans up VB.NET code



 
 
IntMain





PostPosted: Visual C++ General, Visual C++/CLI Top

Mr.Anton, wow!Your Converter is incredible :o

It works like a charm :D

On the other hand, C++/CLI just recently came out so it will definately take time to start seeing more resources for it. But im already impressed by the amounts of books that have already been released on it.


 
 
David Anton





PostPosted: Visual C++ General, Visual C++/CLI Top

Glad to hear you like it.



 
 
IntMain





PostPosted: Visual C++ General, Visual C++/CLI Top

Bah, Ive decided to move to C# now. Ive been trying to convince myself over and over again that C++/CLI .NET is the superior one, but now im going to have to face the truth thats been waiting to come out..By far, C# has ALOT, and by that i mean ALOT more resources,books,code examples etc than C++/CLI .NET. Believe me, C# has only been around for 5-6 years and yet it has more Programmers coding in it than in C++ or Java.Every C++ Programmer is moving into C# also.

 

If C++/CLI had nearly as much resources,code samples and books as C#, i would stick to it..

 

Im most likely moving to C# soon unless someone can convince me otherwise.


 
 
Ben Anderson MSFT





PostPosted: Visual C++ General, Visual C++/CLI Top

Every tool has its purpose, and depending on what sort of thing you're trying to do, C++, C++/CLI, or C# may be better for you.

C# is great for productivity if you live in a purely managed world, but at the moment that comes at a cost - speed, versatility, control, scaleability and functionality. If you can live with those costs, and many applications can, then C# is for you. C# also has a better IDE experience given the fact that it's a much smaller and less complicated language to parse and all its parsing tools are mostly brand-new. Also, C# will work well with XAML and WPF straight out of the box. A great place for using C# is in the UI, and then using a thin layer of C++/CLI to interface with a pure native C++ backend for speed.

C++/CLI can do everything C# can do, plus gives you some additional features as well as better control over the CLR. This of course runs into the sharp knife problem - it cuts better, but it's also easier to cut yourself. The big wins with C++/CLI over C# are deterministic finalization, templated code (much faster than C# generics), and a more sophisticated optimizing compiler resulting in speed wins, and perhaps most persuasive, easy, direct and fast interop with native code and standard C++. Check CodeGuru - it's orders of magnitude faster than using p/invokes. Regardless of how much documentation and examples C# has generated in the last five years, that's comparing anthills to mountains when it comes to the amount of resources available in the C++ world in terms of apis, existing codebases and examples.

C++ is what it always has been - a (mostly) elegant solution for writing code in a high level programming language which still cuts to the bone when it comes down to control of the machine. Any sort of field where perf is important will still use C++ over C# to do the heavy lifting. Systems programming, large applications, games etc need that native perf.

Hopefully in the long run it will be possible to get the same sort of perf out of managed code as you currently can with native, and in some situations, you can get close even now. It ultimately comes down to picking the right tool for the job and what kind of programmer you and your team are. C# and C++ (as well as C++/CLI) are great choices for the fields they attempt to service, and there are clear areas where one is better than the other for a particular task.

-Ben



 
 
Marcus Rahilly





PostPosted: Visual C++ General, Visual C++/CLI Top

Ben said:

"C++/CLI can do everything C# can do, plus..."

Ben - I translated into C++/CLI and got working C# Managed DirectX/Direct3D samples. This now works just great.

The one thing that stumps me is how to do ASP.NET 2.0 / Web Apps using C++/CLI.

Do you know of any such samples This could be holding back C++/CLI adoption in a big way for a lot of developers - the perception that C++/CLI can not handle Web Applications even though it does handle Web Services

/Marcus



 
 
Ben Anderson MSFT





PostPosted: Visual C++ General, Visual C++/CLI Top

Unfortunately I am not particularly familiar with ASP.NET. I imagine there is a way to write your ASP.NET code in C++/CLI since it all compiles to the same IL, but it might involve some potentially **** manual build setup. You happen to have hit on what I believe to be the biggest weakness of the C++/CLI language as a general purpose CLI development language which is development tool support. Since C++/CLI is far newer than the other .Net languages (VB and C#), the tool support - particularly in specialized fields such as the Visual Web Developer IDE - is not at the same level.

You'll notice the same issue if you work with some of the CTP previews of LINQ or WPF designers (WPF code can be written in C++/CLI, but the designer and the XAML generation only work with C# and VB). Unfortunately, C++/CLI is probably not the best, or even a reasonable option in such cases, and I would say probably doesn't make sense in other areas where perf is not such a necessity.

Re: "C++/CLI can do everything C# can do, plus..." - I guess I have to eat my words on that one.

That said, for the case of ASP.NET, I believe the barrier is not particularly high if you are willing to figure out the build options the IDE is setting up for you behind the scenes and replicate them with C++/CLI if you prefer the language to the other options, or if you are particularly concerned about control and perf issues.


 
 
Ben Anderson MSFT





PostPosted: Visual C++ General, Visual C++/CLI Top

Re: eating my words - there is one feature which C++/CLI does not currently support which is something called partial classes (and is why it doesn't work right now with XAML). It's possible that ASP.NET requires this support in which case C++/CLI may not work.