Slashdot Mirror


C

Craig Maloney submitted this review of Addison-Wesley's entry in the tough field of books on C (book title: C), and pulls no punches in comparing it to others. He says it's slightly above average, but that "experienced programmers will likely pass on this book." Read the complete review below for his reasoning. C (Addison-Wesley Nitty Gritty Programming Series) author Klaus Schr�der pages 400 publisher Addison-Wesley rating 5.5 reviewer Craig Maloney ISBN 0-201-75878-4 summary A slightly better than average C book with some very good points, but poor delivery.

Lost in the Company of Giants

It's hard not to take a book like C and compare it to such acclaimed and trusted books as K&R, Expert C Programming, and other lesser known, but equally good tomes. Unfortunately C doesn't really compare with many of the other classic books covering the C language. For starters, the writing in this book isn't quite up to the same caliber as the other books. Part of the problem with this book is language. English does not appear to be the author's native language. There are sentences in this book that require a few glances to glean the full meaning. C is difficult enough to present without a language barrier introducing more problems. Another problem is organization. The ideas presented at the beginning of the book are muddled and disjointed, with multiple ideas introduced but not formally explained until later. Beginners will have a terrible time working through this book without becoming quickly confused, and experienced programmers will likely pass on this book in favor of the other well-known books.

Not All Bad

The book is not all bad, however. The examples in the book are plentiful and are based on tried-and-true examples found in books like K&R. There are some idioms that are used in the examples that will irk the more structured programmers (not using braces in certain areas being the biggest example), but most of the examples are pretty good. Also, the explanations of the more advanced topics are relatively good considering how confusing the more basic material is. Memory management is explained well, with clear diagrams (although the programs are a bit confusing without a careful eye).

So What's in it for Me?

Addison-Wesley is clearly marketing this book to the same crowd that purchases quick-learning books. Unfortunately beginners purchasing this book will quickly find themselves lost amid the confusing descriptions in this book. Those who manage to muddle through will find some tasty bits of information locked inside, but the work involved in getting there outweighs the rewards. Most programmers will probably want to leaf through a copy of this book before purchasing it to make sure they'll get the most out of it.

You can purchase C from Fatbrain. Want to see your own review here? Just read the book review guidelines, then use Slashdot's handy submission form.

