C & C++ FAQ's
Home ] Up ]

 


What ANSI C & C++ Standards are Available

ANSI C        C89, C99, C11, C17, C2x
ANSI C++    C++03, C++11, C++14, C++17, C++20, C++23
These are normally set in the C or C++ compiler for the current project
Generally use the latest one supported by your compiler and tool chain

What is the relationship between K&R C and ANSI C?

K&R C refers to Kerninghan and Ritchie C. Brian Kerninghan and Dennis Ritchie were the two men at Bell Labs that invented the C language in the early 1970’s. At the time it was created so that UNIX could be written in something other than assembly code. UNIX is typically written 90% in C and 10% in assembly code for the kernel which has to be extremely fast. Their primary focus seems to have been to create an extremely fast, small, and efficient programming language. They succeeded admirably. ANSI C is a newer version of C which was designed to overcome some of the shortcomings of K&R C and also allow the compiler to do more rigorous type checking of your code.

Should I use K&R C or ANSI C?

ANSI C is strongly recommended over K&R C. Just the compiler function prototype type checking alone is a significant advantage. If you call a function with an improper argument an ANSI C compiler will generate a fatal error immediately rather than having to spending hours trying to find out why it won't work properly.

Should I skip C and go directly to C++?

For most people the answer is no. C is still the preferred language for certain types of embedded programming; typically applications that have to be small, fast, and very efficient. C has a lot of utility in its own right. It also makes the process of learning C++ an easier, more digestible two step process. C++ is a superset of C and as such formally adds object oriented capability on top of C. Even though these two languages share a common heritage, you will have to work very differently with them to use each effectively. Meaning that strong C programmers will have to learn many new concepts and techniques to be able to use C++ effectively.

The number of 8 and16 bit microprocessors (CPU) and microcontrollers (MCU) sold absolutely dwarfs the number of 32 bit processors sold. This flies in the face of conventional wisdom but conventional wisdom is frequently wrong. 8 and 16 bit powered intelligent devices have become ubiquitous in industrialized society - they're everywhere. Some of the new high priced automobiles coming out contain as many as 70 microprocessors and/or microcontrollers. The vast majority of this code is written in C. Somebody has to write code for these applications and people who have skipped C to get to C++ won't know how. These types of applications require CPU's and MCU's that don't require much PCB space for themselves or their peripheral chips, are fast so they can be sleeping as much as possible,  are relatively inexpensive, and most of all require minimal amounts of power. These are all system level hardware issues and from what I've seen most software engineers understand hardware poorly if at all.

My recommendation is that programmers become proficient in both languages so they can handle all types of applications. C is still well suited for embedded applications that have to be small, fast, and energy efficient. C++ is well suited for larger, more complex applications, running on more powerful hardware.

What is the relationship between C and C++?

C is a very fast, powerful, flexible, and efficient computer programming language. C++ as a superset of C formally adds object oriented capability to the C language. C++ is far more powerful and complex than C - it adds a lot of sophisticated and exciting features to an already very potent language. Both are now ANSI compliant languages. I believe that they each have applications to which they are best suited.

What types of applications is C best suited for?

Applications that need to be small, fast, and efficient. C is a lean and mean programming language that comes close to the performance of assembly language while still allowing you to work in a high level language. C is best suited for procedural applications versus OO applications as well as support of smaller (8 and 16 bit) microprocessors and microcontrollers.

What types of applications is C++ best suited for?

C++ is best suited for large and complex applications that will typically have a long life and are expected to be enhanced significantly over time. OO languages are better equipped to deal with the logistics of implementing larger and more complex applications. GUI, CAD, CAE, and FEA applications are good examples of complex programs that are better handled with C++ than C.

Can you do object oriented programming in C?

Yes, it’s possible to do object oriented programming (OO) in any procedural language. It’s much easier to use an OO language though such as C++. OO languages have been designed from the ground up specifically to do OO programming and they support it much more efficiently and completely. If you have to use a procedural language but would like to use some of the OO concepts it is possible, but you have to write your code to implement them.

OO Programming sounds great, what’s the good news?

Microsoft Windows GUI programming for example, is much easier with Visual C++, or Borland C++ than with ANSI C. You are able to work at a higher level and simply not have to write as much code. 

OO Programming sounds great, what’s the bad news?

A significant learning curve and somewhat larger, slower code. OO languages are far more powerful, complex, and sophisticated than procedural languages. This power comes at a price. They are doing a lot of things for you automatically behind the scenes, hence the frequently larger file size and somewhat slower speed. Although C++ is much faster and more flexible than Visual Basic, I don't think it's that much harder to learn.

How long does it take to get a basic working knowledge of C or C++?

It generally takes a minimum of five days of training to cover the basics in C and another five days to cover the basics in C++, or a hybrid in five days. Additional training in more advanced topics is recommended. Even though most training courses are hands-on, additional practical experience after the class is over is essential.

What is GUI programming?

GUI, or Graphical User Interface, refers to Microsoft Windows, X Windows under UNIX, or the Apple Macintosh operating systems. They are graphically based operating systems rather than text based command line operating systems such as: DOS, UNIX, or mainframe computers. They also are at least multi-tasking and in the case of UNIX also multi-user. These are all much more powerful and complex operating systems than the command line versions with attendant increases in programming complexity. System resources such as: the display, keyboard, mouse, disk drives, and communications ports are all shared by software applications. This also increases programming complexity.

I want to do Windows GUI programming, what do I need to know?

A basic working knowledge of C, followed by a basic working knowledge of C++, then take a GUI programming course for a specific compiler and Microsoft Windows. Advanced C techniques (advanced pointers, etc.), Advanced C++ techniques (templates, STL, etc.) and Object Oriented Analysis & Design would also be very helpful. You need to be a reasonably proficient C++ programmer to be able to learn how to do Windows GUI programming. Unlike learning C and C++ which are ANSI standard languages and can be taught with any C or C++ compiler on any platform or operating system; GUI programming is tied to a very specific compiler, CPU platform, and operating system.

What is the MFC ?

MFC is the Microsoft Foundation Class C++ class library. It is a library of C++ classes and their member variables and member functions designed to aid in developing Microsoft Windows GUI applications. Other C++ compilers will normally have their own C++ class libraries for GUI applications. Borland provides the OWL or Object Window Library for example. Unfortunately while all of these GUI class libraries do generically the same thing they all work differently with different function names, prototypes, and calling sequences.

Is it possible to write portable GUI code ?

Yes, but you have to purchase C++ (or some other language) class libraries from a single vendor for specific GUI targets. Because all libraries have been developed by the same vendor, they have an identical programmers user interface; i.e., function names, prototypes, actual functionality, and calling sequence are identical regardless of GUI platform. Therefore your source code is portable across a variety of GUI platforms. The actual guts of each function will of course be different, but the vendor is taking care of that for you. See old copies of the C/C++ Users Journal for various vendors.

What is Embedded C++ (EC++)?

EC++ is an attempt to streamline C++ and remove the larger features that are not as desirable for embedded applications. Compiler vendors are trying to retain the most significant OO capabilities and remove those that are inefficient or not necessary for embedded applications. EC++ exists somewhere between C and full blown C++.

Am I a Novell Network Engineer or a MCSE?

No, I'm a real engineer, see the biographical data. I was programming in C before Microsoft even had a C compiler. Both of these certifications train people to be network technicians, not software engineers.



Copyright 2000 - 2023 by DeepSoft, LLC, All Rights Reserved