last day (15 days later) » 

16:57
18
Q: Is it appropriate to ask the professor a trick question?

User6784315I'm a CS student enrolled in a class about a certain programming language. Recently, I discovered a trick that is pretty useless in actual production code and doesn't seem to be known by many. The trick results in a program not outputting the expected result. The program is less than 5 lines long...

That is the sort of sophomoric trick you would pull on a classmate, not a professor.
Why are you curious? Are you trying to figure out if professors are street-smart? Are you close to him? If not, this will almost certainly backfire, particularly if he interprets that you are trying to embarrass or outsmart him. In addition to you looking silly, he may be legitimately annoyed that instead of asking a legitimate question, you are wasting his and your time. Most "trick questions" (at least in my field) are pretty dumb and based on interpretation, context or missing information.
"The program is less than 5 lines long." So is it 4 lines or what? It shouldn't be that hard to count and write the actual number if it's less than 5.
No CS professor cares about some esoteric programming language "gotcha". He won't know, won't care, and will find it quite annoying.
Is consultation time meant to use as a period where you can discover things about your professor, e.g. when you are curious as to whether [they] would be able to uncover [something]? If not, then using it for that purpose is by definition not appropriate, for certain values of appropriate
16:57
If you're dying to sound smart, maybe skip it and turn it into a joke to brighten up people's day. Like this time I was asked for a regex to match a really complicated expression, and I just replied with .*, which gave some people a chuckle (or maybe made them spit out their coffee, not sure).
@Džuris "Lines of code" isn't a useful measure of anything, since it depends as much on formatting conventions as anything else.
@gardenhead Professors are people, too. I don't see how you can be so confident that somebody you don't know will or will not be interested in or know about a particular corner case of some programming language. Certainly, if I were teaching a programming language, I would hope to have sufficient expertise in it to know about that kind of thing.
So. What's the trick? As for your question, it really depends on the personality of the professor.
Depends. Is there any didactic purpose to the gotcha? (Java has tons, and Python has quite a few). Some of these are very instructive (e.g. the mutability, shallow copy-related ones), and some are just annoyances or mistakes in the standard. Anyway, I'd phrase it as a comment: "There's an obfuscation/gotcha revolving around X" instead of a riddle.
You have made some of us very curious about the trick. Please tell us the trick.
@gardenhead can confirm. I would be somewhere between annoyed and confused.
16:57
@DavidRicherby CS is not about teaching one programming language after another. In fact, I'm quite surprised that a CS department would even have a class to teach a particular language - I'm guessing it's not and OP just worded it poorly.
@gardenhead I work in computer science so I'm well aware of what the subject is. Every CS course I've been involved with has taught at least one programming language. As you say, CS isn't programming but programming is a skill that any undergraduate computer scientist needs.
@gardenhead: "In fact, I'm quite surprised that a CS department would even have a class to teach a particular language" That's such a ridiculous statement, I would think that you were from a country (if not planet) different from mine. But according to your profile we live in the same city. Data point: All of the intro courses at Brooklyn College (CIS 1.x or 2.x) are specific to either Java, Perl, or C++. brooklyn.cuny.edu/web/academics/schools/naturalsciences/…
Well, at my college, there were no courses to teach programming languages. We were taught data structures, algorithms, discrete math, computer systems, etc, but never a course just to learn Java or C. YMMV, apparently.
@Džuris : Being non-specific actually makes a lot of sense, since often code can be written in different ways, varying the line count without actually affecting what is significant (which is the behavior).
@gardenhead If I ever interviewed someone with a CS degree who had never written a program to actually build and use a data structure, algorithm, math, etc., I would consider them completely unqualified. How can anyone claim to know CS without experience in writing some kind of code and running/compiling it? What language a student learns is immaterial, it's very unlikely to be one they will use in an actual job (sometimes though it is), but to know absolutely no languages makes a student almost worthless for anything other than academics, imho.
16:57
@ToddWilcox You seem to misunderstand. We absolutely learned programming - it just wan't the entire focus of the course. For example, there were two courses on data structures - one was in SML, the other in C. And with that background, I am now able to learn a new language extremely quickly, and actually analyze its features, as opposed to just learning whatever is hot without any understanding.
Back in the day, we coded only Pascal in our CS course. However, we studied multiple languages, and compared them. I remember tracing the evolution of Algol and its influence on other languages. We also had exercises do design an assembler for an imaginary CPU, first with 4 general registers and an accumulator, then 3, then, 2 ... until we had only an accumulator. After which , we compared the instruction sets.
Sure, we mostly studied algorithms, etc, but we did have a lot of programming (e.g simulate the CPU of a PGP 11), which were all done in Pascal, but could have been any language, as that is not deemed important for Comp Sci.
I am curious as to whether my professor would be able to uncover the solution I read this as "I'm trying to look smart in front of my professor, and really want validation from them"

last day (15 days later) »