Thread: Why C Matters

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Quote Originally Posted by abachler View Post
    As for function overloading, its called function renaming, The C++ preprocessor just handles it automatically for you.
    You're right, function overloading is usually implemented by "mangling" the names of the functions to include some information about the function's arguments. However, it's the compiler that does this, not the preprocessor. The preprocessor does very few things, among them:
    • File inclusion with #include.
    • Conditional compilation with #if etc.
    • Macros with #define.
    • Comments (the preprocessor strips them).
    • String literal concatenation.


    The first C++ "compiler" was actually a source-to-source translator: it simply converted C++ into C. So every feature of C++ can be represented in C. In fact, every feature of C++ can be represented in assembly -- that's how compilers can exist.

    But that doesn't mean we should be programming directly in assembly just because C++ can be converted into assembly. It's convenience, and abstraction, that makes us use higher-level languages.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    I dont disagree with you dwks, but I dont see C++ as a seperate language from C. It has more features for sure, just as modern english is more descriptive than english of say 100 years ago. Both can be translated into grunts whistles and other basic phoenetic primitives. That doesnt make 19th century english and modern english 2 seperate languages, nor does it mean we should all go around speaking in phoenetics either. I can obviously translate any modern phrases into terms in use in the 19th century, granted it woudl take longer to express teh same concepts, just as it woudl take more lines of code to express the same behavior in C as in C++. Again, this does not make them seperate languages, merely differnt dialects at most.

    Quote Originally Posted by vart View Post
    it is for dynamic memory allocation, what it has to do with classes? If you do not use classes?
    new/delete is the primary way to instantiate a class. it is a bit difficult to instantiate a class using malloc. I really fail to see what you are asking?

    Code:
    int* arr = new int[15];
    can be just as easily expressed in C as

    Code:
    int* arr = malloc(15 * sizeof(int));
    Last edited by abachler; 01-09-2008 at 11:10 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Speed of C++
    By bobthebullet990 in forum A Brief History of Cprogramming.com
    Replies: 64
    Last Post: 01-12-2007, 02:39 AM
  2. Replies: 2
    Last Post: 09-28-2006, 01:06 PM
  3. C++ tests.
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 38
    Last Post: 06-30-2006, 06:51 AM
  4. Confuted/Blackrat: quaternion question
    By Silvercord in forum Game Programming
    Replies: 12
    Last Post: 08-18-2003, 06:02 PM