Should I upgrade my program from C to modern C or C ++?

I have an old program written in C since the 1990s. I would like to update it so that it works for the following individuals and modern compilers. I am currently using a really old version of TurboC to make changes. Should I focus on rewriting this in modern C or C ++? What will be the easiest way to update this code without having to rewrite too much and be able to reuse most of the existing code?

My programming background was mainly in hprogramming languages ​​such as Perl, Python, PHP, Powershell and Visual Basic, so I don't really understand the differences between C and C ++.

+4
source share
5 answers

C and C ++ are different languages, not different versions of the same language. Stick to C, although you can use the fancy features of newer versions of the standard, such as C99.

+5
source

Your last sentence largely meets your feelings. If you are not familiar with the differences and only know the old languages, I would not update this program if it did not have something terrible that affects many users.

You can only update it in the C world to stick with C99 or C11 if you have a new compiler

+5
source

Given:

have an old program written in C since the 1990s.

You have two questions:

Should I focus on rewriting this in modern C? Maybe, maybe not. I would try to stick with the standard C89, C99 or C11. It mainly depends on your tools and how the new development will develop.

Do you like to declare variables except at the beginning of the scope? If so, then maybe upgrading to C99. Do you use any tools that really look like C89 and show errors or warnings with C99 conventions? If so, stick with C89.

If the program is constantly updated, and you hire young people, then newer agreements may be useful.

Should I focus on rewriting this in C ++? Not.

+3
source

Most well-written C programs are also valid C ++ programs or require little adaptation. The opposite is wrong.

Most likely, it is easier to stick to ANSI / ISO C and leave both doors open for the next maintainer.

+3
source

Probably about the same effort has moved into the modern C compiler against the modern C ++ compiler. The evolution of C and C ++ diverged where everyone has similar functions, but they are not compatible with the source code.

There are several factors that would lead me to upgrade to C ++:

  • Modern C does not seem to enjoy the support of C ++. For example, many new things in C seem to be implemented only in accordance with the requirements of C ++, especially in the Microsoft world. VS doesn't even support C99, except in C ++, not to mention C11.

  • C ++ is better than C : "C ++ is" better than C "in the sense that it supports programming styles using C with better type checking and more notational support (without loss of efficiency)." This still applies to modern versions of C.

  • C ++ adds functions that support some very powerful methods. In fact, their use may be best left to library developers, but that means C ++ can support really great libraries.

+2
source

All Articles