299 comments

  1. Experienced programmers by Schapht · · Score: 0, Troll

    usually use man if my collegues and I are any example.

    1. Re:Experienced programmers by pizen · · Score: 2

      Experienced programmers usually use man if my collegues and I are any example.

      man is good as a specific reference but I think since you are already an experienced programmer you aren't looking for a book like this one.

    2. Re:Experienced programmers by Anonymous Coward · · Score: 0

      Appendix B in K&R thankyouverymuch!

    3. Re:Experienced programmers by Anonymous Coward · · Score: 0

      Actually the best books to learn C from are the ones written by Herbert Schildt.

      Hands down.

    4. Re:Experienced programmers by royalblue_tom · · Score: 1, Informative

      Mod this up!

      I always recommend Schildt's books. Clear descriptions, good example code. Perfect for a complete novice beginner.

      I learned from "C, The Complete Reference". The examples on how pointers work - excellent.

    5. Re:Experienced programmers by Anonymous Coward · · Score: 0
      usually use man if my collegues and I are any example.


      You should get out more. There are many highly capable heterosexual programmers.
    6. Re:Experienced programmers by Anonymous Coward · · Score: 0

      This is an in-joke among C and C++ hackers, but it's too dangerous not to debunk.

      Schildt's Annotated C Standard may a cheap way to get your hands on the text of the Standard, but for goodness' sake don't pay any attention to his annotations. This author is infamously incompetent and grossly negligent in checking his facts, and his books are full of severe misinformation and stupid mistakes.

  2. Aaah... by Anonymous Coward · · Score: 1, Insightful

    I love a review that isn't afraid to say "don't bother"

  3. Amazon Review by Anonymous Coward · · Score: 0, Interesting

    Here is the Amazon review of the book.
    At least it goes into more detail...come on slashdot!

  4. I was looking for a C book... by rbeattie · · Score: 2, Interesting

    I was just getting into C programming (specifically for a project on my Palm, but also in general using GCC like for my GBA and Linux)... And I was looking for a good C book the other day but wasn't sure (there are quite a few). I'm an experience programmer in Java and other languages, so I don't need a basic tutorial on how C works.

    What I need is a book that talks about how to use C in real projects. Gochyas, how to use the STL, etc. Also, I don't really feel like using C++ which seems like too much - even though it's more similar to Java - it looks like the vast majority of apps that I want to explore and use are written just in C...

    Any suggestions?

    -Russ

    --
    Me
    1. Re:I was looking for a C book... by QuantumG · · Score: 1, Troll

      Any suggestions?

      Yes, learn what STL is before you post to Slashdot about C (and then even go on to clarify that you dont want to use C++).

      --
      How we know is more important than what we know.
    2. Re:I was looking for a C book... by envelope · · Score: 2

      how to use the STL, etc

      STL is only available in C++, and is now known as the "C++ Standard Library". While not very OO, it is heavily dependent on templates, a feature not available in C.

      --

      appended to the end of comments you post, 120 chars
    3. Re:I was looking for a C book... by Anonymous Coward · · Score: 0

      How the fuck is this a "flamebait" posting? Sure, the guy made a mistake and thought the STL was part of C, but making himself look like a moron in front of his peers should be punishment enough.

      These terrorist acts of moderations will be corrected in meta-moderation.

    4. Re:I was looking for a C book... by ForsakenRegex · · Score: 1

      I'm an experience programmer in Java and other languages, so I don't need a basic tutorial on how C works.

      C is quite different from Java in that it does not
      garbage collect so you must allocate your memory
      by hand. It also makes heavy use of pointers, which
      is not done in Java. It is a must to learn C from the
      ground up, in my opinion, so that you can get a firm
      grasp of how to create and use the these lower level
      techniques appropriately.

      --
      "A man talking sense to himself is no madder than a man talking nonsense not to himself."
    5. Re:I was looking for a C book... by rbeattie · · Score: 1, Flamebait


      Hmmm. Got me.

      This is why I NEED A BOOK you asshole.

      Why don't you put your ego back in your pants and answer the question if you're the fucking expert.

      -Russ

      --
      Me
    6. Re:I was looking for a C book... by QuantumG · · Score: 2

      Seeing as he has attracted large amounts of flame already one would assume the moderators are trying to indicate that he is baiting for it. The alternative is that he is so lame as to not be worth discussing (which may also be true).

      --
      How we know is more important than what we know.
    7. Re:I was looking for a C book... by kin_korn_karn · · Score: 2

      "New C Primer Plus" published by The Waite Group. There is no better instructional C book.

    8. Re:I was looking for a C book... by jallen02 · · Score: 2

      Relax! My goodness. He was making a valid point. :-)

      STL (Standard Template Library) is a C++ feature.

      C does not have STL.

      And as far as books I would recommend "The C Programming Language", it is well accepted as "The" book for C. ISBN: 0131103628. The authors are Kernighan and Ritchie, so the book is often referred to as K&R C. They created the language (more or less).

      Combine K&R C with a good C reference manual and you should be able to do anything.

      For a reference manual I recommend "C a Reference Manual", ISBN: 0133262243 . It is written by Samuel P. Harbison with Guy L. Steele. Top notch minds IMO.

      Enjoy :)

      Jeremy

    9. Re:I was looking for a C book... by Anonymous Coward · · Score: 0

      C - Kernighan and Ritchie's book is the standard
      C++ - Stroustrup's Third Edition. Another book by the creator.

      Netiquette - http://www.albion.com/netiquette

    10. Re:I was looking for a C book... by Hard_Code · · Score: 2

      Not to get you all confused, but Digital Mars is developing a language called D (eleet C haxxors need not comment on languages named D) which is somewhat of a cross between C++ and Java in syntax, and is a migration path away from C/C++. I'm an "enterprise" Java programmer by day, but D really impresses me...it seems to be the right step to get *general application development* off the mistake-prone and complicated C/C++ languages.

      No it's not a practical suggestion (AFAIK the compiler is not fully complete and the syntax is still being refined), but it sure is interesting.

      Check it out: http://www.digitalmars.com/d/

      --

      It's 10 PM. Do you know if you're un-American?
    11. Re:I was looking for a C book... by bwalling · · Score: 2

      I actually prefer "A Book On C" (ISBN 0201183994) by Kelley and Pohl. Found it easier to pick up.

    12. Re:I was looking for a C book... by Anonymous Coward · · Score: 0

      So not only are you ignorant, you have every intention of being a beligerant jerk about it. Nice.

    13. Re:I was looking for a C book... by jallen02 · · Score: 1

      True, My very first introduction to programming was C for Dummies (don't laugh, this was almost 9 years ago). I learned a lot.

      If someone claims to already Java they can probably stomach K&R C :)

      Jeremy

    14. Re:I was looking for a C book... by geekoid · · Score: 2

      K&R Ansi C

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    15. Re:I was looking for a C book... by Bobby+Orr · · Score: 1

      Yeah...

      That attitude right there is what peeves me about Open Source. Supposedly, there are newsgroups and rank-and-file geeks that will help you out when you get stuck. But then when you ask an honest question, 18 know-it-alls just jump up and down on your head for being so stupid that you actually needed to ask for help.

      If that attitude does not change then I worry about the future viability of Open Source.

    16. Re:I was looking for a C book... by QuantumG · · Score: 1

      Sorry, no, this is what you get when you post to an online forum and type any old thing into the box thinking that it makes you a little bit smarter to mention a buzz word. Ohh.. I'll type in STL.. that's C right? This asshole needs to get himself to the library and read _any_ book on C.

      --
      How we know is more important than what we know.
    17. Re:I was looking for a C book... by Anonymous Coward · · Score: 0

      you just proved this guys post, dick

      looks like your mental state hasnt gone past 12 years old

    18. Re:I was looking for a C book... by belroth · · Score: 1
      If you're happy with zero padding or condescension go for K&R. I learnt C from K&R in 1985 and it is a great read. You may look at it and think it's a little on the thin side but it has all you need for the core languages. But it's not a tutorial.
      NB I haven't read the revised version (2nd ed?) but I'll probably get around to buying it sometime.

      Of course I haven't done any C programming for a while and there may be better books, but I know how good K&R is.

      --
      I hereby inform you that I have NOT been required to provide any decryption keys.
    19. Re:I was looking for a C book... by betis70 · · Score: 1

      I found C Primer Plus to be a great intro text as well. Much more engaging than Kelley and Pohl (they would put me to sleep).

      I made the switch from Java too and learning C was the best thing for me I think. I really learned a lot about how to use the features of Java to my advantage.

      --
      I forget...are we at war with Eurasia or East Asia?
    20. Re:I was looking for a C book... by Anonymous Coward · · Score: 0

      Wow.

      You know you could have moderated your stance -- you had a chance -- but instead you come across on BOTH posts as some no-social-skills know-it-all-jerk with slightly fascist political leanings.

      Whatever you do for a living, I'm sure it isn't something we can't live without. You should tele-commute from a cave.

      Get a LIFE!

    21. Re:I was looking for a C book... by Broccolist · · Score: 1

      Avoiding open source software because people on newsgroups are rude almost never happens, IMHO. Most people never post on newsgroups: in my CS classes, I wouldn't be surprised if half the students there didn't even know what a newsgroup is. Let's not even talk about average joes. I've used linux for years and have never used a newsgroup to answer a question, and I think that's the case for most people.

    22. Re:I was looking for a C book... by Vasily · · Score: 1

      >> It also makes heavy use of pointers which is not >> done in Java

      This is not exactly true. Java uses references, which are essentially pointers with a bit different syntax (due to the fact that Java is not C).

      Sorry to be pedantic, just wanted to point this out.

      -Vasily

    23. Re:I was looking for a C book... by QuantumG · · Score: 1

      That's right. Let it be heard by all: Fuck off till you get some skills.

      --
      How we know is more important than what we know.
    24. Re:I was looking for a C book... by J.+Random+Software · · Score: 1

      Most languages these days (Java, Perl, Python, Eiffel, Scheme, ML) use references instead of pointers. A reference is always null or bound to a valid and compatible object, and objects are preserved so long as any references exist. Casting and arithmetic can produce a pointer to a dead object, an object of an unexpected type, into the guts of an object, or even into storage reserved for the runtime (like the stack or heap), leaving your program facing unrecoverable, unpredictable errors. Even C++ has matured enough to encourage STL iterators instead of pointers (which have been described as "the GOTOs of data").

    25. Re:I was looking for a C book... by Einziger · · Score: 1

      I just got the second edition last night, and it cost about 40 bucks at borders. I believe you can order a used version for about 20 bucks. I've only read parts of it so far, but it seems a lot more insightful then sam's learn c in 24 hours :P

  5. Only two C books needed: by Ars-Fartsica · · Score: 3, Interesting

    K&R and "Advanced C Programming By Example" by John Perry.

    1. Re:Only two C books needed: by theCURE · · Score: 4, Funny

      Yeah because if you don't buy "Advanced C Programming By Example", then K&R might fall over on the shelf.

      --
      "i can never say no to anyone but you"
    2. Re:Only two C books needed: by kolding · · Score: 2

      Personally, the only C book necessary for a good, experienced programmer is C: A Reference Manual by Harbison and Steele. Best book on C out there. Skip K&R. It's awkward, poorly organized, and primarily interesting from a historical point of view.

    3. Re:Only two C books needed: by Anonymous Coward · · Score: 0

      Not only that, K&R is easy to find on the p2p networks.

    4. Re:Only two C books needed: by Alan · · Score: 1

      Took at look at the Perry book and it looked pretty good... complete and (from the exerpts at amazon.com) well written. I ordered it this morning, hope it's as good as it looks :)

      Thanks for the pointers, now I have something to keep my K&R upright on the shelf (other than Unix Network Programming by Stevens of course :)

    5. Re:Only two C books needed: by Anonymous Coward · · Score: 0

      Skip K&R? Ahahaha, right. After all, what do the authors know about C?

    6. Re:Only two C books needed: by gwernol · · Score: 2

      I guess it depends what you want. For example, K&R is a fantastically concise, lucid and authoratative reference to the C language. But it isn't something I would give to someone learning to program. I probably wouldn't give it to an experienced programmer who is coming to C as a second language, either. It would at least need a companion "introduction" book as well.

      When I'm writing C I always like to have K&R close by, but there are much better books to give to someone learning C.

      --
      Sailing over the event horizon
    7. Re:Only two C books needed: by royalblue_tom · · Score: 0

      They do know a lot about the language - but that does not mean they can explain it well to a complete novice.

      As has been noted elsewhere, their book is the best "reference" tome, but not the best t=place to start learning C.

    8. Re:Only two C books needed: by Titusdot+Groan · · Score: 1

      I would submit the expert 'C' programmer requires only one, 'C: A Reference Manual' by Samuel P. Harbison and Guy L. Steele.

      It's a guide to both ANSI and K&R C, it has cool useful tables and an excellent index.

      Not a good "learn C" book. To learn C go through K&R and then Software Tools by Plauger
      and Kernighan. When I say go through I mean read and implement the examples, play around with them.

      My wife and I have three copies of K&R (two 1st and second editions) and two copies of Harbison and Steele (2nd/4th) and the Harbison and Steele books are falling apart ...

    9. Re:Only two C books needed: by Teutates · · Score: 1

      It's awfully good of you to say there are much better books, but not list them.

      I'm glad I've learned from your post!

  6. Re:don't waste your time by geoswan · · Score: 4, Informative

    If you are reading this discussion because you are planning to learn C, know that not only is K&R's book a very fine book, but there is geek cachet in being able to say "I learned C from Kernighan and Ritchie".

  7. So what you're saying is... by InfoCynic · · Score: 1, Redundant

    All in all, you'd give the book a grade about... "C"? :)

    --

    "Recta non toleranda futuaris nisi irrisus ridebis"

    1. Re:So what you're saying is... by Cro+Magnon · · Score: 1

      Actually, since he said "a little above average" that would be a C+. But I guess that's the wrong language.

      --
      Slow down, cowboy! It has been 4 hours since you last posted. You must wait another few hours.
  8. You need to read more than you know by Ars-Fartsica · · Score: 2
    What I need is a book that talks about how to use C in real projects. Gochyas, how to use the STL, etc. Also, I don't really feel like using C++

    Not to sound arrogant, but this statement belies a need for substantial reading about C and C++, not casual reading.

  9. Rule of Thumb by pizen · · Score: 5, Interesting

    One of my CS profs (Georgia Tech people probably know who I'm referring to) gave the class advice on buying a C book: Flip through the book. If malloc isn't covered, put it back. If malloc is covered in an appendix, put it back. If the book contains the line cp=realloc(cp,n); then "burn it! Burn it right there in the store! Burn all of them!"

    1. Re:Rule of Thumb by Mr.+Neutron · · Score: 2
      If the book contains the line cp=realloc(cp,n); ...

      I didn't know Microsoft published a C book.

      ...or...

      Just buy more memory. Memory is cheap.

      --
      dinner: it's what's for beer
    2. Re:Rule of Thumb by megas · · Score: 4, Funny

      The professor is Professor Jim Greenlee, he has fabulous quotes such as
      you must code until your fingers are bloody stumps and you wake up with a keyboard imprint on the side of your face
      and they're collected at http://swiki.cc.gatech.edu:8080/cs2130/57

    3. Re:Rule of Thumb by po8 · · Score: 1

      If the book contains the line cp=realloc(cp,n); then "burn it! Burn it right there in the store! Burn all of them!"

      I don't get it. What does this guy have against realloc()? I must be missing something here. If he intends the cp to be of type char *, then he's right that ANSI libc wants void *, but it's hardly the end of the world; I certainly wouldn't choose my book on this basis.

    4. Re:Rule of Thumb by pizen · · Score: 3, Informative

      The problem is not with realloc. The problem is if realloc fails it returns null and you lose the pointer to memory that is cpand thus creates a memory leak. The better code would be:

      if((temp=realloc(cp,n))!=null)
      cp=temp;

    5. Re:Rule of Thumb by GPB · · Score: 1

      This is of course assuming that you are trying to
      recover from a memory allocation error. Generally
      if realloc fails, it means that your program isn't going to execute very far before it totally pukes anyway.

      I would personally treat it as a fatal error and just exit the program at that point.

    6. Re:Rule of Thumb by pizen · · Score: 2

      Generally
      if realloc fails, it means that your program isn't going to execute very far before it totally pukes anyway.


      Very true. If realloc failing you probably have bigger problems.

    7. Re:Rule of Thumb by bluGill · · Score: 2

      I would personally treat it as a fatal error and just exit the program

      True, but you missed an important step: write (attempt) all the users data to disk so once he solves the memory problem he can finish his work.

    8. Re:Rule of Thumb by frank_adrian314159 · · Score: 2
      The problem is not with realloc.

      The problem IS with realloc.

      Realloc can also move the memory block ensuring that any pointers to the interior of the original memory block will be FU'ed. Realloc is a great idea when the main thing you deal with is arrays of chars or ins or floats, but most programs these days use data structures that have slightly more linkage than that. Similarly, a straight bit-by-bit copy is almost never proper copy semantics for data structures. Realloc is, in general, a car wreck waiting to happen. The original poster was right.

      --
      That is all.
    9. Re:Rule of Thumb by Anonymous Coward · · Score: 0

      The danger is of course that if realloc fails, it returns null, and you've lost your pointer to cp. But this makes me wonder, just what the hell are you going to do if your program runs out of memory? Presumably, you alloc'd because you needed memory. What the hell are you gunno do now, tough guy?

      Anal, obsessive concern for details like this lead to code bloat. If your system were so damn mission critical, you'd not be using C in the first place. You'd instead use Ada or whateverthehell the defense contractor required.

    10. Re:Rule of Thumb by GPB · · Score: 1

      Assuming it is an application that needs this type of cleanup, then yes you should be careful about how you call realloc().

      However, if realloc() fails (and not because of bad input parameters), your write() call probably will fail too since the application most likely won't be able to allocate any new buffers to flush to disk. I agree, it would be good to at least try though (assuming the above is true).

      -B

    11. Re:Rule of Thumb by J.+Random+Software · · Score: 1

      write on a file descriptor never allocates userland memory. fwrite does (only if it's the first I/O on that stdio stream) unless you disable buffering using setvbuf, or you can set aside a few KB at startup if you don't want to deal with short writes.

    12. Re:Rule of Thumb by Frizzle+Fry · · Score: 1
      Anal, obsessive concern for details like this

      Checking return values of functions and system calls to see if they failed isn't anal, it's essential.
      --
      I'd rather be lucky than good.
    13. Re:Rule of Thumb by TheRain · · Score: 1

      Haha, that is really good advice. My first C book didn't cover malloc and so I was stuck programming some pretty limited apps, if you could even call them that. For those who don't know, in order to make any suitably powerful application in C you need to be able to use malloc and it's associated functions and understand them well. It's the key to creating multiple instances and varieties of any data type dynamically at runtime. With it comes the responsibilty of the knowledge of memory management..... like the knowledge of good and evil for those who have had fun with memory leaks :).

      --
      Please help! I'm stuck inside my virtual reality headset!
    14. Re:Rule of Thumb by psamuels · · Score: 2, Insightful
      This is of course assuming that you are trying to recover from a memory allocation error. Generally if realloc fails, it means that your program isn't going to execute very far before it totally pukes anyway.

      Many things which are excusable in production should not be tolerated in education. If the author of the C book you are looking at actually teaches you to leak memory ... burn it! You can't trust an author with such sloppy technique to teach good technique.

      I've seen "void main()" in some C books. Same thing. Obviously in some environments it doesn't matter, but bad habits are bad habits..

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
  10. Why are people still using a 30 year old language? by 91degrees · · Score: 0, Insightful

    C was written in the dark ages of second generation languages, when the concept of a programming language was quite a new idea. It was all well and good in its time, but it has been suprceded by any number of other languages. Quite simply C lacks any of the benefits of any other language.

    C has no bounded array support. This makes it inherently unsuitable for any security programming taks. The concepts of pointers, structures and unions is totally confused. The typeing can't decide whther its a stronly or losely typed language, so it is possible to cast a pointer to an int to a pointer to a float, and have a different result from casting an interger to a float.

    And the support for OO techniques is minimal to non-existent. No templates, no classes. No inheritence. Unlike C++, self modifying code is impossible in a non-platform specific manner. Unlike Perl and Haskell, it is next to impossible to extend an array.

    The #include mechanism is a joke. It requires that you type the name of a function at least 3 times, and then you have to deal with circular include paths, and multiple includes of the same file. Support for 32 bit architectures had to be added afterwards in the form of a long keyword.

    There is no equivalent of the object class. Can you believe that people are still programming in a language that doesn't have this useful conmcept? Most of the functionality in C is available in MSDOS batch scripts!

    It seems that Dennis Ritchie was so besotted with A and B that he forgot to take out the trash.

    If the computing industry had any sense, it would have switched to Java 10 years ago. Why hadn't it? Inertia!

  11. Above average? by Dephex+Twin · · Score: 4, Funny
    He says it's slightly above average

    Actually, "C" is about dead-on average, I'd say!

    mark
    --

    If you want to make an apple pie from scratch, you must first create the universe. -- Carl Sagan
    1. Re:Above average? by Anonymous Coward · · Score: 0

      not in an age of grade inflation

    2. Re:Above average? by ctar · · Score: 1
      Beer: the cause of, and solution to, all of life's problems. -- Homer Simpson


      Actually, the quote is: "To Alcohol! The cause of, and solution to all of life's problems..." From the Beer Baron episode...

    3. Re:Above average? by Dephex+Twin · · Score: 1

      Ah, that's right! Thanks for the correction. I'm gonna go with this compromise though:

      --

      If you want to make an apple pie from scratch, you must first create the universe. -- Carl Sagan
  12. Quick Learning by jeks · · Score: 5, Informative

    Learning C as your first language, without any prior computer experience may not be the most clever thing to do. Programming C efficiently, correctly and clearly is best achieved by first understanding computer architecture and programming concepts.

    A higher level language provides the abstractions necessary to accommodate "logical thinking" as opposed to a full understanding of say memory management and system I/O. Also, C is quite an orthogonal language in that it supports many awkward combinations of features and constructs. If you are not careful to make your source text clear and readable, debugging even your own code can be oh so cumbersome.

    Hence, perhaps reading a book such as "Computer Architecture: A quantitative Approach" by J. Hennessy and D. Paterson is a sensible step towards learning C for the beginner.

    1. Re:Quick Learning by yatest5 · · Score: 3, Interesting

      Learning C as your first language, without any prior computer experience may not be the most clever thing to do. Programming C efficiently, correctly and clearly is best achieved by first understanding computer architecture and programming concepts.

      A higher level language provides the abstractions necessary to accommodate "logical thinking" as opposed to a full understanding of say memory management and system I/O. Also, C is quite an orthogonal language in that it supports many awkward combinations of features and constructs. If you are not careful to make your source text clear and readable, debugging even your own code can be oh so cumbersome.


      I would totally disagree. Learning a higher-level language, like Java, first, will mean you miss out on learning all the basic stuff you would pick up in C which will stand you in good stead if you ever need to pick up other languages quickly.

      --
      • Mod parent up! [a] by Anonymous Coward (Score:5) Thurs, June 31, @13:37
    2. Re:Quick Learning by Uberminky · · Score: 5, Interesting

      I'd tend to agree with you on this one. I understand his points, and perhaps another language should be used at the very beginning. I started out on HyperTalk (the scripting language of HyperCard -- that was the coolest toy I had as a kid), learned Pascal (because that was what they taught)... and then FINALLY learned C. This may sound silly but it was a breath of fresh air to me. Everything made sense, everything could be explained in terms of this. The special cases were all gone. Sure, some things were more work, but I learned so much from C in that 10th grade class. I really feel it has helped me have an edge over many of my college peers. Heck, I would've loved to learn assembly language first. I'm having a blast with it now, in embedded systems. It's doing the same thing that C once did for me, simplifying it down to what's REALLY going on, deep down on the metal, so that I truly understand it. One architecture may go out of date, but you can learn just as much from PDP-11 assembly as you can from Lisp today, they're just in different fields. My fifteen cents.. ;)

      --

      The streets shall flow with the blood of the Guberminky.

    3. Re:Quick Learning by Paolomania · · Score: 1

      Learning C as your first language, without any prior computer experience may not be the most clever thing to do. Programming C efficiently, correctly and clearly is best achieved by first understanding computer architecture and programming concepts.

      And nothing lights a fire under your butt to understand computer architechture and programming concepts like tracking down a good old-fashioned seg fault.

    4. Re:Quick Learning by Kamel+Jockey · · Score: 1

      Learning C as your first language, without any prior computer experience may not be the most clever thing to do

      I can't agree with this. Many a programmer got their start with C. Besides, since every "new" language out there is an offshoot of C in one way or another (C++, Perl, PHP, and to a certain extent, Java), it makes sense to learn this language first as it will make those derivative languages far easier to understand.

      Live dangerously! Free everything you New and Delete everything you Malloc :)

      --
      In case of fire, do not use elevator. Use water!
    5. Re:Quick Learning by Bobby+Orr · · Score: 2, Interesting

      This is why I like Pascal so much. I really believe I saw a difference between students who learned Pascal as a first language vs. those who were dropped right into C/C++.

      At first, you hate the structure that it forces on you. After looking at some freshman's C++ code that is barely better than spaghetti BASIC, though, you begin to pine away for the Good Old Days of Pascal!

    6. Re:Quick Learning by DarkEdgeX · · Score: 2

      I dunno about that. I'm mostly self-taught, gleaning most of my knowledge from books and magazines, and while I didn't start out with C, I also didn't find a lack of knowledge about the inner workings of a PC to be a hindrance either.

      Not to start a flame-war about this language vs. that language, but I started out with QuickBasic 4.5 (or, since it's no longer for sale, QBasic, as it was shipped with MS Windows '9x/SE/ME). It got me started, and I used the very basic book 'QBasic by Example' to learn the ins and outs of how to write programs (I admit, for Basic, some of the code in this book is REALLY old and stale, but for those just starting to learn programming, it's a good start to have IMHO). From that I moved up to Visual Basic for DOS 1.0, the only real difference between it and QBasic was the addition of some reference material on the language (what functions/subroutines do what, how to call them, categorized and indexed for easy perusal).

      After that I moved up to Borland Pascal (IMHO a good cross of the best things of C and Basic), learning more about the hardware involved in a PC and dipping into assembly language for the first time (Borland Pascal (and for the curious, Borland Delphi today) make it easier to learn assembler since it includes a built-in assembler (basm) that doesn't invoke any seperate compilers (like some C compilers do when you use __asm for example-- if you're lacking an assembler, your __asm blocks won't compile (again, this depends on if the C compiler has an internal assembler, or uses an external one)). From that I learned C and ultimately started working on C++ (a subject I'm still expanding on today).

      I think it's more appropriate to start out with the highest level language you can find, get your feet wet with learning, then work your way down into the internals (this is probably also the best time to start to learn code optimization at the CPU level, for example). For someone jumping into PC programming that has no prior experience, a computer architecture book IMHO would be the wrong way to go.

      --
      All I know about Bush is I had a good job when Clinton was president.
    7. Re:Quick Learning by royalblue_tom · · Score: 0

      My college mates would probably disagree. We had to learn fortran. I was lucky to learn C over the summer. Then ... Data structures. Please program a doubly linked list. In fortran. And be able to parse it in both directions. Now a tree structure. Same rules. My tree parser took six lines in C. Doncha just luve recursion! Some guys took over a day to write their parser in fortran. And they were the grade A students ... Back on topic. The reference manual I bought (Schildt - C, the complete reference)had examples of data structures in C.

    8. Re:Quick Learning by Uberminky · · Score: 2
      I think it's more appropriate to start out with the highest level language you can find
      I feel the opposite. (I do appreciate all of your points, of course.) While I'd agree that trying to teach a non-programmer to write compact, efficient assembly language for a particular processor would be difficult to say the least, there is something that is, in my mind, absolutely wonderful about assembly, and to a certain degree C: simplicity. Java is great because it will do everything for you. But for a learning language it seems absolutely awful. It's such a hideously complex language. "Hello, World" takes a page of code! Everything is so abstracted away, and there is so much theory behind everything. Whereas with assembly language, C, and to a point Scheme, they all have very small fundamental parts. And once you understand these, you are good to go. You can learn more about the inner workings of them, but you know all you need to know with just some basic knowledge. As I see it, Python has this same problem. It's great in that it'll do everything for you. But nothing is fundamental. There are so many special cases it's ridiculous. So for a more advanced programmer it's wonderful. Just not for learning, IMHO.
      --

      The streets shall flow with the blood of the Guberminky.

    9. Re:Quick Learning by emodgod · · Score: 1

      Ah, I miss the PDP-11. My first assembly course used the PDP-11 and it was a joy to program... vectored interrupts, memory mapped I/O and general purpose registers. Those were the days.

    10. Re:Quick Learning by dstone · · Score: 2

      My tree parser took six lines in C. Doncha just luve recursion! Some guys took over a day to write their parser in fortran.

      If you want to learn more about recursive Fortran programming, check here or here.

      If your classmates were using a strictly conforming Fortran 77 compiler (like GNU), that might explain why their parsers were more difficult to write (ie, without recursion). Most 77 compilers (and anything recent) will let you write recursion just fine.

    11. Re:Quick Learning by Anonymous Coward · · Score: 0

      Whatever you do with that book, don't count on Schildt to have any idea what he's talking about.

    12. Re:Quick Learning by akuma(x86) · · Score: 1

      I tend to look at C as a shorthand for assembly code.

      I may be in the minority here, but I think that programming should be taught from the bottom up. First understand computer architecture which will explain assembly code. Then move onto C. Then move onto some higher level languages like Java. This will teach you to appreciate what's really going on in the machine and why the abstractions you are using exist.

    13. Re:Quick Learning by hgh · · Score: 1
      to teach a non-programmer...absolutely wonderful about assembly, and to a certain degree C

      I agree that a very high-level language is probably not the optimum way to teach programming, especially Java (a lot of the I/O and graphics stuff is way to complex for new programmers), but I don't think assembly or C is the way to go. Both languages require a relatively good understanding of computer architecture right from the beginning--there is no easing into it, especially in assembly.

      Despite what seems to be a general sentiment against it, I think C++ is a great way to start, especially now the STL. The C++ I/O libraries are pretty easy to use, and the STL gives you quite a bit of high-level functionality. Having strings makes the initial steps a lot easier to grasp. New programmers won't ask "well, why do I have to do all this?" when they want to do some basic string manipulation. They can ease into that question in time, while using the same language. You can also use C++ to learn about OO techniques. The first language I learned was C++ (the first programming book I found), and I found classes to be an intuitive way to model "things" in code. At first it's always concrete classes, but as you learn you start to code more abstract classes. The power and flexibility you have with C++ make it a great language to learn with.

      There is pretty good presentation (real video) featuring Bjarne Stroustrup that gives a better defence than I offer.

      hgh
    14. Re:Quick Learning by YogSothoth · · Score: 1

      [in java] "Hello, World" takes a page of code!

      Exhibit A

      #include <stdio.h>

      int main()
      {
      printf("Hello World\n");
      return(0);
      }

      Exhibit B

      public class hello
      {
      public static void main(String args[])
      {
      System.out.println("Hello World");
      }
      }

      Have you ever actually programmed in java?

      --
      there are two kinds of people in this world - those who divide people into two groups and those who don't
    15. Re:Quick Learning by Uberminky · · Score: 2
      Have you ever actually programmed in java?
      I have and do program in Java. In the future I'll try to remember that sarcasm is something that goes undetected on Slashdot. In fact, when I said that it takes "a page of code", I was (in jest, I might add) referring to the numerous complexities that are necessary to do otherwise simple things. For example, "System.out.println" compared to "printf". Or "public static final void" blah blah blah. Thank goodness I didn't say anything witty, that would have gone over like a lead balloon! ;-)
      --

      The streets shall flow with the blood of the Guberminky.

    16. Re:Quick Learning by ttfkam · · Score: 2
      For example, "System.out.println" compared to "printf".

      For *very* simple cases like string literals, yes. But what about when you start wanting to actually wanting to have dynamic values?

      const char *foo = "This is";
      const char *bar = "intuitive";
      printf( "%s %s?", foo, bar );

      Oh yeah, very intuitive... Compare with

      String foo = "This is";
      String bar = "intuitive";
      System.out.println( foo + " more " + bar );

      %s? What does 's' stand for? String? Why is the variable a char* then? That's the C version of a string? Sheesh! It's a good thing C isn't complex or anything...

      Of cource, there's always C++

      std::string foo = "this is";
      std::string bar = "intuitive";
      std::cout << foo << " also more " << bar;

      C coders really need to take a step back and look at their "simple" language and try to remember all of the arcana necessary to memorize to use it. And what about those string manipulation functions? strcmp, strcat, strstr, strtok... Why were they only six letters long and cryptic? Oh! Those limited-functionality computers from >30 years ago that had only a few K of memory and symbol tables couldn't handle long names. It's 2002 for god's sake! Long names don't matter in processing time and modern editors (if you can call emacs modern) can do variable and function name completion for you. It's not a time issue, it's not a performance issue, and it's not simpler.

      <bio>I code in C for a living along with a few other languages and I'm tired of constantly writing a new linked list structure or binary tree or any other data structure reminiscent of the wheel.</bio>
      --

      - I don't need to go outside, my CRT tan'll do me just fine.
    17. Re:Quick Learning by ttfkam · · Score: 2

      Iterative algorithms are usually faster anyway (and won't fill the stack on large inputs).

      Have a nice day. :)

      --

      - I don't need to go outside, my CRT tan'll do me just fine.
    18. Re:Quick Learning by Uberminky · · Score: 1

      It was a joke. I'll remember not to bother with those on Slashdot anymore.

      --

      The streets shall flow with the blood of the Guberminky.

  13. Nobody reads books anymore by Anonymous Coward · · Score: 0

    I had about 20 technology-related books in my collection, but after time I was realizing that I never used any of them anymore, and I find online resources to be much more valuable as well as much more current than books can ever be. There really needs to be a large push to get away from printed copies of books and possibly XML-formatted online versions.

    1. Re:Nobody reads books anymore by Anonymous Coward · · Score: 0

      You dribbling idiot. Just because you don't write any useful code, and have an instant on, 24/7 broadband connection, doesn't make reference books any less useful. Its a lot quicker to grab K&R, flick to the index & find the entry, than it is to start the browser, wait for the search page to load, wait for the search results to load...

  14. Why I wasn't using Java 10 years ago by brenfern · · Score: 2, Funny

    Because it only came out in 1995.

    Also, old does not necessarily mean bad; universities still teach LISP (out in 1958) and quite rightly so.

  15. Re:Why are people still using a 30 year old langua by pizen · · Score: 3, Insightful

    It seems that Dennis Ritchie was so besotted with A and B that he forgot to take out the trash.

    If the computing industry had any sense, it would have switched to Java 10 years ago. Why hadn't it? Inertia!


    Speaking of taking out the trash...I prefer to say when garbage collection occurs. I don't get that control with Java like I do with C.

  16. Re:don't waste your time by Anonymous Coward · · Score: 0

    That said, if you're looking for a less expensive book, I'm a big fan of the WROX series. The writers tend to have a good grasp of the english language (which many authors of programming books, sadly, don't), and use worthwhile examples. They're written for folks who don't know anything at all about programming, for the most part, and they're quite good. They also run about $35, or about half of what most of the "real" programming books cost.

    *shrug* I also found that most of the really good (read, popular) ones didn't explain things in a way I understood, but that could just be me. For instance, I find O'Reilly's books to be excellent as reference manuals, but terrible teachers.

  17. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 0

    Oh yes. Java. How useful a language. And gee, you can do anything in it. Perhaps I'll write the VM in Java... oh, wait.

    Maybe I'll write an efficient embedded OS in Java... oh, wait.

    OK, I'll write my device drivers in Java... oh, wait.

    Alrighty, then. I'll write my large, distributed database system in Java. Hey, that'll work! Too bad Visual Basic would cut my development time in half.

    Java is a fine language for SOME things. Just don't think that any serious OS or embedded-systems engineer would even consider it.

  18. here's a good beginner book on C by ForsakenRegex · · Score: 4, Informative

    The best book for C beginners I've ever come
    across is _A Book on C_, by Al Kelley,
    and Ira Pohl. I've recommended it to quite a
    few beginners and they've all said it was an
    easy and very informative read.

    --
    "A man talking sense to himself is no madder than a man talking nonsense not to himself."
    1. Re:here's a good beginner book on C by sabbo · · Score: 1

      Yes, this is a very nice book. one of the best features is the index (a very important piece of a good programming book).

    2. Re:here's a good beginner book on C by David+at+Eeyore · · Score: 1

      The Kelley & Pohl book is great. We had it set as the "intro to programming" text in CS at Deakin. I found its 'dissection' of programs very helpful..
      dt..

      --
      "Never underestimate the power of very stupid people in large groups" seen on someone's blog...
  19. In case you don't know what they're talking about by spaten-optimator · · Score: 1

    When people talk about "K&R" as a book, they're referring specifically to "The C Programming Language" by Kernighan and Ritchie (amazon), which is, without a doubt, the best reference available for C, and well worth the $40 its gonna cost ya.

    Mind you, its probably not the best book to learn C, but once you have the basics, this book will become your bible. I keep a softbound copy at home, and a nice hardback version I found at a used bookstore at work. Absolutely indispensible.

    --

    --
    Disclaimer: The above statement probably includes half-truths, because real truth is too complicated.
  20. Re:Does the world need more C books? by boltar · · Score: 0

    And OS kernel code
    And device drivers
    And games (speed)
    And HUGE amounts of legacy unix , vax & mainframe
    code

    C aint dead yet

  21. The Art of Writing by Alien54 · · Score: 3, Insightful
    The Art of writing and education is difficult in its own right, and not everyone knows how to put things together. Often you have to correctly analyse what concepts are fundamental to the understanding of more complex concept.

    As an example, I can recall a man who came into the store where I was working, and who asked me how much "virtual memory" cost.

    Besides trying not to laugh there was the problem mentioned above.

    The fundamental concepts missing were the concepts of "memory" and "virtual", along with a larger mental model to enable the average person to organise the concepts into something useful when dealing with computers. [The usual mental model I use for beginners is one of a computer = your information factory. Hard drives = warehouse, etc.]

    It is possible to arrange things inthe manner of " Gradus ad Parnassum " (graded steps)

    Without proper technique in this area, It is very easy to make a bloody mess of it. It is a skill in its own right, separate from knowledge of the area to be taught in the first place.

    --
    "It is a greater offense to steal men's labor, than their clothes"
  22. Tools of the trade. by DCram · · Score: 3, Interesting

    When you walk into HQ or Home Depot have you ever asked yourself why are there so many tools that do about the same job? There is always the right tool for the job. This is the same as it is in the programing world. I have heard people in this thread say why use C. Because if its the right tool to get the job done then use it. Don't get so caught up in one language, even a new one, that you make yourself a dino.

    A good C book is always a great find. I find myself going through kernel code or drivers or as of late the netsnmp code going hmmm.. I've seen this before but exactly what is going on.

    Refrence material is always good..no matter what.

    What I would love to see is a thread on what books most coders have found to be the most useful, what they have on there shelves.

    I love reading the reviews that say the book is good but not really worth my time.

    --
    If I were only smart enough to accomplish the things I dream about.. Or maybe too dumb to care.
    1. Re:Tools of the trade. by ciscoeng · · Score: 2, Informative

      Three of the best I've read for programming in C (that are happily ear-marked, bent, and written-in):

      "C Traps and Pitfalls", Andrew Koenig, AT&T, 1988
      - A bit dated in places, but still covers the very fundamental gotchas that a lot of programmers forget/don't know

      "Expert C Programming: Deep C Secrets", Peter Van Der Linden, SunSoft Press, 1994
      - Fun to read, especially how the simple linguistics of a language can cause major ($20 mil)
      bugs

      "The C Programming Language, second ed", Kernighan and Ritchie, AT&T, 1988
      - They developed C, 'nuff said.

  23. Re:Why are people still using a 30 year old langua by gte910h · · Score: 1

    It seems that Dennis Ritchie was so besotted with A and B...
    Actually, the precursor to B was BCPL, not A. B is C's precursor.

    --
    Want to see every step I took to start my company? http://www.rowdylabs.com/blogs/pitchtothegods
  24. Re:Why are people still using a 30 year old langua by qurob · · Score: 1


    C has no bounded array support. This makes it inherently unsuitable for any security programming taks.


    *cough* *NIX is written in C *cough*

    If the computing industry had any sense, it would have switched to Java 10 years ago. Why hadn't it? Inertia!

    Let's just think of how fast x86 Java VM's were 10 years ago. In 1992 I had just purchased a Macintosh Quadra (25mhz), Windows NT wouldn't come out for a year later, and Windows 3.1 and OS/2 2.0 had just came out. The Sparc 10 had just been released. Pentiums were not coming out for a whole 'nother year.

    The HotJava browser didn't come out until...1994?

  25. Most importantly, does it cover coding style? by Anonymous Coward · · Score: 1, Insightful

    A C book that doesn't cover a proper coding style is pretty useless.

    Yeah, you might bang out a quick "itch-scratcher" without using a strict coding style, but not a solid piece of software that can be maintained.

    1. Re:Most importantly, does it cover coding style? by Anonymous Coward · · Score: 0

      Sorry, but coding style is upto the author (Or the lead developer, or the company you work for), and do not need to be set in stone in a book. Every C book I have read has always basically said "Here are some styles you might try, but feel free to choose one that you are comfortable with" How would you like for the GNU style to be adopted as The Standard? My blood runs cold at the very idea...

  26. Re:don't waste your time by avandesande · · Score: 0

    The think that sux about rox books is the lifeless faces of the authors that stare back at you. There is a guy at work here who actually put a cover on the book so he doesn't have to see them. I'd rather see a yak or something than those jerks!

    --
    love is just extroverted narcissism
  27. Re:Why are people still using a 30 year old langua by pizen · · Score: 2

    C has no bounded array support. This makes it inherently unsuitable for any security programming taks.

    *cough* *NIX is written in C *cough*


    Yes, but wasn't Windows also originally written in C? I guess it's the programmers and not the language that determine the security.

  28. Lost in a sea of C's! by nexusone · · Score: 1

    Are not all other programming languages that are popular today, just extensions of the 'C' base? If you look back 'C' it is the first cross platform language, take JAVA which is really 'C' with an OOP style and a few syntax changes.

    A quote from the reviewer: "C is difficult enough to present without a language barrier introducing more problems." I think he is confusing 'C' with 'C++'; which can be a very confusing implication of 'C'.

    I think a first time 'C' user would be well advised to get one of the 'K&R' programming books. I found it very helpful when I was learning 'C'.

    --
    Wise men speak because they have something to say, Fools because they have to say something!!!!
    1. Re:Lost in a sea of C's! by CodeMonkey555 · · Score: 1
      I believe it is an over simplification of programming languages to say that all popular languages (including Java) are based on C. There are really three types of programming languages (beyond assembly): functional, procedural, and object-oriented. Functional is basically LISP, procedural include C, Pascal, Fortran, Cobol, while object oriented contains C++, Java, and Delphi. C++, Java, and Delphi are object-oriented, but they are based on procedural languages for their basis. Everyone says that Java is really object-oriented, but there's still that damn little "static void main".

      Eventually, there will be a real object-oriented language that is a paradigm shift away from oop-built-on-procedural. Most of us will prolly just complain because MS will develop it and it will be a point-and-click system. :)

    2. Re:Lost in a sea of C's! by Anonymous Coward · · Score: 1, Informative

      Lisp covers functional, procedural and OO. That's what makes it such a joy the program in, because it doesn't tie you down to one paradigm.

      Haskell is a better example of a functional language.

  29. Re:I was looking for a C book... (more pedantry) by IainHere · · Score: 1

    [cough] STL is part of the standard library. They are not the same thing. [/cough]

  30. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 2, Funny

    From the jargon file:
    C is a language that combines all the elegance and power of assembly language with all the readability and maintainability of assembly language.

  31. Kernigan Ritchie by maitas · · Score: 1

    I don't know why they even write C books. There has always been and will only be one programming book "the C programming languaje" by Kernigan Ritchie. Not only a superb C book, simply put, the best programming book ever. Now I'm looking for a similar book on JAVA, but all the books I found are tooooooo big. So far, the best JAVA book I read is "Just JAVA and beyond" by Peter Van Der Linden. Chapter 2 is all you need to know about OOP.

    1. Re:Kernigan Ritchie by jrennie · · Score: 1

      Have you read Java in a Nutshell (O'Reilly)? It's compact and serves as a nice reference.

      Jason

    2. Re:Kernigan Ritchie by rjha94 · · Score: 1

      Try Ken Arnold and James Gosling's
      the Java programming Language
      Addison-wesley: ISBN: 81-7808-148-2
      Real Nice Book

      --
      No .sig
    3. Re:Kernigan Ritchie by Anonymous Coward · · Score: 0

      That's Kernighan and Ritchie. Two authors.

    4. Re:Kernigan Ritchie by iangoldby · · Score: 1

      I'm still looking for a book on C++ written in an equivalent style to K&R. The example programs in all the C++ books I've ever seen are just too darned long. K&R manage to illustrate the essential points of C in snippets mostly of around 3 lines. No fluff and completely general. I'm not interested in examples that implement a whole program, because I can put the pieces together myself thankyou, once I understand what those pieces are. I don't want to have to spend more time trying to understand what a program does than I do understanding how it's expressed in the language when I'm learning a new language.

      I think terse examples are far more educational than long 'real-world' examples. K&R's one-liner implementation of strcpy() is a perfect example. Once you understand why it works, you understand for loops, pointers, null-terminated strings, expression evaluation, post-increment, etc...

  32. Re:Why are people still using a 30 year old langua by Ubi_NL · · Score: 2

    I'm confused now

    I guess I'll wait for "D" to come out

    --

    If an experiment works, something has gone wrong.
  33. Re:Why are people still using a 30 year old langua by pizen · · Score: 4, Informative

    So what you're saying is that you prefer a language that has NO MEMORY MANAGEMENT to one that does?

    A good programmer can manage memory without the help of the runtime environment. There's a certain pride in being able to program with no memory leaks.

  34. Re:Why are people still using a 30 year old langua by 91degrees · · Score: 1

    *cough* *NIX is written in C *cough*


    Good. Now choose an OS with no known buffer overflow exploits.

  35. Agreed. by glrotate · · Score: 1

    Quite a supplement to K&R.

  36. Re:Why are people still using a 30 year old langua by ForsakenRegex · · Score: 1

    I don't necessarily disagree that the memory
    management complications in C cause problems,
    but, I believe that OpenBSD has no known
    buffer overflow exploits, at least in the core
    OS.

    --
    "A man talking sense to himself is no madder than a man talking nonsense not to himself."
  37. C vs. C++ by SPaReK · · Score: 1, Offtopic

    Though its been a while since I have programmed in C, I think it is worth noting, for new users, that learning C, is a lot easier than trying to learn C++. I tried to learn C++, but as a newbie programmer, it got very confusing. I don't remember why, but C was just a lot easier to learn. I never went on to study C++ (perl got really interesting). But, my advice for anybody wanting to go into programming, take a look at C first.

    1. Re:C vs. C++ by MagPulse · · Score: 1

      C is a much simpler language, and if you stay away from complicated OO concepts, programming in C is pretty straightforward. Some like to say C is just "pointers, structs, and functions".

      C++ has a ton of features, and you aren't going to use all of them, they're just there to support whichever programming paradigm you decide to use it for.

      Stroustrup suggests jumping right in to C++ though if you're not interested in C. The difference is you have to stay alert for which parts of the language you're learning, and not get stuck in the features. I suggest the Deitel&Deitel book; it lets you start coding right away with the important parts of the language.

    2. Re:C vs. C++ by Anonymous Coward · · Score: 0

      I learned Java, then C++ and C.

      C++ for me is a much cleaner and easier to learn language. Just take a look at printf() and its shortcomings in C and how easy is cout >>.

      No comparison. For beginners I recommend C++, C has a limited use by now.

      I recommend C++ over Java to learn coding.

    3. Re:C vs. C++ by Anonymous+Brave+Guy · · Score: 2
      Just take a look at printf() and its shortcomings in C and how easy is cout >>.

      It's easy to jump to that conclusion if you've been reading lots of C++ books, and certainly the IOStreams library has advantages over C's approach. However, it is itself fundamentally flawed for many applications, simply because it makes it nigh-on impossible to write code that's well-behaved in multiple (human-spoken) languages.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    4. Re:C vs. C++ by Anonymous Coward · · Score: 0

      If I want to do formatted output of built-in types, I much prefer printf(). For I/O on user-defined types I much prefer iostreams. Right tool for the job.

  38. The only C book I ever recommend to all by GCU+Friendly+Fire · · Score: 1
    C Traps and Pitfalls
    Andrew Koenig

    Still the best after thirteen years.

    1. Re:The only C book I ever recommend to all by Anonymous Coward · · Score: 0

      I like a book that is up to date on
      ANSI C 2000.

  39. Just for fun... C is a hoax? by spaten-optimator · · Score: 5, Funny

    An old april-fools joke, this snippet will give you a good chuckle at the expense of C:

    "We stopped when we got a clean compile on the following syntax:

    for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+*u++/8)% 2))P("| "+(*u/4)%2);

    To think that modern programmers would try to use a language that allowed such a statement was beyond our comprehension!"

    Also check out shooting yourself in the foot in various programming languages.

    --

    --
    Disclaimer: The above statement probably includes half-truths, because real truth is too complicated.
    1. Re:Just for fun... C is a hoax? by majcher · · Score: 2

      And people complain about Perl being unreadable...

    2. Re:Just for fun... C is a hoax? by Anonymous Coward · · Score: 0

      Scarely enough, I can read & understand a good deal of that code block you have there...I still don't get the for(e=C; though, that would indicate an infinite loop to me.

    3. Re:Just for fun... C is a hoax? by Anonymous Coward · · Score: 0


      why?

      the second thing in the for(;;) is the test (i.e. for(x=1;x10;x++). the test is evaluated every iteration, and in this case it's e-- - since e-- will evalutate to true as nonzero, and false once it hits zero, it'll stop eventually.

    4. Re:Just for fun... C is a hoax? by Alhex · · Score: 0

      You can write bad code in any language. Besides, that line is not too bad. The only thing making it unreadable is the spacing.

    5. Re:Just for fun... C is a hoax? by Monkey+Troll · · Score: 1
      The only thing making it unreadable is the spacing. Well, I find that I always have to look twice at the idiom:
      printf("_" + n % 2)
      There are much, much clearer ways to print a "_" if a number is even, and nothing if a number is odd. Spacing has nothing to do with it.
    6. Re:Just for fun... C is a hoax? by Anonymous Coward · · Score: 0

      The inherited surplus of terse operators from C is half the reason Perl is write-only; Perl's stunningly awful reference syntax is the other half.

    7. Re:Just for fun... C is a hoax? by J.+Random+Software · · Score: 1

      (0 == n % 2 && putchar('_'))

      is still an expression but it replaces a wasted call to printf and a search for the end of a string with a macro that usually just copies a character and bumps a pointer within a (FILE*).

    8. Re:Just for fun... C is a hoax? by Monkey+Troll · · Score: 1
      sure... or if you want to avoid that strange 0 == replacement for !, you could use
      (n % 2 || putchar('_'))
    9. Re:Just for fun... C is a hoax? by J.+Random+Software · · Score: 1

      I suppose distinguishing false from 0 is a Java-ism I picked up. Writing if(integer) feels a little misleading to me now, though if(pointer) doesn't. Putting the constant on the left (so you don't use = instead of ==) is just one of those style guide recommendations that looks good in job interviews.

  40. Re:don't waste your time by elefantstn · · Score: 5, Funny

    Not only that, but pulling a dog-eared, bookmarked, highlighted copy of K&R off your bookshelf has the panty-removing power of playing your band's seven inches or flashing the keys to your '57 Corvette.

    --
    If it ain't broke, you need more software.
  41. Reference material by ciole · · Score: 1

    A good C reference would be one thing, however, this sounds like more of an introductory general C comprehension book, and in the vein of those that have gone before. What use do coders have for this? If we know C we need a more specialized discussion, and if we don't, there are canonical texts to refer to (K&R).

    OTOH, it warms my heart to see interest in C. it's really my favorite language, and while i don't mind that most employers want me to write OO code, i would hate for C to fade from the earth (especially in favor of C#).

  42. I'm totally underqualified to comment but... by QuantumG · · Score: 1

    For a person who doesn't program in C and never learnt C++ (because Perl, of all things, distracted him) I would suggest that your comment is worth about nothing.

    --
    How we know is more important than what we know.
  43. Language Barrier by keep_it_simple_stupi · · Score: 1
    English does not appear to be the author's native language. There are sentences in this book that require a few glances to glean the full meaning.
    So how is this any different from the college C courses available? :)
  44. Re:don't waste your time by ProlificSage · · Score: 1
    ...if you're looking for a less expensive book, I'm a big fan of the WROX series

    Having learned VB and Java first, and having read many books on computer architecture, I would suggest that the only book you need to learn C is K&R. The Wrox books have too much fluff for someone who just wants to get down to what's important.

    In addition to K&R, The C Standard Library by Plauger is also quite useful. If you're not the type of programmer that can pick up language basics in a few days with a good reference, then, by all means, get something with less substance and more hand-holding. I also managed to find a book on nothing but pointers in C, but, unfortunately, do not have it close by to pass on the title. It's somewhat old, and may be out of print, anyway.

    --
    Real software engineers regret the existence of COBOL, FORTRAN and BASIC.
  45. Re:Why are people still using a 30 year old langua by blackwings · · Score: 5, Informative

    Reasons to still use C (at least sometimes):

    1. It is the native language to most operating systems API (*nix, MS-*).

    2. It is the language most third party librarys and code is written in.

    3. It is the language a lot of old code is written in.

    4. Interfacing other languages with libraries or APIs written for C is never as easy as the documentation says it is and issues may slow down development time significantly.

    5. It is the only widely used standardized all purpose language that is available to all platforms.

    C++ - is hardly standardized (most compilers still does not come close to the ANSI-C++ standard).
    ADA - Is not widely used.(unfortunately)
    Java - Is not an all purpose language.

    6. It is a very elegeant and consistent language (unlike C++).

  46. Re:Typical Slashdot asshole reply.. by Anonymous Coward · · Score: 0

    always the need to:

    1. Be a smartass.
    2. Show off your expertise, while
    3. Not helping anyone.

  47. Not to sound arrogant, but I will by Anonymous Coward · · Score: 0

    always the need to:

    1. Be a smartass.
    2. Show off your expertise (self-perceived), while
    3. Not helping anyone.

    1. Re:Not to sound arrogant, but I will by Anonymous Coward · · Score: 0

      more like if you can't see the connection between C, C++ and the STL, a posting on slashdot isn't going to help you.

  48. low standard by avdi · · Score: 1

    Isn't that an awfully low standard? Kind of like saying a rule of thumb for picking a book on baking bread is to put it back if it doesn't mention flour. Well of course; but that leaves room for plenty of bad books to make the cut. A C book would have to be trully awful not to mention malloc. In fact, I have a hard time believing such a book exists. A more accurate rule would be "If the book doesn't mention malloc, put it back - you picked up a C++ book by mistake, idiot".

    --

    --
    CPAN rules. - Guido van Rossum
    1. Re:low standard by nakaduct · · Score: 2
      A C book would have to be truly awful not to mention malloc. In fact, I have a hard time believing such a book exists.
      --
      Kernighan & Ritchie, The C Programming Language (Prentice-Hall, 1978). ISBN 0-13-110163-3.
      I have a copy on my desk and if there's any mention of malloc it's well-hidden. It does present an implementation of a general-purpose storage allocator [alloc(), pp.175], which you could presumably adapt into a malloc-workalike.

      cheers,
      mike
    2. Re:low standard by Anonymous Coward · · Score: 0

      Vintage 1978 K&R predates StandardC by many years, and without any disrespect to the authors, it can fairly be described as an awful book to use if you want to write modern code.

  49. Re:Why are people still using a 30 year old langua by jaoswald · · Score: 1

    If you're "man enough" to write a program with no memory leaks, you've probably also written a program that can't function as part of a long-lived dynamic system.

    That is, if your program is simple enough that memory allocation can be handled manually, then it probably isn't complicated enough to do anything interesting. Where by "interesting" I mean, can do things with data that are too complicated to get a human brain around without making a mistake---such as running queries against complicated databases for flexible, user-configurable front-end applications.

    Why is it that most large projects start out with defining a memory-management subsystem? Why not use a language that has a robust memory management capability built in, and save your presumably valuable time?

  50. Re:Why are people still using a 30 year old langua by binaryDigit · · Score: 1

    A good programmer can manage memory without the help of the runtime environment

    I agree, however, one must consider that we live in the real world. A world in which a very small percentage of programmers are "good programmer"s. That's why there is a need for, um, simpler languages. One for the "common" programmer. Sort of a VolksLanguage, or VPL.

  51. Re:Why are people still using a 30 year old langua by jaoswald · · Score: 4, Insightful

    What makes you think dynamic memory management in C is efficent?

    Just because "malloc" and "free" each fit on one line of code doesn't mean they are fast or efficient. In particular, if your memory arena gets seriously fragmented, the performance of these routines can get worse and worse over time.

    As opposed to a genuine generational garbage collector, for which the performance stays relatively consistent.

  52. Re:Why are people still using a 30 year old langua by binaryDigit · · Score: 1

    I guess it's the programmers and not the language that determine the security

    DING DING DING DING DING. Give the man a monkey!

  53. Excellent book on C Socket Programming by Kamel+Jockey · · Score: 1

    While we're on the subject of good books, one that should definitly be looked at if you are getting started with any kind of socket programming in C is The Pocket Guide to TCP/IP Sockets: C Version. It is short (~100 or so pages), to the point(lots of examples which actually work with linux and cygwin if you dare), and most importantly, CHEAP ($15)

    Go check it out here

    --
    In case of fire, do not use elevator. Use water!
  54. Re:don't waste your time by Anonymous Coward · · Score: 0

    No kidding. The PHP book is the worst, though. Check out the guy on the left in the second row.

  55. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 0

    BWAHAHAHAHAHA!

    Funny guy.

  56. Harbison and Steele... by dpbsmith · · Score: 1

    Harbison and Steele's "C: A Reference Manual" is the book I use. I like it a lot. This is "real-world" C, full of guidance on things which are in the standard but frequently implemented correctly (so you can avoid them if you want to be conservative), or things which are not in the standard but a frequently implemented in a certain "traditional" way.

    It is valuable because it does NOT have the "one-vendor" myopia that is so common elsewhere.

    IMHO, it is better organized and better written than K&R. And, unlike K&R, which describes C the way K&R would like it to be, Harbison and Steele describe C the way it is.

  57. re: Does the world need more C books by binaryDigit · · Score: 1

    ..... the only book on C is K&R.

    However, there seem to be many gaps in the C++ book market.


    Of course this brings up an interesting point. One of the things I LOVE about C is that it's a straight forward language. Sure you can create some hairy messes, but once you understand some basic concepts, most of the language is accessable to you. It's also _MUCH_ easier to write code without side effects, which is a bane to programming. With little effort, one can look at some C code and have a reasonable idea about what's going on. With C++, a line of code is never what it seems, and you usually have to track down a dozen h or cpp files to figure out what the heck is going on. C++ is the best damn employment insurance ever created for programmers ;)

    With C, you can get away with a couple of good reference books. With C++, you can never have enough reference books.

  58. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 0
    *cough* *NIX is written in C *cough*

    Which is exactly his point.

  59. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 0

    Gee, and it took only 30 years to get to that point.

  60. Re:In case you don't know what they're talking abo by KowShak · · Score: 1

    Is there a good C++ equivilent to _the_ K&R C book??

  61. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 0

    A good programmer wouldn't waste his time doing it himself. Reinventing the wheel is nothing to be proud of.

  62. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 0

    Don't forget to mention that C is missing important features of C++, like templates and many others I have no time to explain here.

  63. (OT) So what are the standard libraries in C++? by yerricde · · Score: 1

    STL is part of the standard library. They are not the same thing.

    Other than STL, iostream, and the C library, what libraries does the C++ standard define?

    --
    Will I retire or break 10K?
    1. Re:(OT) So what are the standard libraries in C++? by Anonymous+Brave+Guy · · Score: 2

      Actually, strictly speaking the STL isn't even part of the C++ standard library. The STL (as designed by Alex Stepanov) is an entity in its own right, and the C++ standard library borrows very heavily from its ideas and maps them onto C++. The result of that mapping is commonly known as the STL among the C++ community, but the use of the term is not strictly accurate. There, that should settle the pedantry. ;-)

      To answer your question more completely, the ISO C++ standard defines the following sections relating to the library.

      • Language support library
      • Diagnostics library
      • General utilities library
      • Strings library
      • Localisation library
      • Containers library
      • Iterators library
      • Algorithms library
      • Numerics library
      • Input/output library

      Additionally, of course, there is what is inherited from C.

      That covers the STL-based stuff (containers, iterators, algorithms), string manipulation, i18n issues, iostreams and such, the numeric classes (complex numbers, etc.), and various basic tools to make programming C++ easier.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  64. Re:Why are people still using a 30 year old langua by extrasolar · · Score: 2
    A good programmer can manage memory without the help of the runtime environment. There's a certain pride in being able to program with no memory leaks.

    Then where have all the good programmers gone? Or have they all moved over to Lisp?

  65. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 0

    I like OpenBSD, most secure OS hands down.
    But there are still bugs in there, the guys keep fixing them...track the OpenBSD developer mailing list.

  66. (OT) You were that lame once too. by yerricde · · Score: 1

    The alternative is that he is so lame as to not be worth discussing (which may also be true).

    At one time, we were all that lame. Be nice.

    --
    Will I retire or break 10K?
  67. Expert C programming by getafix · · Score: 1

    Started off with K&R, and 5 years later picked up Expert C Programming, and Koenigs C book. I found all of them to be valuable, even though similar information was found in the last two books. A different perspective, and additional examples of folly are always welcome.

  68. Little C question :) by Anonymous Coward · · Score: 0

    Allow me to make a little C question.

    I have a function that receives an array and analises it.

    Then it returns another array with some information in each "position", like

    info[0] = width
    info[1] = heigth

    The function woule be called as:

    result = analise (myarray);

    A couple of cicles generate the "info" array, and then I need that thing returned.

    AFAIK in C it isn't possible to return an array from a function, so, how do I do this thing?

    Thanks.

    1. Re:Little C question :) by nodrip · · Score: 1

      dude, buy a c book. Of course you can return
      an array.

      int * analyse( int result[], int size )
      {
      int i;
      int * data;

      data = malloc( sizeof( int ) * size );

      for( i = 0; i < size; i++ )
      {
      data[i] = i;
      }
      return data;
      }

      int main(int argc, char* argv[])
      {
      int i;
      int data[2];
      int * result;

      result = analyse ( data, 2 );

      for ( i = 0; i < 2; i++ )
      printf( "%d\n", result[i] );

      free( result );

      return 0;
      }

      --


      -- "The best way to predict the future is to invent it."
    2. Re:Little C question :) by Bhisma · · Score: 1

      Return a pointer to a malloc'd array or pass in a pointer to the array you want returned.

    3. Re:Little C question :) by Anonymous Coward · · Score: 0
      Not quite that.
      I want it to return an array created inside, not one passed by parameter.

      I'm trying to achieve something as what follows.
      • #define SIZE 2

        analyse (int info[]){

        for (i=0;i<SIZE; i++){
        if (something){
        result[0]+= 1;
        }
        else {
        result[1]+=1;
        }
        }

        }

        int main (){

        int info[2];
        int result;

        info[0] = 1;
        info[1] = 2;

        result = analyse (info);

        }

      Ideas?
    4. Re:Little C question :) by Anonymous Coward · · Score: 0
      The analyse function would have:
      • return result;
    5. Re:Little C question :) by Artik+Vodka · · Score: 1
      Another way to do that is pass in a point to an array you declare in the main function - or whatever function you use to call that. First, you either pass the size in the analyze function or you declare it with #define or something.
      • #define MAXSIZE 10

        void analyse_this ( int *info, int *result ) {
        int i;

        for ( i = 0; i < MAXSIZE; i++ ) {

        if ( your shabang ) {
        result[0] = info[i];
        }

        }

        int main () {

        int i;
        int info[MAXSIZE];
        int result[2];

        (do some loop, fill the array or something)
        info[i] = i;
        (end loop)

        analyse_this ( info, result );

        (do something with the result array)

        return 1;

        }

      A for or while loops can be used to load data into the info array, then just use the analyse_this function to generate something into the result array, ...
    6. Re:Little C question :) by J.+Random+Software · · Score: 1

      If the array you want to return is fixed size, put it in a struct. When C was defined, arrays were automatically passed and returned by pointer like FORTRAN (copying an array at every function call seemed extravagant in the 1970s) but you couldn't pass or return a struct at all, just a pointer to one. When they got around to allowing structs to be passed and returned, they specified that it was by value--every member gets copied, even arrays.

      If the array is variable size, C can't tell you how large a memory allocation is, so you're going to have to roll your own representation (element count or end pointer) or migrate to C++ and use std::vector<>.

  69. Re:Why are people still using a 30 year old langua by OneFix · · Score: 1

    6. It is a very elegeant and consistent language (unlike C++).

    This is why I decided to use ANSI-C rather than C++ when I took my C classes in college. The professor gave us a choice ... and most ppl took C++ because they were told it would be so easy (if I recall correctly, I was the only one to prefer ANSI-C) :)

    I was using AmigaOS and AIX at the time and knew that the only standard across platforms tended to be ANSI-C.

    Incidentally, the book I used was The Joy of C ... it is one of the most well written books on C that I have found. And it's now out of print ... I thought about buying another copy (I sold mine back because I was a broke college student)

  70. Best C programing book available by erichbear · · Score: 2, Insightful
    The best C book that I have ever read would be:
    • UNIX Systems Programming for SVR4
    Not only does it addtess such cryptic issues as UNIX terminals and processes in great detail, but it also covers much of the C standard library. A must have for any serious C programmer.
  71. Re:In case you don't know what they're talking abo by Anonymous Coward · · Score: 0

    Be careful that the hardback copy you have is a Second Edition copy, and not the original, non-ANSI C, First Edition.

  72. Re:Why are people still using a 30 year old langua by Snowfox · · Score: 2
    If you're "man enough" to write a program with no memory leaks, you've probably also written a program that can't function as part of a long-lived dynamic system.
    Or you had enough common sense to implement a good debugging mode.

    Storing the __LINE__ and __FILE__ compiler variables along with each allocation in your debug build, and being able to print the current state of all allocations is a no brainer. And it points to exactly the point of leakage. For a more complex project, add tags so you can check for memory of a given type left between points in your code.

    You should get the idea, and adapting this to suit your memory usage mode should be pretty straightforward.

    A decent programmer should be able to add this to his project and find all leaks between reading this and going home tonight. RAM leaks are a sign of a bad programmer, or a programmer too lazy to create good tools for himself.

    Quit blaming your tools. Get off your ass and make the ones you're missing.

  73. The wrong idea by The+MoMo+King · · Score: 0

    I'm sitting here reading all these posts and I can't help but realize that a lot of people are missing the point. Every language has its time and place. The average Joe trying to live the hacker ethic has little hope of using the more advanced languages correctly. It takes time, education and gasp ... skill to program. You may not have an A game to code but don't bash a language because you don't have the skill to accurately choose the correct language for a problem or understand the paradigm it was created from. C++ is not the best language for all problems ... sometimes the solution to a problem dictates simplicity which C, or some other language, can provide. The same thing can be said about books. Each has its time and place and attended audience ... don't bash if it wasn't meant for you.

  74. Re:Why are people still using a 30 year old langua by Snowfox · · Score: 3, Insightful
    Why are people still using a 30 year old language?
    Why are people ignoring 30 years of code maturity?
  75. Ada Anyone by shaunbaker · · Score: 2, Insightful

    I am really curious as to know peoples opinions on Ada. It is highly verbose and slightly annoying but overall the system seems well thought out. Class-wide programming seems straightforward enough and the compiler seems to catch just about everything that would cause cryptic C++ bugs. It takes a little longer because quick and dirty hacks aren't allowed, but overall it seems very good.

    1. Re:Ada Anyone by Cro+Magnon · · Score: 1

      I've never actually used it. I know it's very strongly typed, which I think is good. Judging by an old book I have on Ada83, it is quite verbose, but probably no worse than COBOL (yes, I'm an old guy).

      --
      Slow down, cowboy! It has been 4 hours since you last posted. You must wait another few hours.
  76. Re:Why are people still using a 30 year old langua by geekoid · · Score: 2

    But that would mean they would have to understand what there doing! All they underlying hardware is just a pain, and the certianly don't want to be bothered with learning how code works on a low level!
    sorry.
    Its just so good to here someone post about good programming habits instaed of what language makes it easier to code without regard to what there doing.
    the question is: are you in the business to write code, or to write programs?

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  77. van der Linden's Expert C Programming: Deep C Secr by Anonymous Coward · · Score: 0


    If you like van der Linden as an author [in real life, he seems to be something of a cocktail party marxist], you should try his Expert C Programming: Deep C Secrets. It's a great read for the intermediate to advanced C programmer; I once used it as the basis for a course I taught in intermediate C.

  78. Where to look for good C and C++ book reviews by Anonymous+Brave+Guy · · Score: 3, Informative

    You might try the Association of C and C++ Users web site.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  79. Not quite that low... by Mr.+Neutron · · Score: 2
    ...Kind of like saying a rule of thumb for picking a book on baking bread is to put it back if it doesn't mention flour...

    malloc() is not *part* of C, merely a POSIX system call. Granted, it's about the most essential of system calls, but if your book is about C, and C alone, you can leave malloc() out. I guess.

    --
    dinner: it's what's for beer
    1. Re:Not quite that low... by sinserve · · Score: 1

      Malloc is part of the C standard library. MS DOS had a malloc, and it wasn't POSIX compliant.
      malloc is a function, and not a system call.

      --

    2. Re:Not quite that low... by Alhex · · Score: 1, Informative

      Actually malloc is part of the ANSI C standard...and K&R C for that matter.

    3. Re:Not quite that low... by seebs · · Score: 2

      It's only in POSIX because POSIX inherits the entire standard C library, which is a "part of the language", in that the specification for C itself describes the standard library.

      (Of course, malloc is free to not exist in freestanding environments, but they don't necessarily start execution at main(), and there's no requirement that they support any form at all of input or output.)

      --
      My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
    4. Re:Not quite that low... by Mr.+Neutron · · Score: 2

      I guess this is one of those examples of how C and UNIX kinda blur together. malloc() IS a system call. You are making a system request. It's also part of the standard C library. It's also a stardard part of the UNIX/POSIX specification. When you get down to that level where UNIX specification begins and C specification ends really doesn't matter. The two are one and the same.

      --
      dinner: it's what's for beer
    5. Re:Not quite that low... by Anthony · · Score: 1

      malloc() IS a system call. You are making a system request. It's also part of the standard C library.

      Actually malloc is a library as you pointed out. For examply, on my Solaris and linux boxen, the underlying system call is brk.
      --
      Slashdot: Where nerds gather to pool their ignorance
    6. Re:Not quite that low... by J.+Random+Software · · Score: 1

      I don't know of any system on which malloc is a direct syscall. OS memory management tends to be slow and inefficient (being tied into virtual memory commitment and resource limits), so any decent standard library implementation gets large chunks of memory using the appropriate syscall (Unix sbrk, Win32 GlobalAlloc, or whatever) and doles out smaller chunks for use by malloc and ::operator new (and then coalesces them in free and ::operator delete).

  80. Learning C before C++? by Anonymous+Brave+Guy · · Score: 2

    Interesting. However, many experts do disagree with you, including Bjarne Stroustrup and Marshall Cline.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  81. K&R == succinct by drjzzz · · Score: 1

    Agreed! Nearly all the other programming books are huge. To think, K&R introduced the whole language in just over 200 pages with clear examples and a lot of white space. It also makes a great reference book, maybe because it's so easy to find the important things.

    --
    to err is human, to forgive is divine, to forget is... umm...
  82. Get rid of C! by Tom7 · · Score: 5, Insightful

    Goodness, this is an awfully empty review. Except for the comment about the author's native language (which humorously is followed up by an awkward if not ungrammatical sentence from the reviewer), this whole review could be applied to practically any programming book! What sets this book apart? If nothing, then why review it?

    Anyway, the real reason I clicked on this article is because I just love a C debate. Since there's hardly anything to talk about with regard to the review, let's get to it!

    Here's what I say: outside of the low-level systems crowd, C should die. We should *not* be teaching beginning programmers C or C++. C should not be the "default language" of computer programming.

    Today, efficiency is no longer the primary concern about software. It has been ousted by robustness and ease/cost of development (modularity and reuse). C is awful for robustness (the language lets you "get away" with anything you want, though those things are seldom what you want in application software), and even worse for modularity and re-use. Modern languages, or even quasi-modern languages like Java, are far better than C for robustness and ease of development. They even win on some points which are typically seen as less important than efficiency: portability, elegance, etc.

    Finally, the efficiency of high-level languages is comparable (though not as good as) C. Compiler technology is improving somewhat, as well. But since developing and debugging take less time, you have more time to optimize your program (if necessary), so I am not convinced that this is really a big deal. Yet, even if I need to concede the efficiency issue, I still believe modern languages beat C overall.

    I'll be glad to argue about that stuff, but today I have a different point to make. C is also holding back the progress of other computer fields. Let me give you an example. My friend is working on compilers that compile high-level languages (to them, C is a high-level language) down to circuits. Here, discovering data parallelism in the code is probably the most difficult problem. Of course, the same issues arise in compiling to architectures like the IA-64 or even P4, where in order to get best execution speed, the compiler needs to figure out what instructions can be executed in parallel.

    When they compile C, they need to look for common idioms (certain patterns of for-loop use), then analyze them to extract the parallel algorithm. For instance, this simple C loop adds k to every integer in an array a of size s:

    for (int i = 0; i < s; i++) {
    a[i] += k;
    }

    The idea is that the compiler should be able to produce a circuit that does all of the adding in parallel, on silicon. Since you all probably grew up on C, this seems like the totally natural way to write that code. In fact, it is short and it is straightforward. Unfortunately, it is less straightforward to a compiler. The compiler needs to prove to itself that the for loop can be parallelized -- what if the programmer changed k or a or i in the loop body? The C code actually says to run each loop iteration sequentially.

    Of course, compiler writers have gotten pretty good at catching this particular idiom, but when the code gets more complicated (especially when the compiler needs to do alias analysis), it is not so good.

    The chief problem here is that the programmer is unable to effectively communicate his parallel algorithm to the compiler. The programmer takes something in his mind "add k to all elements in the list", sequentializes it for C "for (int i = 0 ...", and then the compiler has to *undo* this sequentialization to produce the parallel code. In the process of translating, some information is always lost.

    Now look how this code would be written in SML (a so-called "modern language"):

    Array.modify (fn x => x + k) a

    (fn x => x + k) is a function expression (SML lets you pass around functions), and Array.modify simply applies the function to every element in the array. Here, the compiler can very easily tell that my operation is parallel, because I used Array.modify! The code is also a bit shorter, and I also think that this code is a lot clearer. That's subjective, of course. BUT, I hope you will agree that for this example, the SML code is closer to what the programmer means, and easier for the compiler to understand.

    Anyway, perhaps some of you will say that this particular issue is not a problem, or that it is already solved (I would like to hear the solution!). I merely mean to propose an example of a theme I have been observing over the past few years in many areas of computer science. Computer programming is about communicationg with the compiler or machine in such a way that it is easy for the human to create code, and easy for the machine to understand it. C was never particularly easy for a human to create (though we have become accustomed to it), and though it was once easy for a compiler to understand, this is becomming less and less true. When the language is neither optimal for humans nor optimal for compilers, doesn't that mean that something needs as change?

    1. Re:Get rid of C! by nodrip · · Score: 1

      You want this kind of functionality you can find it in a number of languages that exists today. Those languages - their runtime libs and their vm's, are built with c.

      Mother nature didn't throw the gene out once she had the human being.

      Builders always use metal beams to build sky scrapers.

      Developers build prototype based language systems using c.

      If you throw out the basic building blocks, inovation and invention stall - you always have to have 'the basics' on which everything else is built upon.

      The problem you mention is not with the c language, it is in the fact that you are trying to adapt a linear system to a parallel one. You need to start with two parallel systems and go from their instead.

      --


      -- "The best way to predict the future is to invent it."
    2. Re:Get rid of C! by Anonymous Coward · · Score: 0

      isn't that chicken your raping gettin raw!!!!!!!!!

    3. Re:Get rid of C! by Jimmy_B · · Score: 3, Insightful

      Your post is definitely a troll, but since you immediately admit and justify it ("Since there's hardly anything to talk about with regard to the review, let's get to it!") I will respond anyways.

      I'll start my argument with an anecdote. There is one particular C++ program I was writing, not atypical, and not a particularly difficult problem computationally. I was programming on my AMD Athlon 1400MHz, a fast computer by any reasonable standards, and found that it wasn't running as fast as I'd like. I profiled it, and found the functions to blame were operator overloads (called very frequently) on a class coord, which looked something like this:
      friend coord operator+ (coord a, coord b) { return coord(a.x+b.x, a.y+b.y); }
      Spot the error on that line. Now, ask someone who's never programmed in C before to spot the error. Give up? It's the passing by value, which prevents the compiler from inlining the function; the correct way to write that function is:
      friend coord& operator+ (const coord& a, const coord& b) { return coord(a.x+b.x, a.y+b.y); }
      If not for my experience programming in C, I never would've realized that.

      It is my observation that people who are taught to ignore C, and start immediately with an object-oriented language such as C++, <B>never</B> learn low-level concepts such as inlining or pointers, and never learn to truly understand what it is that they're writing. I say that the best way to learn and properly appreciate the "right way" of doing something is to first do it the *wrong way*, in a project that doesn't matter for anything. I have debugged pointer spaghetti, written code with dozens of meaninglessly named global variables with no comments, written procedural code, and had I not done these things, I wouldn't know why it is important to name variables intelligently, to use object orientation, or to use pointers carefully. You tell someone to comment their code, and you get lines line this:
      a=b; // Copy b into a
      The only reason the comment is there is because they were taught to always comment their code, to comment every line, etc. On the other hand, someone who's dealt with uncommented code before would put useful comments where they need to be.

      I agree with you that C should not be used in production code where it can be avoided (that is, areas other than systems and embedded programming). However, I strongly believe that people should always learn and master C before learning higher-level languages. If the only reason you use classes is because you were taught that that's how to write clean code, then you're not using them correctly. On the other hand, if you're using classes because you wrote in C up to the point where you encountered a problem that required inheritance or polymorphism, then you're using the feature for the right reasons.

      Your example, by the way, in which a loop that increments elements of an array is parralelized in hardware, is actually simpler than you think. The compiler first performs loop unrolling (a very, very old idea), then analyzes the code blocks to see that they don't work with the same data, and parralelizes them. Your particular example implies that the only real way to solve parralelism is to define parralel functions and human-solve them; this clearly violates the distinction between language and library, and doesn't really help. Besides, in your case example of compiling high-level code into hardware, I could come up with far more examples where object orientation hurts rather than helps. OO hides all of the overhead, promoting huge bloat which, while not a problem in software, is fatal in hardware.

    4. Re:Get rid of C! by jacobm · · Score: 2

      I'm not sure what you're arguing ... that C deserves a gold star? Sure. C deserves a gold star. (Though I'm not happy with C's happy-go-lucky attitude towards program safety.) That C is the most relevant important skill for programmers to have today? No. Definitely not.

      Unlike buildings, we shouldn't start from scratch every time we write a new program; we ought to build up and only program the new stuff that's specific to our program and nothing else. C is terrible at that, which is why God gave us Lisp and the wisdom to use it. I have yet to hear anyone make a cogent argument as to why Lisp is inferior to C for general-purpose application coding (not systems-level stuff; e.g., why Excel, Word, Notepad, the calculator, Netscape, etc ought to be coded in C or C++ instead of CL or Scheme). And it's not like I haven't asked.

      --
      -jacob
    5. Re:Get rid of C! by Tom7 · · Score: 2

      > Your post is definitely a troll

      Just because a post is provocative doesn't mean it's a troll. A troll post usually says something that the author doesn't really believe, just to get people fired up. I actually believe this, and I think it's worthwhile for the C-centric slashdot crowd to think about it.

      > It's the passing by value, which prevents the
      > compiler from inlining the function; the correct
      > way to write that function is:

      I disagree that this "prevents" the compiler from inlining. It might force the compiler to call the copy constructor (if it can't deduce that it has no effect), but there's no reason it "prevents" inlining. It may be that the compiler just doesn't inline it, sure.

      I don't really see why programming in C gives you any more clue about when a C++ compiler will perform inlining, since that's basically an arbitrary choice made by the compiler.

      That said, I agree that there is definitely a place for learning C in a well-rounded programmer's education. I've taught programming enough to know that... Programmers that don't know low-level programming won't be able to do low-level optimizations. BUT, I think the emphasis that slashdot folks place on low-level efficiency is highly overrated. I feel that C actually encourages programming styles that are BAD for programming in general; I think it can do more harm than good for a programmer to learn "efficient" programming in C. So while it's a good idea for people to learn it, I don't necessarily think that it's smart to learn C *before* you learn other high-level languages.

      > Your example, by the way, in which a loop that
      > increments elements of an array is parralelized
      > in hardware, is actually simpler than you
      > think.

      Well, if you say so. People actually do their PhD theses on this kind of thing. In conversations with my friend, who actually works on these kinds of compilers, it seems that the problem is actually difficult. For instance, if there is almost any kind of memory write in the loop, then you need to do alias analysis to verify that it is not breaking the parallelism.

      > Your particular example implies that the only
      > real way to solve parralelism is to define
      > parralel functions and human-solve them; this
      > clearly violates the distinction between
      > language and library, and doesn't really help

      Well, let me reiterate my actual point: Instead of always working with C, languages should be adapted to the task at hand. C gives you an abstract view of a sequential machine -- and this is hardly how computers actually operate today (especially when compiling to hardware!) Having a language (even if like C) with a parallel array modification construct like SML's would make programs *easier* to write, and compilers better.
      I don't know what you mean by violating the distinction between language and library. Why should parallelism be a library??

      For the record, I wasn't encouraging Object Oriented programming, which I think is a bit of a sham -- but that's a different argument entirely. ;)

    6. Re:Get rid of C! by Tom7 · · Score: 1

      > You want this kind of functionality you can find
      > it in a number of languages that exists today.
      > Those languages - their runtime libs and their
      > vm's, are built with c.

      That's not necessarily true. SML compilers, for instance, usually compile directly to machine code. Sometimes we use C to interface to the operating system, but that's simply because the operating system is C-centric.

      Regardless, hacking up virtual machines and garbage collectors sort of is C's domain. Kernel hacking, also C. (Though I wish we had a microkernel so that things like the filesystems, higher levels of the network stack, etc. could be written in modern languages.) Embedded systems, C. But most programmers don't write these things, they write applications -- and those are definitely not what C is good at.

      Maybe you are simply taking issue with the title of my post, "Get rid of C!". I didn't really mean that. I mean, stop using C for application programming.

    7. Re:Get rid of C! by Discoflamingo13 · · Score: 1

      Amen! Here at school, we start people out on Scheme, so they can concentrate on high-level design and not worry about low-level stuff. Their next language is usually Java, for a look at the object-oriented paradigm (and most everybody has some issue to raise with that, but meh). Then, in Programming Languages, everyone has to learn at least some Prolog (declarative/constructive programming), C (low-level procedural programming) and SML (high-level functional programming with monster type safety).

      I find it odd that more people don't realize that ANY programming language can be interpreted (like Perl, Python, Java, Ruby, SML, Scheme, etc.) or (machine) compiled (C/++, Python, SML again, Fortran, Scheme again, etc.) if it's designed correctly. If people want speed, why don't they bootstrap high-level languages from an interpreter to native code? Not that Scheme is the best example of a high-level langauge, but the difference between Scheme code from ChezScheme and normal C++ is not night and day.

      In short, it's the paradigm of programming that should fit your problem. Once people learn (if they ever learn) that you should not try to write self-modifying C code (use Scheme for that), predicate evaluations in C++ (use Prolog, SML, or Mercury for that) or operating systems in Scheme (for crying out loud, use C), then the software engineering landscape will continue to be a bleak landscape of hammering with screwdrivers.

    8. Re:Get rid of C! by Tom7 · · Score: 1


      Good call.

      > If people want speed, why don't they bootstrap
      > high-level languages from an interpreter to native
      > code?

      Well, high-level languages have the ability to be fast in native code to varying degrees. For instance, lisp and scheme can both be quite fast, though dynamic tag checking and dynamic scope (in lisp) hurt performance. SML wins for speed here because it's statically typed, but still pays for array bounds checks (usually, but we're working on it ;)) in order to guarantee safety. But of course you lose the ability to do certain tricks you can do in a highly dynamic language like scheme. Java suffers from a bloated class system and some language misdesign, so there's a lot of overhead no matter the implementation. Languages like perl where you can build string representations of program syntax and interpret them on the fly essentially need the compiler built into the language to have fast native code capabilities.

      Of course, as you mention, none of them are so much slower than C that they wouldn't be appropriate for applications. And as I said in my post, when development is that much easier, that leaves more time for optimization. =)

    9. Re:Get rid of C! by Anonymous Coward · · Score: 1, Informative
      Spot the error on that line. Now, ask someone who's never programmed in C before to spot the error. Give up?


      @_@

      The error is obvious, and I've never programmed in C before, only C++. Tell me, what part of your C experience told you that references were the way to go here?

      The answer to your problem is obviously to discard C, and up the standard of how C++ is taught. For all your enlightenment of how bad C is (we should use OO, etc) there are fifty bearded unix guys who will claim C to be the ultimate programming language, useful for all and any problem.

      And the ultimate answer is to discard C++ and C both as learning languages and go for something more modern. C++ can then be used when it's absolutely needed, and we software designers can actually get some real evolution going for our toolset.
    10. Re:Get rid of C! by e-Motion · · Score: 1

      I'll start my argument with an anecdote. There is one particular C++ program I was writing, not atypical, and not a particularly difficult problem computationally. I was programming on my AMD Athlon 1400MHz, a fast computer by any reasonable standards, and found that it wasn't running as fast as I'd like. I profiled it, and found the functions to blame were operator overloads (called very frequently) on a class coord, which looked something like this:
      friend coord operator+ (coord a, coord b) { return coord(a.x+b.x, a.y+b.y); }
      Spot the error on that line. Now, ask someone who's never programmed in C before to spot the error. Give up? It's the passing by value, which prevents the compiler from inlining the function; the correct way to write that function is:
      friend coord& operator+ (const coord& a, const coord& b) { return coord(a.x+b.x, a.y+b.y); }
      If not for my experience programming in C, I never would've realized that.


      As someone else pointed out, the function should return by value.

      Your experience with C has nothing to do with your ability to eliminate the bottleneck. C doesn't even have references. Not only that, but any C++ programmer worth a damn understands what copy constructors are, and what passing by reference means. If he can't understand the difference between the two functions above, and why one is more likely to be more efficient than the other, then he doesn't understand _C++_, not C.

  83. Their entry? by LinuxInDallas · · Score: 1

    Addison Wesley, as most of us know, already has a vast array of great programming books. This is definitely not their entry in the field.

    Since everyone else has done it, I thought I'd put in my recommendation for one of my all-time favorites: Expert C Programming, Deep C Secrets. This book is awesome and full of insight. Just look for tha orange book in the programming section of your favorite book store.

  84. Pointers on C by Spudnuts · · Score: 1

    Ken Reek's Pointers on C is a very complete reference. I strongly recommend it if something more full than K&R is desired (as do many of the amazon.com reviewers).

  85. Informative? More like impudent by Ars-Fartsica · · Score: 2
    A good programmer can manage memory without the help of the runtime environment.

    We're not talking about "hello world". Try coding up 50k lines of C and see how well your memory management skills stack up.

  86. Does Greenlee have his Ph.D. yet ? by DaveWhite99 · · Score: 1

    When I was at GA Tech ('93-'98), Greenlee only had a Master's degree and was an "instructor" rather than a flavor of "Professor" such as "Assistant Professor", "Associate Professor", "Full Professor", or "Professor Emeritus". Does he have a Ph.D. yet ? I actually liked his sadistic teaching style, even though most people didn't. Though, nothing about Greenlee is suprising. He tends to have pretty extreme viewpoints.

    --
    Biodiesel : domestic, renewable, clean, and in the fuel tank of my bone stock 2002 New Beetle TDI
    1. Re:Does Greenlee have his Ph.D. yet ? by pizen · · Score: 2

      Does he have a Ph.D. yet ?

      He's still just an instructor (AFAIK). I just refer to him as a prof because it's easier than explaining the real title. I also enjoy his teaching style but I'm glad he's the only one. I don't think I could deal with a full load of Greenlee-like profs.

  87. on C the language by nodrip · · Score: 1
    I can't believe somebody could ask the question - why learn an old language like c? That's the craziest question i've ever heard. That 'old' language is the language all of the current 'newer' languages are implemented in. At the base level, it all comes down to c code. If you don't understand the basic building blocks, how can you possibly expect to master a higher level language built with them? C#, C++, Java, Perl, Python, Lua, Javascript or whatever.. the libraries that compile and run those languages are written in c.

    Also, IMHO c is one of the most elegant and powerful languages around. Written correctly, it is one of cleanest languages that exists.

    On other languages:
    - Java and C++ are disgusting to look at and overly complex.
    - Python is a hack.
    - Perl is ugly.

    You have to really step up into the higher level prototype based languages like Lua before you get to a point where the code is elegant again. But before you program in any of these 'next generation' languages, you really have to understand what their built with.

    my 2 cents.

    --


    -- "The best way to predict the future is to invent it."
    1. Re:on C the language by AYEq · · Score: 1

      I will agree with you about C elegance and simplicity, but must you slam other languages in order for you to feel justified in your love of 'C'.


      Java and C++ are disgusting to look at and overly complex

      agreed



      Python is a hack

      please explain, IMHO python was one of the first of the next gen languages that didin't feel like a horrible hack, but I am interested in why you think that.


      Perl is ugly


      True, but I have not seen a language that is as instantly usefull. A ten line perl script can do thnigs that a hundren line C program cannot. (and if you are careful, you can read it in the morning)

    2. Re:on C the language by nodrip · · Score: 1
      but must you slam other languages in order for you to feel justified in your love of 'C'.

      your right, i thought of this when i posted it. bad idea.

      Python is a hack

      The api's aren't put together in a clean and organized fashion.. actually I should have said - Python's libraries are a hack.

      Perl is ugly

      ahh, a difference of opinion i guess...

      --


      -- "The best way to predict the future is to invent it."
  88. Re: Does the world need more C books by Tom7 · · Score: 2

    > It's also _MUCH_ easier to write code without
    > side effects, which is a bane to programming.

    Hmm. I agree with what you say about C++ -- I think the language is awful -- and I agree that side effects are a bane to programming, but I definitely don't agree that C is good for side-effectless (ie, functional) programming.

    For instance, implementing something as simple as binary trees without side-effects almost *requires* a garbage collector in order to get reasonable performance. (Maybe you could do something tricky with lazy reference counting, I dunno.)

    In fact, since memory allocation is a side effect, even string manipulation in C is hard to pull off without side-effects. (How do you return a variable-sized string from a function?) On the contrary, C++ has value-semantics strings that make this possible.

    And since C lacks first class functions (really, I should say it lacks nested functions, since you can actually pass around pointers), lots of the functional idioms just don't work.

    What did you mean by this?

  89. Re:don't waste your time by steve802 · · Score: 1

    One of the first things I do when I start a new semester teaching C (yes, there are still classes out there in this fine language), I always bring my dog-eared K&R. Then I say "we're not using this book - it is a classic and I refer to is often, but it is too dense." Then I heft my copy of "C Programming" by KN King, soon to be published in its 2nd Edition, and say "this book may be all you'll ever need." I'll check out the new "C" book, but I suspect it won't outside King's.

  90. "code until your fingers are bloody stumps" by hyacinthus · · Score: 2

    Sheesh. Certainly Prof. Greenlee is not the only exponent of this idea, but still, I find myself wondering in how many of his students he confirmed the fraudulent idea that you do your best work in marathon sessions, on your fifth cup of coffee, after three hours' sleep.

    hyacinthus.

  91. Which compilers do not come close to ANSI-C++ ? by DaveWhite99 · · Score: 1

    All of the latest versions of the C++ compilers I have used lately are either ANSI-C++ compliant or come damn close to being compliant : Diab (for embedded systems) GNU g++ Sun CC Visual C++ (gasp !) What most compilers got hung up on, in my experience, was templates. Now that STL has been out a while, it's forced any decent compiler to come up to spec..

    --
    Biodiesel : domestic, renewable, clean, and in the fuel tank of my bone stock 2002 New Beetle TDI
    1. Re:Which compilers do not come close to ANSI-C++ ? by Anonymous+Brave+Guy · · Score: 2

      There is currently no 100% standard-compliant C++ compiler available, AFAIK. Comeau's is close, but even that has been suffering with getting export to work properly, and Comeau C++ seems to be several months ahead of the field in standards compliance.

      You're right that most of the problems are with template support, but to the serious C++ programmer, those are serious problems.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:Which compilers do not come close to ANSI-C++ ? by Anonymous Coward · · Score: 0

      The STL is really fucked up in g++. Caused me much trouble, it isn't fun to reimplement stuff which should be there already.

  92. Re:In case you don't know what they're talking abo by bluGill · · Score: 2

    Are you kidding, you want a copy of BOTH edditions. I still go back to my first edition K&R book when I need to know.

    Maybe you don't have to make your code run on an old VAX as well as a system with a ANSI-C compiler, but I do from time to time. Even when I don't have to, I like to know my programs will work. (of course there are a lot of ansi-C tricks that I have to not use to make it work, and then put back in for modern systems, but I can deal with that)

  93. Re:Why are people still using a 30 year old langua by room101 · · Score: 2

    Yeah, consistent, until your app decides to garbage collect. On most platforms, your app stands still, or usually at least gets sluggish. Hopefully, that is a good time, but the bad news is, you have no control.

    To be fair, this is becoming less and less of an issue, but still an issue for hyper important/time sensitive apps. With C-style mm, you can decide when to free memory if you want.

    --
    room101 -- how much can you stand before they break you?
    (they always break you eventually)
  94. Re:Why are people still using a 30 year old langua by kob · · Score: 1

    C has no bounded array support. This makes it inherently unsuitable for any security programming taks.

    *cough* *NIX is written in C *cough*

    Yes, but wasn't Windows also originally written in C? I guess it's the programmers and not the language that determine the security.


    No Pascal.

  95. The only new C book we need... by Anonymous Coward · · Score: 0

    is one that advertises a 12 step program for C programmers.

    char *step_array[] = {
    "Get your C-compiler.",
    "Walk to the trash can.",
    "Deposit the compiler.",
    "Set the trash can on fire.",
    "Pick out another language.",

    .... ;

    for (i=0; i12; i++) {
    strcpy(cmd, step_array[i]);
    system(cmd);
    }

    I have no sig.

  96. Re:Why are people still using a 30 year old langua by frank_adrian314159 · · Score: 2
    Why are people ignoring 30 years of code maturity?

    Show me a 30 year-old C compiler that's still in use.

    The language may be mature; the knowledge that the compiler writers possess about the language and how to compile it may be mature; but I seriously doubt the maturity of most compiler code in use today.

    By your rationale, we should prefer Fortran and Lisp

    OOPS! I do (at least for most things). Never mind...

    --
    That is all.
  97. RT systems often can't afford garbage collection by DaveWhite99 · · Score: 1

    A garbage collector inflicts a significant run-time overhead to the system it's running on. Garbage collection is explicitly not in C++ because of this reason. However, there's nothing preventing you from linking in 3rd-party garbage collectors.

    --
    Biodiesel : domestic, renewable, clean, and in the fuel tank of my bone stock 2002 New Beetle TDI
  98. (OT) Java OS and the true cost of Visual Basic by yerricde · · Score: 1

    Maybe I'll write an efficient embedded OS in Java... oh, wait.

    Wait no longer. J2ME is here. Yes, I understand what you're saying (C tends to be more efficient than some other popular languages for writing stuff that directly bangs on the hardware), but an embedded Java OS does exist.

    Alrighty, then. I'll write my large, distributed database system in Java. Hey, that'll work! Too bad Visual Basic would cut my development time in half.

    Time is money, and money is time. The Java tools are available for almost free as in beer (Mandrake CD + Internet conn for downloading J2SDK). Visual Basic, on the other hand, costs much more per seat (Windows XP Pro license + Visual Studio license + Windows licenses for all the testers' machines), money that somebody has to earn. Does your estimate take into account the opportunity cost of the time you spend working to make up the cost of expensive software licenses?

    --
    Will I retire or break 10K?
  99. Re:In case you don't know what they're talking abo by jacoberrol · · Score: 1

    "The C++ Programming Language" by Bjarne Stroustrup

  100. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 0

    Heap fragmentation, my ass. I guess you know nothing about "steady state" or "reaching equilibrium". Eventually all programs with bounded memory reach this state. I have server apps running for months that don't experience this supposed fragmentation you speak of - with completely deterministic (fast) memory allocation and deallocation. Why don't you actually LOOK at the source code of a good malloc library to see why it does not happen as you claim.

  101. Re:Why are people still using a 30 year old langua by jaoswald · · Score: 2

    There are real-time garbage collectors, which are guaranteed to not take longer than a fixed time.

    Most modern garbage-collected languages can use generational garbage-collection, which, although not hard real-time, generally avoids long pauses, and is very efficient when much garbage is being generated quickly.

    Malloc and free are generally not hard real-time.

    Try reading the Garbage Collection FAQ

  102. Re:Why are people still using a 30 year old langua by jaoswald · · Score: 2

    So when your customer runs your program for many months and happens to trigger some rare condition that you didn't test, he'll just leak memory, right?

    This assumes that your test cases are always exhaustive enough to cover any possible order of reference creation and destruction processes, and have run times long enough to do so.

    I'm not blaming my tools, I'm blaming your tools. When I program in Common Lisp, I don't spend a millisecond of my time debugging/preventing memory leaks. You seem to spend days. Which seems like a better use of programmer time?

  103. Re:Why are people still using a 30 year old langua by room101 · · Score: 1

    1. I never said malloc/free were "hard real-time", I just said that the programmer could choose when it happens.

    2. Because I said something like "this is becoming less of an issue", I had hoped that intellegent people would understand that this is a general comment and not an absolute statement. Yes there are special cases/workarounds/advances, but generally, you make the trade-offs that you feel comfortable with.

    Do I think that garbage collection is probably better? You bet, but the point is that the programmer decides everything with the old way (for better or worse) and with gc, the system/library decides. Usually that is a good thing, but not always. (once again, this has been espacally true in the past, but yes, progress continues)

    Yep, that gcfaq is interesting, I have looked at it before. The only thing I don't like about it is you get the feeling that they think that anyone who doesn't use gc is just obviously retarded.

    --
    room101 -- how much can you stand before they break you?
    (they always break you eventually)
  104. Re:Why are people still using a 30 year old langua by Cro+Magnon · · Score: 1

    Have you seen the average progammers desk? Are you telling me you trust HIM to take out the trash?! He needs maid service (Java).

    --
    Slow down, cowboy! It has been 4 hours since you last posted. You must wait another few hours.
  105. Re:In case you don't know what they're talking abo by coleSLAW · · Score: 1

    But of course! There's Stroustroup's "The C++ Programming Language" which is a thorough reference to the language itself, and how to use it effectively. As well, there is Josuttis' "The C++ Standard Library." Together, they make a great set.

    --

    == I am not Me.

  106. Re:In case you don't know what they're talking abo by foonf · · Score: 2
    Maybe you don't have to make your code run on an old VAX as well as a system with a ANSI-C compiler


    Hasn't gcc been ported to the VAX? Seemed like it would have to have been, or the NetBSD Port would be impossible.
    --

    "(Man) tries to live his own life as if he were telling a story. But you have to choose: live or tell." --Sartre
  107. Best C book around there... by Anonymous Coward · · Score: 0

    "C Unleashed", by Heathfield, Kirby et al.

    http://www1.fatbrain.com/asp/bookinfo/bookinfo.a sp ?theisbn=0672318962

  108. Don't use C++ for Palm anyway by epepke · · Score: 2

    One can use C++ for the Palm, but unless one knows the language rather intimately, it's easy to produce a big chunk o' code. That's because, depending what you do, C++ can link big libraries without your acquiescence.

    The Palm requires the Old Virtues, grasshopper. Use simple C. Avoid non-Palm library calls.

    You could do a lot worse than just taking some of the sample Palm code and studying it. The O'Reilly Palm Programming book is pretty good.

  109. Re:In case you don't know what they're talking abo by emodgod · · Score: 1

    How old is you VAX C compiler?

    I remeber DEC releasing a version of their C compiler that tracked the ANSI C Specification (circa 1989). I had to make quit a few changes to some programs I wrote, since the K&R version of the VAX C compiler passed strutures as a pointer, while the ANSI C Standard changed the behavior to pass by value.

  110. Which decent games are written in lisp? by Anonymous Coward · · Score: 0

    Personally, I write my own malloc routine (based on standard ideas of course) and ensure that all dynamic variables are released between various stages of the game (long-lived data is statically allocated). It works, since I don't tend to allocate piddly bits of memory.
    Of course on PCs I just use the STL to take care of memory, because they have lots of it and its safer.

    1. Re:Which decent games are written in lisp? by jaoswald · · Score: 2

      I don't know about decent games (Abuse had a Lisp engine), but systems to develop games certainly have been written in Lisp.

      I would suspect that the best breakpoint for run-time efficiency is to have a C or assembly language rendering engine, with Lisp-based game action code. I.e. the dynamic portion that has to be easily changed is in Lisp, the part that has to smash data into registers as fast as possible would be in C or assembly. Of course, commercial Lisps typically have provisions for a Lisp-syntax expression of assembly code, so you can write assembler using Lisp macros...

  111. I have this oneRe:here's a good beginner book on C by ppetrakis · · Score: 1

    I have this book and I 'love' it. It's the only C book you need to get started and it will introduce
    you to some UNIX programming contructs too like fork . Well written, a little dense but you will find an answer to what you're looking for. The section on pointers is excellent. oh, realloc is only in the index :-) This is book is from the same publishing house as the one being reviewed.

    Peter

    --
    www.alphalinux.org
  112. Good points, bad conclusions? by Anonymous+Brave+Guy · · Score: 2

    First of all, let me say that I see where you're coming from, and I agree entirely. I think it is important for people to understand the effects of the code they write, to an appropriate level.

    However, I don't think your examples and conclusions follow from that as well as they might. For example, the inlining issue you mentioned (passing by value in C++) is a quality-of-implementation issue for your C++ compiler. It isn't a flaw in the langauge. It's a shame that we have to have idioms like pass-by-const-reference in a language at all today, since they are effectively nothing but preemptive optimisation and syntactic cod liver oil.

    My other suggestion is that, while I do think it's advantageous to know what's going on under the hood, that doesn't have to come before learning a higher level language. On the contrary, those who have programmed C or assembler for years and who then try to pick up a language such as ML seem to be hampered by an intuitive need to understand everything that's going on under the hood, and to map all constructs and ideas in the language onto familiar low-level terms. This is counter-productive. We know that some higher level languages can generate very good code, with speeds and executable sizes comparable even to languages such as C or C++ today. Focussing on the little details -- trying to break down a complex construction in a high level language into low-level concepts -- hides the big picture, and we all know that your performance really depends on the overall job, not the little tweaks.

    As a supporting fact, consider that today, most C or C++ compilers on Intel boxes generate better (smaller, faster) assembly language output than "hand-optimised" assembly written by the programmer. Issues like pipelining and parallel processing have rendered truly low-level programming a specialist art, requiring great skill. Since the people writing compilers specialise in that skill, I'm happy to let them do their job, and get on with mine using the tools they give me.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  113. My favorite C book... by seebs · · Score: 2

    _C Programming: A Modern Approach_, by K. N. King.

    http://knking.com/books/c/

    What I can say is, everyone I know who's on the C standards committee and has read this book liked it, as do a number of the regulars of comp.lang.c. I read an early printing, found maybe two small errors, and one basically correct thing that isn't the way I'd have done it. I believe he said the errors would be corrected in future printings.

    Nice book.

    --
    My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  114. Scheme is the best first language. by karlheg · · Score: 1


    I agree with "How to Design Programs" (MIT Press, available online with a great Scheme environment usable by beginners) as well as experts) that Scheme is a great first language.


  115. No no no. Scheme! Teach Scheme. by karlheg · · Score: 1

    The Teach Scheme Project and the "How to Design Programs" web sites have some very good arguments in favor of using Scheme as a first computer language.

  116. Get rid of C Books! by Anonymous Coward · · Score: 0

    Anyone who hasn't memorized K&R by now isn't worthy ;).

  117. Same title different book? by thogard · · Score: 2

    A few years ago I read a book that a huge "C" on the front. It wasn't about the language but about conspiracies and espionage. It had covered such things like a cannon ball price war in Portugal started by the British which resulted in the Spanish Armada being equiped with lower quality armourments. I think it was a better written book than the one covered by this review.

  118. Harbison and Steele by gdbrown · · Score: 1
    Just wanted to add a second opinion on this book...

    Harbison and Steele's "C: A Reference Manual" is an extremely thorough and detailed reference manual. Not a book from which to learn to program, but an excellent book for experienced programmers (either just learning C, or wanting something deeper than Kernighan and Ritchie).

    --
    Do not meddle in the affairs of dragons, for you are crunchy and taste good with ketchup.
  119. Another good C book by rweir · · Score: 1

    Expert C Programming by Peter Van Der Linden

    A recommended text for my second year programming course, it's a bit different to all the other C books I've read. Instead of just going over the syntax, and (intermitently) mentioning that X is a good way to do Y or foo should be baz'ed, it's a set of chapters on different aspects of C. There's on declarations, a chapter on how pointers and arrays are not the same, etc. Also nice is the humourous and informal style the author uses, peppered with jokes about PC architecture and Microsoft.

  120. 50K lines? Jesus Christ by Anonymous Coward · · Score: 0

    50,000 lines is the equivalent of a senior project for a CS bachelor's degree. If you are honestly suggesting that you can't write 50K lines of code without getting in trouble with your memory management, then I would suggest (no, I would plead) that you stick with Visual Basic or something else sufficiently easy. I'm the project lead for two systems written in C, both of which have over 1.5 million SLOC. Neither systems have any memory management skills. This is because we actually know how to code.

    Oh yeah, that's right .. in the Microsoft era, developers shouldn't have to know how to code! It's just a nuisance that gets in the way! It is hateful and elitist to suggest that developers should have any sort of skills whatsoever! Bah. You know, I don't care if it is elitist. I can code circles around any of these drooling VB veggies that the two-year Vo Techs are cranking out, and I'm not afraid to say it. Oh yeah, and I've actually got a strong base of knowledge when it comes to mathematics and abstract CS theory. Ask any of these morons to explain a Turing machine to you, and they start bawling.

    1. Re:50K lines? Jesus Christ by Anonymous Coward · · Score: 0

      I wouldn't be throwing around the word "moron" so easily if I were the aforementioned word responsible for using C in a large system instead of C++.

  121. Heh by Anonymous Coward · · Score: 0

    Neither systems have any memory management skills.

    This was meant to read "Neither system has any memory management problems." :)

  122. Re:don't waste your time by Requiem · · Score: 1

    One of my professors, one of the old guard of the department, told an interesting story to my Formal Languages class a few weeks ago. He said that back in the 70s, Kernighan and a few of the other Bell Labs guys had been at our university for some conference or another. Our professor asked them about the design of C, and they told him this:

    Some of the members of their group had expressed their concerns with the language - that it was a bit confusing, and that the many levels of precedence were a pain to deal with. They replied with, "Don't worry, it won't see any outside use."

    Classic.

  123. Verilog? by umarsyed · · Score: 1

    Verilog is a language with C-like syntax that compiles to hardware. How is your friend's work different?

    1. Re:Verilog? by Tom7 · · Score: 1

      Um... Verilog has just barely C-esque syntax, but has entirely different semantics. It's a language for describing circuits, not a general purpose language.

  124. Buggy fix for inlining by TimoT · · Score: 1
    I'm sorry to that afaiuc your piece of code is faulty.
    friend coord& operator+ (const coord& a, const coord& b) { return coord(a.x+b.x, a.y+b.y); }
    In this case operator+ is returning a reference to a coord-type variable, which is built on stack and destroyed at the moment the stack-frame of operator+ is overwritten. It may work on p1 = p2 + p3 -type of expressions, where p1 has a copy-constructor. Consider void foo(coord&); foo (a+b); (this won't catch the bug if + is inlined since the returned coord variable is allocated on the stack frame of the function calling +) or a case where the coord type has a destructor e.g. make the destructor set x = y = 0, and see if you program still works... This is error is a bit like returning a pointer to a variable in stack.
  125. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 0

    In real time systems you don't allocate things
    during time critical processes.
    (everything being preallocated during program
    initialisation).

    You can't do that with Java (i.e. it should
    be very very difficult, more difficult then writing in assembly ;-)

    => no real time with java.

  126. A page of code ? by SimonK · · Score: 2

    public class Hello {
    public static void main(String[] args) {
    System.out.println("Hello !");
    }
    }

    compare:

    #include "stdio.h"

    int main() {
    printf("Hello !");
    }

    5 lines each. Its a draw.

  127. Re:Why are people still using a 30 year old langua by Anonymous Coward · · Score: 0

    lol

  128. Re:In case you don't know what they're talking abo by bluGill · · Score: 2

    Yeah, but we hadn't updated the vax in years. It was only used for testing in a lab, as a network traffic generator. Not internet connected so security wasn't an issue. Never saw a real load, so there was no point in upgrading to something more modern. We have plenty of more modern equipment to play with, so nobody wanted to upgrade the vax, though when you need a few more traffic generators they were there.