Motley says: "Native C++ code development is obsolete"
Summary
Motley: Native C++ code development is obsolete. Everyone should be using a language like C# or Java.
Maven: Managed code is a great platform, but there are still reasons to use native C++, such as enhancing legacy code and developing an operating system (e.g. Windows Mobile). Understanding C++ makes you a better managed code developer.
______________________________
[Context: Maven and Motley are in the middle of discussing programming languages and, in particular, C#. Motley is pondering other languages and their usefulness]
Maven: I agree with you Mot - C# is a killer language. There are constant strides to move it forward and it is very intuitive for a new developer to learn.
Motley: I wouldn't want to develop in any other language, thank you very much. In fact, I am surprised other languages still exist. Well, Java has a place for the non-Windows developers, but other than that, why maintain them?
Maven: C# is great, but there are other languages out there that are still widely used. C++, for example, is still used in many different companies and serves a real need.
Motley: Hah! Name one. There are so many advantages to developing with managed code that you don't get in C++. C# is much more intuitive and easier to learn than C++. It is harder to make nasty mistakes considering you have garbage collection. Exception handling is a built-in construct. Your code is optimized by the Just-In-Time (JIT) compiler dynamically according to the platform you are executing on. I could go on and on.
Maven: Here's where you may want to have a chat with James. Before joining Cynthesis he worked for Microsoft in the Entertainment and Devices division group developing components for the Windows Mobile operating system that runs on tens of millions of so-called "smart phones". His work on that team was all native code.
Motley: Sucks to be him. I am willing to bet he is the victim of code complexity, a legacy code base, extremely long build times, nasty dangling pointer problems, and a host of other issues that are an order of magnitude more complicated than developing for .NET.
Maven: Yes, he told me that there were some nasty problems. But the point is that there are real reasons why the group chose to develop on a native C++ platform.
Motley: I'm waiting.
Maven: When you think about it, developing for mobile and embedded devices is almost like taking a step back in time a few years. Consider the type of hardware you are developing for:
- Devices are constrained by CPU - a 200Mhz or 600Mhz processor (if you are lucky) is the norm. Writing software that exhibits high performance is a critical concern.
- Devices are constrained by memory - 128MB of RAM (if you are lucky). Applications with high memory usage are not acceptable.
- Devices are constrained by unconnected power - rechargeable batteries last a few days (if you are lucky). Software that sucks CPU and other resources has a big impact on battery life. Efficiency is king.
- Devices are constrained by typically not having a floating point unit or graphics processor. As a result, the algorithms you choose must take efficiency into account.
When you consider all these constraints, you want to develop applications to be as lean and mean as possible. The Common Language Runtime (CLR) has significant overhead in the system and is a negative drain on efficiency.
Motley: Those concerns are less prominent in most other types of development, however.
Maven: You might think, but ignoring these constraints even on desktop workstations leads to much more bloated software and applications that do not play nice with one another. Although not necessarily high profile, the skills that a mobile developer possesses make her a better developer overall, regardless of application domain, platform or language. You started out on C++, didn't you?
Motley: Yeah, and I never want to go back. As far as I'm concerned, native C++ code development is obsolete.
Maven: C++ is far from obsolete. In fact, standardization of the new version of the language, C++ 0x, should be completed by end of 2009.
Motley: Great. I'll just take a job where developers use managed code and be happy.
Maven: That's fine, although there are many more reasons to join a team than just technology and programming language. We discussed that previously. Anyway, I would argue that you are a better developer now because you had a C++ background. You understand what a pointer is don't you?
Motley: Don't insult me.
Maven: Do you ignore the concept of a pointer in managed code?
Motley: Absolutely not. There are times to pass objects by reference. There are times when using COM Interop that I have to worry about AddRef and Release. There are times when I do server-side development that I have to explore heap fragmentation issues (and in rare circumstances heap corruptions). Understanding a pointer is a necessity.
Maven: I agree! In addition, and when writing an operating system like Windows Mobile, you may need finer control at many different levels of the architecture. You cannot take the hit in performance for garbage collection. You may need your own memory manager given hardware constraints. You need finer control over the creation and destruction of objects to ensure resources are freed as soon as possible.
Motley: Understood. It's just not for me. I did my time.
Maven: I prefer the .NET platform as well. James, however, just found such a fantastic team at Microsoft that he gave up his technology preference to build a cool application with super strong developers. Although COM and C++ have been around for years, they are here to stay for a while yet. There is lot of legacy code written in C++ that still must be maintained. Although we may wish that the entire development population wrote managed code, that day is still far off in the future.
______________________________
Maven's Pointer: Is Maven's "pointer" a bit of a misnomer if we talk mostly about managed code? Well, yes and no, as Motley indicated. Taking some time to understand the underlying technology behind managed code will improve you as a developer. This may include starting at the level of C++ but also delving down into intermediate language (what C# compiles into) and assembly language. By the way, if you understand how a Reverse Polish Notation (RPN) calculator works and its stack-based number manipulation, you already understand much of what you need to grasp intermediate language (IL).
Maven's Double Pointer Indirection: Microsoft made a big bet on .NET with Windows Vista a few years ago exposing the majority of the APIs as managed code. The best didn't really pan out and contributed to forcing a development reset partway through the cycle. Managed code has a great future for many different types of applications, but for developing operating systems, more improvements are in order.
Maven's Triple Pointer Indirection: This is a bit of a controversial topic. I'd love to hear the opinions of others out there. How long will native languages like C++ be around?
Maven's Resources: