Thread: Why C Matters

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by vart View Post
    If it is so, why a lot of people wanting to buy a source code prefer C over C++?
    That's what I'm trying to figure out myself! I don't see why they'd want an older, less powerful language (as I see it, C is less powerful than C since C++ could do everything C can and more).

    Quote Originally Posted by CornedBee View Post
    C source is considerably easier to audit, because there's less going on behind the scenes. No hidden function calls. No surprising return paths through exceptions.
    But you miss out on powerful functionality. That's my thought on the matter. And C code generally looks messier than C++ code since C++ can use classes, so I don't agree.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #2
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    That's what I'm trying to figure out myself! I don't see why they'd want an older, less powerful language (as I see it, C is less powerful than C since C++ could do everything C can and more).
    I wouldent say C is less powerful; its lower level. C++ has features that make it easier to do stuff, but many come with overheads and its still very easy for someone hideous mess with it.

    Another option would be to use a higher level language like Java or C# for most stuff, and make a C dll to deal with the intensive bits.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    Omaha, Nebraska
    Posts
    116
    Quote Originally Posted by Elysia View Post
    ...And C code generally looks messier than C++ code since C++ can use classes, so I don't agree.
    Personally, I think that may just be poor formating on the part of the programmer.
    That's just my thought.
    Last edited by MikeyIckey; 01-15-2008 at 01:18 PM.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Maybe. It may just be may opinion, though, but generally when I see C code, I see it as messy whereas C++ code would be much better looking. It may just be me, but I like the idea of classes, virtual functions and polymorphism. I use it in almost every program and design.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by Elysia View Post
    Maybe. It may just be may opinion, though, but generally when I see C code, I see it as messy whereas C++ code would be much better looking. It may just be me, but I like the idea of classes, virtual functions and polymorphism. I use it in almost every program and design.
    Hmm, well it could be just a big misunderstanding on your part. It sounds like, according to you, because of the syntax alone C loses some merit. There are efforts made by most well-versed C programmers t break up their projects into tasks and make the language expressive. Perhaps more hobbyists simply haven't made the effort.

    And there are reasons to like C++. I love making classes and algorithms more flexible with templates if I've written something that works well. It's easier for me to do that in C++.

    But it seems that because C dedicates itself to one paradigm, like Java's object oriented approaches to everything, it will be criticized for limiting the programmer's options to procedural solutions. Which is just nonsense: it's all because OOP is popular right now. Python, I think, recently added lambda expressions to the language, but that doesn't mean that some Pythonic functional programming is going to make functional languages obsolete. There need to be languages dedicated to certain paradigms because on occassion they do work better than a one-size-fits-all howitzer.

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >And C code generally looks messier than C++ code since C++ can use classes
    I take it the code you read and work with doesn't use templates extensively? In my experience, C++ with templates has a tendency to look like cipher text. Of course, you can write messy code in any language, and "messy" is a subjective term.
    My best code is written with the delete key.

  7. #7
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Quote Originally Posted by Prelude View Post
    >And C code generally looks messier than C++ code since C++ can use classes
    I take it the code you read and work with doesn't use templates extensively? In my experience, C++ with templates has a tendency to look like cipher text. Of course, you can write messy code in any language, and "messy" is a subjective term.
    Add inheritance and pointers to templates and you have yourself the Da Vinci Code.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Sure, I use templates a lot. I love them, since they're flexible when you can pass whatever type you want. But even so, I write very clean and readable code so I don't really get confused when reading my own template code, even if it was a long while since last I worked or looked at it.
    Maybe I'm just too C++-aligned so that I automatically take distance from C, whether I like it or not
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by Elysia View Post
    But even so, I write very clean and readable code so I don't really get confused when reading my own template code
    The key word here is - own code

    When considering the laguage for the project one of the issues is possibility to read and understand someone else code. When this someone has gone for more than 10 years and it is no possibility to ask him why he did that or that.

    For this matter - C is more readable and simple than C++
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  10. #10
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by vart View Post
    When this someone has gone for more than 10 years and it is no possibility to ask him why he did that or that.
    This is a management issue. If the code is so great that you are still using it 10 years later, perhaps the company shouldnt have let that individual go. Sorry but I have no sympathy for egotistical managers that replace people just to avoid paying them more.

  11. #11
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by abachler View Post
    Sorry but I have no sympathy for egotistical managers that replace people just to avoid paying them more.
    What this has to do with the menagers?
    People ARE going to change place of work for some reason from time to time. 7-10 years at the same firm is a regular avarage values. After that people start looking for something new.

    When you hire a programmer you cannot be sure that he will stay at the project till the end of lifecycle of the project. So you from the beginning want to ensure that his code will be written in a such way so other programmers could support it and find bugs.

    The most part of the code lifecycle is in the phase of the maintanance, not writing. (If you write code one year and after one year of usage it goes away - you have a very big problem of planning your investments)
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by abachler View Post
    This is a management issue. If the code is so great that you are still using it 10 years later, perhaps the company shouldnt have let that individual go. Sorry but I have no sympathy for egotistical managers that replace people just to avoid paying them more.
    There are of course several other reasons why you can't ask someone about the code:
    1. Retired. (Ok, so you can probably ask the person in this case).
    2. Mutually agreed leave - e.g. the employee decided to move to another company, and no (reasonable) offer of higher could prevent this. Changing jobs may be of other reasons than pay. The new job may be in a different part of the country (or another country). Or the programmer may have always wanted to work in <industry of choice>.
    3. Incarcerated - the programmer may not have much access to the internet or even a telephone when he/she is in prison. Take Hans Reiser for example.
    4. Illness/death. These things happen.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by matsp View Post
    There are of course several other reasons why you can't ask someone about the code:
    1. Retired. (Ok, so you can probably ask the person in this case).
    2. Mutually agreed leave - e.g. the employee decided to move to another company, and no (reasonable) offer of higher could prevent this. Changing jobs may be of other reasons than pay. The new job may be in a different part of the country (or another country). Or the programmer may have always wanted to work in <industry of choice>.
    3. Incarcerated - the programmer may not have much access to the internet or even a telephone when he/she is in prison. Take Hans Reiser for example.
    4. Illness/death. These things happen.

    --
    Mats
    If 2 is amicable, most programmers would not have a problem with post departure support, at least I wouldnt.

    3 and 4 are fortunately rare occurances.

  14. #14
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by vart View Post
    For this matter - C is more readable and simple than C++
    I will challenge that. C code can be messy and even more error-prone than C++ and if done right, it does not cause a mess. A typical example is working with objects. When you need to do a deep copy of something, a copy constructor can be constructed for the object, but in C you need to do the copy manually or design a function to do it for you and call that. And if the function is a little poorer named and the code is a mess, then it won't be easy to know what it does.
    But in C++, if I see a = b, I know a will be equal to be then.

    It all depends on how you write it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #15
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    My argument isn't subjective. In C, an operator is a built-in operator. A variable declaration does nothing aside from reserving space. There isn't code that is suddenly executed when a function returns. And a function returns only at a return statement or the end of a function block.

    In C++, an operator may be overloaded. Constructors can have side effects in simple variable declarations. Destructors get executed when functions end. And functions may end at any time another function is called or one of a few select language constructs is used, due to exceptions.

    As such, C code is far easier to trace. That makes it easier to audit.

    C code is generally larger than C++ code. The fact that there is more of it may offset the ease of analysis. But that doesn't make my argument subjective.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

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