Hacker News new | comments | show | ask | jobs | submit login

I did not say it was. But it's a shitty test regardless.

Again, it depends on what those kids were supposed to study. If it's a general programming/algorithms class then yes this is testing the wrong knowledge. If it's a C++ specific class, this is completely justified. How does one come out of a C++ class and not know this stuff?

It was "an intro to programming course for incoming engineering freshman".

Also I write C++ for living and I was not entirely sure if "y = x++3;" was valid or not (turns out it is an error but "y = x+ +3;" is fine, which I would have guessed but would not have been quite certain).

Edit: Now that I think about, I believe that "x = (x++ == 3 + x % (x=x=3));" is undefined behavior. I guess the question is not asking about that but regardless, that's a stupid thing to ask.

If you set aside the fact that the deeper issue is probably that C++ in general is a bad intro language to begin with, then its not completely unreasonable to test on this syntactic stuff, especially as you go farther back when compilers/checkers were less friendly. For better or worse, one of the lessons of programming is the unforgiving nature of the computer to do exactly what you typed in, and not what you meant. I remember having a similar test or quiz to this when I was in high school (~12 years ago or so). Its not that big of a deal, the whole class is not just that, its just to kind of drill this into your head. We were using pretty terrible Borland compilers with rubbish error messages. At that particular point, being able to stare at code and determine what minor thing you mistyped was unfortunately a crucial skill. Again, this is arguably less important today (and arguably all written tests are bad for CS).

Later in college, I remember hating the assembly tests where you had to keep track of what numbers were in what address, and whether you were adding what was on the stack or in some register or the address or what was in the address and making a mistake in the very beginning could ruin the whole problem. Not fun, not sure how useful, but certainly gave you an appreciation of what was going on.

I guess my main issue is with OP's attitude regardless of the test's content. His sense of "lol, I sure showed the freshmen that I can put together a test that they would fail" is just plain dumb.

Questioning what the -Wall -Wextra -pedantic arguments mean would be better. This is how you find those typos in the real world.

Ask them about compiler errors. For example, what does "undefined reference to `vtable for Foo'" mean?

Then some style guide [0] might be helpful. Make them write the rvalue expression to the left of comparisons, because "if (3 = x)" is an error then. Or some "assert (this != NULL)" in methods.

Ask about semantics, like "What is the difference between a move and a copy constructor?" or "Write a program to demonstrate the difference between any two of static_cast,dynamic_cast,reinterpret_cast,const_cast,implicit cast" or "When should you use unique_ptr instead of shared_ptr?"

[0] http://google-styleguide.googlecode.com/svn/trunk/cppguide.x...

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact