Like Tree7Likes

Why new programming students aren't fairing well.

This is a discussion on Why new programming students aren't fairing well. within the C Programming forums, part of the General Programming Boards category; It has amazed me how poorly prepared students are for the more advanced programming classes I've taken, but recently I've ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Location
    Saratoga, California, USA
    Posts
    334

    Why new programming students aren't fairing well.

    It has amazed me how poorly prepared students are for the more advanced programming classes I've taken, but recently I've had to go back and take a basic C course for my degree. Now I know why.

    I thought I'd share some of my instructor's thoughts on C with you all.

    1.
    Code:
    int b = 5;
    
    -b++ //will evaluate to -6 AND b will have -6 as its value after the expression
    2.
    Code:
    (a + b)++  //is apparently a valid expression
    3. Any variable declared in main() is in scope in any function if it is written below main.

    4. Functions should never return anything but exit status. Goodbye float, char, pointer, struct, etc. functions. And 0 means no error.

    5. Formal parameters in a function definition are not local variables to that function, they are merely aliases to the actual parameters. They produce no overhead in other words. (Yay for infinite recursion).

    6. For loops are counting loops, while and do/while are conditional. For loops are more efficient because of this.

    7. Never, ever, ever use break or continue. ( I'm sure there are others who feel the same way on this ).

    More to come, I'm sure. Sadly, after 10 weeks, the class has seen probably 30 lines of code all told.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,514
    Quote Originally Posted by Tclausex View Post
    1.
    Code:
    int b = 5;
    
    -b++ //will evaluate to -6 AND b will have -6 as its value after the expression
    I would not guess that this would be the result; I would guess +6 in b.

    Quote Originally Posted by Tclausex View Post
    2.
    Code:
    (a + b)++  //is apparently a valid expression
    IMHO, This is maybe true; No idea how it is useful.

    Quote Originally Posted by Tclausex View Post
    3. Any variable declared in main() is in scope in any function if it is written below main.
    IMHO, This is completely false.

    Quote Originally Posted by Tclausex View Post
    4. Functions should never return anything but exit status. Goodbye float, char, pointer, struct, etc. functions. And 0 means no error.
    I have heard this one below from non-C programmers; it has it pluses and minus. I think it does NOT really work well for a low level Language like C.

    Quote Originally Posted by Tclausex View Post
    5. Formal parameters in a function definition are not local variables to that function, they are merely aliases to the actual parameters. They produce no overhead in other words. (Yay for infinite recursion).
    The conclusion is defiantly wrong in my opinion (true for inline functions.)
    The parameters are passed on the stack on most; maybe all implementations.

    Quote Originally Posted by Tclausex View Post
    6. For loops are counting loops, while and do/while are conditional. For loops are more efficient because of this.
    I will give him this one; I think it might be right.

    Quote Originally Posted by Tclausex View Post
    7. Never, ever, ever use break or continue. ( I'm sure there are others who feel the same way on this ).
    I assume from number 7 that the switch/case statement is NOT allowed to be used.


    At my College, an good (according to every body I asked) instructor in C never gets to covering how to write a proper header in C in the first semester.

    I have reached the conclusion that there is NO instructor that really teaches the basic of programming very well at my College; they all appear to teach the language syntax instead of how to break the problem down into steps. Note: The good instructor in C seems to be the closest to teaching how to program; but, he runs out of time to teach the full beginners level of C programming.


    Tim S.
    Last edited by stahta01; 12-01-2011 at 04:16 PM.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    Quote Originally Posted by Tclausex View Post
    Sadly, after 10 weeks, the class has seen probably 30 lines of code all told.
    I'm not surprised:


    Quote Originally Posted by Tclausex View Post
    Code:
    (a + b)++  //is apparently a valid expression
    ...

    3. Any variable declared in main() is in scope in any function if it is written below main.
    ...since the above two will lead to a lot of code that even the most absurdly lenient C compilers from 1980 wouldn't know what to do with.

    I've met exactly one person like that in my programming career - thankfully for me, he didn't know enough programming to know I'd totally ignored his "guidelines". The code worked (despite his best efforts) so he didn't care to learn too much...
    Last edited by JohnGraham; 12-01-2011 at 04:48 PM.

  4. #4
    Registered User
    Join Date
    Sep 2011
    Posts
    81
    I go to University of Central Florida which has one of the highest rated CS and Engineering departments in the country. I believe it's like #5 or so. Even so, the teachers do quite well at teaching but you have to do a lot of outside work in order to fully understand the concepts. Relying on teacher for sufficient knowledge is silly nowadays.

  5. #5
    Registered User mdj441's Avatar
    Join Date
    Aug 2011
    Location
    NYS, USA
    Posts
    18
    There was a teacher in my high school who taught C++ or, as his website put it, "C." He gave all his students a copy of Turbo C++ 2.x (or so) for DOS through 2007-ish when he upgraded to 4.0. It was a 5 day/week, 2 hour/day class that ran yearlong but never covered arrays or pointers or namespaces or templates or type (ie. class) definition.

    The class may have just been axed this year, I'm not sure.

  6. #6
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    949
    -b++ evals to -6 but 6 is stored in b. ++ has higher precedence than unary minus.

  7. #7
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    949
    Seeing as how for is really just a preprocessor directive that expands to a while loop, I'd say they're equally efficient.

    Your professor might be retarded.

  8. #8
    Registered User mdj441's Avatar
    Join Date
    Aug 2011
    Location
    NYS, USA
    Posts
    18
    Quote Originally Posted by Epy View Post
    Seeing as how for is really just a preprocessor directive that expands to a while loop, I'd say they're equally efficient.
    If you mean a for loop could be imitated using a macro that expands to a while loop, I'd agree. But the the keyword for itself is definitely unrelated to the preprocessor.

  9. #9
    Registered User
    Join Date
    Nov 2011
    Location
    Saratoga, California, USA
    Posts
    334
    Well,

    -b++ evaluates to -5.
    (a + b)++ would be akin to saying (a + b) = (a + b) + 1, which makes no sense at all. Increment/decrement operators require 1 lvalue. Also, it was being used on the board as an example of adding 1 to the evaluation of a plus b, which has to be the ultimate in laziness.

    And as far as I've ever understood it, a for() loop is just another loop. To say that it isn't conditional, is absurd. Unless you write it as for( ; ; ) of course, but then it's infinite unless you put a conditional inside! Whether it's more efficient or not, I couldn't say. If someone out here understands what's going on under the hood would like to comment on that, I'd love to know.

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Tclausex View Post
    It has amazed me how poorly prepared students are for the more advanced programming classes I've taken, but recently I've had to go back and take a basic C course for my degree. Now I know why.

    I thought I'd share some of my instructor's thoughts on C with you all.
    And on the other hand, we have people here who were struggling to write what I would consider a commercial quality application as their second assignment in first semester...

    One has to wonder how many programmers know how to teach and how many teachers actually know how to program.
    MK27 likes this.

  11. #11
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,444
    Out of curiosity, but about the -b++ and (a + b)++ examples: was there no student in the class who attempted the examples and then asked the teacher why the result was different or why the program would not compile?

    #4 and #7 are stylistic issues, so pure beginners cannot be expected to know better (and #7 may be held by the "bondage and discipline" variety of experienced programmers). Until it occurs to a beginner that he/she needs to modify a variable in a function such that the result is reflected in the caller, #5 could well appear correct too, efficiency issues aside.

    As a rule of thumb of "counting" versus "generic condition", #6 could be useful to help a beginner choose, except for the claim about efficiency, which would be beyond a beginner's ability to dispute anyway.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  12. #12
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    949
    Quote Originally Posted by mdj441 View Post
    If you mean a for loop could be imitated using a macro that expands to a while loop, I'd agree. But the the keyword for itself is definitely unrelated to the preprocessor.
    I'm having trouble finding a solid source, but you will see several discussion results that say most compilers expand for loops to while loops (not necessarily using the preprocessor, no). This is what I was referring to.

    And regarding -b++ evaluating to -5: goddamn prefix and postfix increments. b is indeed 6, but you're right, that expression does evaluate to -5.
    Last edited by Epy; 12-02-2011 at 05:42 AM.

  13. #13
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Code:
    int b=5;
    -b++;
    printf("b equals: %d",b);
    b equals: 6

    In Pelles C.

  14. #14
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,444
    Quote Originally Posted by Adak
    b equals: 6

    In Pelles C.
    When compiled by any standard conforming C compiler.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #15
    Registered User
    Join Date
    Mar 2009
    Posts
    344
    Quote Originally Posted by Epy View Post
    I'm having trouble finding a solid source, but you will see several discussion results that say most compilers expand for loops to while loops (not necessarily using the preprocessor, no). This is what I was referring to.
    This is wrong. Hopefully you just misunderstood and they were saying that you can code any while loop as a for loop or vice versa, but what you've described above is not how compilers work.

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. O_o cin and cout aren't declared?
    By charlybob in forum C++ Programming
    Replies: 6
    Last Post: 10-03-2006, 11:25 AM
  2. Vindictive bunch, aren't we?
    By samGwilliam in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 04-05-2005, 06:59 PM
  3. they aren't teh
    By neandrake in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 11-21-2004, 08:42 AM
  4. Any Computeach International Students/ex students??
    By stevey in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 03-26-2002, 03:12 PM
  5. Why aren't we all here 24/7?
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-30-2001, 09:49 PM

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