C and C++ are old and tiredlanguages that have outlived their usefulness. For programmers, there are more productive ways to develop software. The odds of getting engineers a reliable program to use are significantly better with C#. While C and C++ are expressive and powerful languages, letting anyone but very experienced programmers use them is like greasing the floors and letting your programmers run across it with knives. The most likely victims will be schedules and/or code reliability.
Productivity is significantly influenced by a language's ease of use and the time it takes to debug and fix problems. Any language that requires a book like "C++ Gotchas", which describes 99 common C++ programming mistakes, has serious usability issues. For instance, who really has a handle on how to decipher C type declarations like:
char *(*(*a[5])())();
Don't get me started on the myriad string data types and APIs you have to deal with: ASCII char*, multi-byte char*, wchar_t, CString, BSTR, CComBstr, _bstr_t and basic_string<>. Come on! How many different ways of dealing with a string do we need?
By far the biggest productivity killer is the vast potential for writing buggy C or C++ code. Dynamic memory management and the pointers typically used in conjunction with them get more programmers into trouble than any other feature of C or C++. If you don't remember to explicitly free memory you have memory leaks. If you access memory that has been freed, your program may crash or behave unexpectedly. Indices used to access arrays are not validated in C or C++. As a result, an "off by one" error can cause undetected memory stomps that in turn can cause your program to crash somewhere completely different than where the stomp occurred.
C# leaves C and C++ in the dust when it comes to programmer productivity. C# and the underlying Microsoft .NET platform put to good use the exponential improvement in computing power that has occurred in the 30 years since C was created. The extra compute capacity is used to provide automatic garbage collection, which eliminates memory leaks and freed memory reads altogether. Array accesses are always checked at runtime to verify the index is valid; this eliminates one source of memory stomps. Since C# doesn't require the use of pointers, another class of memory stomps are eliminated. While these services require a little extra computing power, the way I look at it is that hardware is cheap, software development time is not.
Many C/C++ programmers are concerned about standards and performance. C# has been standardized by both ECMA and ISO. C# performance is not only better than Java and Visual Basic, it also isn't too far off the performance of C/C++. Furthermore, most instrumentation automation programs are performance limited not by the development language but by instrument I/O.
The SDK comes with the C# command line compiler as well as many sample programs. I predict that you will be pleasantly surprised at how far your C or C++ skill set can take you with C# and how much more productive you will be.
Author Information
Keith Hill has a BSEE and a masters in electrical and computer engineering.
JUNE 26TH WEBCAST: Collaborative Requirements Engineering
Speed your innovation. Capture the "voice of the customer" and translate customer requests into user requirements that define new products. Find out why the new ENOVIA Requirements Management solution enables organizations to improve their overall global requirements management process. Read More
Mechatronics in action
Successful synergistic integration of controls, electronics, computers and mechanical systems is key to the 21st century design process. Unlock the secrets at the Mechatronics Zone!
Webcast: Sensor Know-How Now
Join our moderator Randy Frank and John Keating from Cognex and explore Solving Industrial Inspection Problems. Read More
Engineering Concept Conduit
Engineering Concept Conduit looks at new products and the components that make them exceptional. Each month we’ll look at a new electronic product and see what makes it tick from an engineering point of view. We’ll explore the design and engineering challenges for the product and examine the components that solved those challenges.
Light Matters: Systems Level Approach to HBLED illumination applications
Its good practice to apply a systems-level approach to high-brightness LED (HBLED) illumination applications. Minimally, the system includes the optical, thermal and electrical characteristics of the of the HBLED, the lens (if any) which is built-in to its package, secondary optics such as external plastic lenses/reflectors to direct the light as your application requires and power driver electronics. Read More