Why C Matters

This is a discussion on Why C Matters within the A Brief History of Cprogramming.com forums, part of the Community Boards category; >And C code generally looks messier than C++ code since C++ can use classes I take it the code you ...

  1. #106
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >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.

  2. #107
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,635
    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.

  3. #108
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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

  4. #109
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by CornedBee View Post
    As such, C code is far easier to trace. That makes it easier to audit.
    This is more a function of programming style than C++ itself. If the auditing process itself is done properly, then the class should be audited seperately from the main application, so that the class itself can be assumed to be safe. This is one of the points of classes, in that you can use modular code design so that portions of the application do not have to be redeveloped for a future application. Proper programming style should eliminate trivial classes, and thus ease the audit process. I realize that this isnt how most CS kiddies do it, but its the job of their supervisors to correct the bad habits they learned in college.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  5. #110
    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 12:18 PM.

  6. #111
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    Quote Originally Posted by abachler View Post
    Proper programming style should eliminate trivial classes, and thus ease the audit process.
    Sorry, I don't understand: What's a "trivial" class?
    There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary.

  7. #112
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    then the class should be audited seperately from the main application,
    But first - you need to locate the bug source. When in your big project some bug happens - no one will tell you "Hey, it is because your CTheGreateWindowManagerClass has a missing copy constructor!!"

    You have to trace the full program trying to understand when and why something is not working correctly...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  8. #113
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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++
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  9. #114
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    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.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  10. #115
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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)
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  11. #116
    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.

  12. #117
    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. #118
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    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.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  14. #119
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by abachler View Post
    If 2 is amicable, most programmers would not have a problem with post departure support, at least I wouldnt.
    You are ready to do 2 jobs for price of one? Why to leave?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  15. #120
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,635
    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.

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, 01: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21