Why CC Cannot Be a Scripting Language

Why C/C++ Cannot Be a Scripting Language

C/C++ are unproductive, unsafe, and have an extremely high learning curve. Of course, for someone who has been using C/C++ for several years, these statements may seem untrue. Because C/C++ do not have a runtime engine, all the code must be compiled and linked ahead of time to a specific CPU’s instructions. In other words, it is not possible to execute arbitrary code during runtime.

A new developer can easily be baffled by the fact that there are many ways to do the same thing. To understand C++, a developer must understand C and C++ as well as the difference between the two. For example, in a cpp file you can allocate memory using the new keyword, the malloc function, or the calloc function. Similarly, to read a file you can use the fread or the C++ file input stream. Strings may be C-style character arrays, C++ strings, or MFC strings, and each has its own representation and ways of manipulation.

In addition, seemingly similar ways of doing things can give very different results or may even be entirely wrong. For example, an array can be conveniently initialized at declaration time as long as it is not a class member. The equals operator can be, and often is, overloaded to compare data other than the expected data.

C/C++ compilers generate errors that are excessively convoluted for a novice programmer. This is in part because of the complexity of the language and the fact that the compiler has to deal with a lot of legacy. For example, leaving out a semicolon results in rather interesting error messages. Leaving out a semicolon after declaring a class in a header file results in error messages that point the developer to the wrong files.

Dealing with header files is an unnecessary headache that a new developer should not have to deal with. Consider the fact that declaring global variables in a header file is perfectly fine until more than one source file includes the same header. Doing so results in the creation of multiple symbols with the same name, and an error is generated only when it comes time to link the object files. Circular inclusions can also be problematic and rely on the use of macros. In some situations, even if macros are used, you will need to add forward declarations to trick the compiler.

Pointers are one of the hardest topics to learn for new developers, and they are also unsafe. A pointer can be cast to any type and then used. Because of the complete access to the memory, a mistake in one module can cause a completely separate and unrelated module to fail because the first module can mistakenly corrupt the data used by the other module.

Besides the fact that C/C++ requires longer implementation time and debugging time, compiling a large C/C++ project can take a substantial amount of time. Simple projects may only need a minute, but an entire game or its tools can take anywhere from tens of minutes to a few hours. The time spent on simply compiling and linking the code is a bottleneck in the development pipeline.



Practical Java Game Programming
Practical Java Game Programming (Charles River Media Game Development)
ISBN: 1584503262
EAN: 2147483647
Year: 2003
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net