Thread: Frustration in learning C++

  1. #31
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    The programmers who only use one compiler, learn to rely on obscure features of that compiler or its library, and then insist there is nothing wrong with their code when another compiler rejects the code.
    ++And it is an infection that just spreads and spreads!

    Soma

  2. #32
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    Quote Originally Posted by grumpy View Post
    Those who slavishly insist on premature optimisation. Those who delight in squeezing 25 critical side effects into a single unreadable statement. Those who insist on using a bitwise operation to divide by 2, and those who insist on multiplying by 2 in order to shift bits.
    I used to be like that...there are a lot of older articles on optimization in C that will swear by doing these sorts of things. However, one eventually learns that modern compilers are made to take the simpler statements and perform these optimizations automatically. Modern optimizing compilers want you to simply tell them what you want the program to do in the simplest terms, and hopefully will produce the most optimized product available while preserving a readable code.

  3. #33
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    That's a fair point but I think grumpy's is more to the effect it has when you're really doing one thing (bit fiddling) and deliberately trying to be cute (using arithmetic).

    There is a certain productivity to being able to do a lot with a line, but that's easier in higher level languages.

    Both of these things kind of make you wonder what people really care about.

  4. #34
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    Being in the programming "business", so often one programmer will quickly throw some code together, completely undocumented and cryptic in nature. Then they leave the company, leaving the next person completely lost. People ought to care about readability first and foremost, and if you have to do something cryptic, comment the hell out of that line so that an idiot can understand it. Code can almost be described as beautiful when you program in this way, and it makes it's courteous to the next man.

  5. #35
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    comment the hell out of that line so that an idiot can understand it
    Comments are great so long as they are correct. Often times code sections get updated and yet the comments do not which is essentially the same as having no comments. Heavily commented code usually results in large incorrect sections of comments b/c most programmers fail to update the comments. As well various integrations and merges can cause the comments to be out of place. I have seen comment sections that began 1 line out of place and about a year later the section was almost 50 lines out of place.

    Most of the time when I am learning a new code line I rarely, if ever, rely on the comments. I may refer to them when I just cannot figure the code out but more often than not I will ask someone or find someone to ask that has worked on the code. That sure beats sitting there spinning my wheels all day long.

    And remember no matter how much you idiot proof your code there is always a bigger idiot out there. Readability is key but going overboard actually hurts readability. I believe it is a balancing act that you learn through experience.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Frustration with tutorial.
    By A34Chris in forum C Programming
    Replies: 19
    Last Post: 03-18-2008, 03:08 AM
  2. Frustration
    By curlious in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 09-29-2003, 02:22 PM
  3. Frustration ...
    By goran in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 08-06-2003, 11:21 PM
  4. DLL frustration
    By robid1 in forum C Programming
    Replies: 4
    Last Post: 06-22-2003, 03:37 AM
  5. Frustration
    By kas2002 in forum C++ Programming
    Replies: 4
    Last Post: 05-29-2002, 05:00 PM