Passion * Technology * Ruthless Competence

Monday, April 11, 2005

Not Your Father's C++

Certainly not my father's C++. I sat thru a presenation on VC++ 2005 today. Wow, I hadn't realized all the coolness there.

First off, all the syntax is working it's way thru the standards bodies, so no more underscore underscore syntax. It makes the code somewhat easier to read, but more importantly it's following a similar standardization process to CLI and C#.

Secondly, you can now use all the native C++ features (templates, multiple inheritance, buffer overrun protection, etc) and all the CLI features (garbage collection, generics, language interop) together. Previously, you had very limited choices for mixing the two coding idioms. No longer - go ahead and mix and match. This gives you the best of both worlds. Use templates, and expose them to other .NET languages as generics.

Finally, it brings deterministic finalization to .NET. In VC++ 2005, you can declare both a destructor (used when a class goes out of scope or is explicitly deleted) and a finalizer (used when the class is garbage collected). This is similar to the whole IDisposable approach for classes that wrap unmanaged resources (file handles, network sockets, etc). Actually, it's identical to IDisposable because that's how it's implemented! And it works both ways - if you instance a managed class that implements IDisposable "on the heap" then it will automatically call dispose at the end of scope. For example:

{  //C++ Version
   
FileStream fs = FileStream(path, FileMode::Create); 
   fs.Read(...);
   fs.Write(...);
//fs.Dispose called automatically

Even though the FileStream is implemented in C#, it behaves here like a stack type and is destructed as you would expect. In C#, you'd have to use a using statement to achieve the same effect. For this trival example, it's not that big a deal. But if you have multiple stack instances created at different times within a scope, this helps out immensely.

Not sure I would move to C++ for all my managed programming, but I'll certainly be giving VC++ 2005 another look.

Posted By Harry Pierson at 8:54 PM Pacific Daylight Time
Tuesday, April 12, 2005 5:01:19 AM (Pacific Standard Time, UTC-08:00)
So what's the syntax for a "generic template"? And is it different from a "templated generic"? Programmers find it hard to ignore features in a language. I'm afraid this will lead to unreadable code.
your father
Comments are closed.
TechEd New Zealand
TechEd Australia

PDC08

patterns & practices
Summit 2008

Change Congress
Recent Bookmarks
Tags .NET Framework (2) ADO.NET (5) Agile (7) AJAX (3) Architecture (284) Guidance (6) Interop (2) Modelling (61) Patterns (7) Process (4) SOA (93) Web Services (5) ASP.NET (22) Battlestar Galactica (3) BI (2) BizTalk (4) Blogging (115) dasBlog (11) Podcasting (4) BPM (1) C# (10) C++ (4) Capitals (5) CardSpace (3) CLR (2) College Football (10) Comedy Central (1) Community (81) Concurrency (6) Consumer Electronics (1) Database (13) Dependency Injection (2) Development (116) C Plus Plus (1) Embedded (5) Lanugages (37) Media (2) P2P (11) Rotor (1) SharePoint (6) SOP (3) DIY (1) DLR (12) Domain Specific Languages (13) Durable Messaging (5) Dynamic Languages (9) Dynamic Silverlight (1) Education (3) Enterprise 2.0 (1) Entertainment (14) ETech (15) F# (50) Functional Programming (17) Game Development (2) Guidance Automation (3) Hardware (8) HawkEye (3) Hockey (29) Home Electronics (1) Home Network (5) Humor (5) IASA (1) Idempotence (3) infrastructure (5) Instrumentation (4) Integration (2) IronPython (24) IronRuby (10) Java (2) Job (3) LINQ (19) Live Mesh (1) Lost (1) Master Data Management (1) Media 2.0 (6) Microsoft (29) MIX06 (2) Mobile Phone (1) Monads (5) Morning Coffee (171) Object Oriented (4) Office (5) Open Source (5) Open Space (2) Operations (3) Other (135) Art (1) Books (1) Family (31) Games (18) General Geekery (26) Home Theater (1) Movies (23) Music (20) Politics (3) Society (1) Sports (37) Working at MSFT (15) Parsing Expression Grammar (16) patterns & practices (2) PDC08 (2) Politics (42) PowerPoint (2) PowerShell (32) Presentation (5) Projects (1) HawkWiki (1) Python (4) Quote of the Day (4) Refactoring (1) Research (2) REST (18) Reuse (5) Robotics (2) Rome (5) Ruby (23) Ruby on Rails (1) Sci-Fi (2) Scripting (4) Security (3) Service Broker (14) SharePoint (2) Silverlight (17) Social Software (1) Software + Services (2) Software Factories (11) Software Industry (1) Spark (1) SQL Server (2) Stephen Colbert (1) TechEd (7) TechEd06 (1) TechRec League (1) Television (6) Travel (6) Unified Client (1) Unit Testing (4) UX (1) Virtual PC (2) Visual Basic (1) Visual Studio (20) Volta (2) Washington Capitals (34) WCF (31) Web 2.0 (65) Web Services (5) WF (21) Windows Live (23) Xbox (1) Xbox 360 (53) XML (7) XNA (14)
Disclaimer: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion.