The Artima Developer Community
Sponsored Link

.NET Buzz Forum
C++ for .NET at dotned

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Peter van Ooijen

Posts: 284
Nickname: petergekko
Registered: Sep, 2003

Peter van Ooijen is a .NET devloper/architect for Gekko Software
C++ for .NET at dotned Posted: May 3, 2005 5:45 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Peter van Ooijen.
Original Post: C++ for .NET at dotned
Feed Title: Peter's Gekko
Feed URL: /error.htm?aspxerrorpath=/blogs/peter.van.ooijen/rss.aspx
Feed Description: My weblog cotains tips tricks and opinions on ASP.NET, tablet PC's and tech in general.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Peter van Ooijen
Latest Posts From Peter's Gekko

Advertisement

Yesterday we had the VS 2005 C++ team at the dotned user group meeting. It was a good meeting and a good talk. Ronald Laeremans is somebody who can, and will, talk for hours. The C++ vision on .net is quite interesting, let me reproduce some of the things I learned.

To me the C++ language has always been you had to learn to live with, never did any real C++ programming but I had to read C++ on a daily basis. All code samples were in C++, incorporating the ideas in my Delphi win32 required translating. These days I do mainly C#, a language whose syntax is far closer to C++ than Object Pascal but whose “architecture” (events, properties, components) comes far closer to Delphi.

C++ is still a major language at MS, according to the VC team 95% of the MS products is coded in C ++. The team was clearly jealous on the new star C# but gave some good reasons to use (unmanaged) C++:

  • Existing code base. You can’t dump 20 years of Windows and Office development
  • Backward compatibilty.
  • Do your own memory management. Some code has to keep running with 0% memory free. In managed code the smallest things, like boxing an integer, can result in a memory allocation (by the CLR)
  • Directly invoking an unmanaged function is checked at compile time. A dllimport in managed code is checked at runtime.

The upcoming C++ does a couple of things to bring the world of unmanaged C++ and managed code together

  • To the compiler IL is just another platform target, there’s x86, Itanium and IL
  • When declaring a class in C++ you can prefix the class with the value or ref keyword. The class (type) will than be compiled into a managed class which can be reused by any .net language using the assemby. A class without a prefix is a native class.
  • The clr:safe compiler directive checks your code on the absence of pointers and native classes. When both criteria are met you have a built a managed assembly with C++.
  • A nice feature are trivial properties and events. Declared as a property but you don’t have to write out the (trivial) getter and setter routines.

Some nice scenarios of mixed code

  • Wrap up DirectX complexities. Directly address DirectX objects iterated in a .net foreach loop.
  • Give an MFC app a .NET Winforms UI. As a demonstration the team had built a customized slide sorter for Powerpoint. Powerpoint in an MFC app and Winforms is very good in building a sophisticated UI.

C++ is clearly not intended as a mainstream language. You can still do horrific things. And in your app you’re dealing with three kinds of memory: the stack, the managed heap and the native heap. Not for the faint of heart. I will stick to my beloved C# but have seen good things to further expand my horizon. (But will not forget pInvoke.net)

Another part of a meeting is the social networking part. Of course Sander and Hassan were there and I promissed to restore the broken links to their perfomaces on a former meeting. Is done. See you at the next meeting.

Read: C++ for .NET at dotned

Topic: When you have a plumbing problem, hire a plumber Previous Topic   Next Topic Topic: TestDriven.Net version 1.1 has been released

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use