PDA

View Full Version : Biased professors teaching antiquated crap



SilentStrike
09-07-2001, 07:50 PM
Is this a recurring theme in college?

In my data structures class (in Java, which is fine by me, memory management is a hell of a lot easier when you don't have to free memory), the teacher said a few things that I thought were off.

First, he talked about using vectors in java, despite how they are now deprecated in the API (ArrayLists are now preferred). Second, he described bools in C++ as "just an enumeration." (although they may have been implemented that way years ago in bool.h, that is before my time) I believe they are as much a part of standard C++ as booleans are of Java. Finally, he said a code fragment like this would cause a runtime error (this is java), like a hanging reference in C/C++ (returning a pointer to a variable on the stack in a local function).



static int func() {
for (int i = 0; i < 10; i++);
return i;
}


I instead thought it would be a compile time error, as i is simply out of scope, to which he responded "That would be nice, but I don't think it happens that way." On my compiler, indeed, it causes a compile time error.

Witch_King
09-07-2001, 09:52 PM
I don't see anything wrong with this in terms of C/C++



int func() {
for (int i = 0; i < 10; i++);
return i;
}

int main()
{
int i = func();
printf("%d",i);
return 0;
}


Must be different in JAVA?

Nick
09-07-2001, 10:18 PM
I have a book that a professor at Rutgers written :)

It has a typo on the third word, it's still great book though!
Very well written, at least the first two chapters, unlike some text books.

Professors at all schools have varying knowledge. Teaching java might be new to your school or the instructor is new to java.
I would hate writting that long ArrayList too! I wouldn't worry
about minor details but if the proffessor really can't teach...

I think pretty much bools behave as



enum bool {
true = 1,
false = 0
};


I think bools have been standard types since the 1997 c++ standard.

Nick
09-07-2001, 10:20 PM
He's probably using a older version of java, hence the
deprecated warnings.

SilentStrike
09-07-2001, 11:10 PM
int func() {
for (int i = 0; i < 10; i++);
return i;
}

It's a scope error in ANSI C++. You don't realize it, because you use the wonderful Microsoft compilers, which the nonstandard for scope.

int func() {

for (int i = 0; i < 10; i++) {
// By the standard, i is limited to this scope
}
// Using MSVC, i is in this scope
return i; // legal in MSVC, illegal for standard compiler
}

I was trying to refer this (least legal to compile) C/C++ runtime error which the professor was trying to explain that simply does not exist in java.

int* func() {
int i = 10;
return &i;
}

About the deprecated thing.... It's pretty saddening. The guy gets paid to lecture about data structures and is using deprecated data structures himself.

Witch_King
09-07-2001, 11:16 PM
I'm glad I have a good compiler. I don't have to put up with nonesense. I still don't think it's scope is the loop though because it is only defined once.

MSVC? Whats that?

SilentStrike
09-07-2001, 11:35 PM
Admittedly, MSVC is the friendliest IDE I've used. Still, it's standard support is crap.

http://www.flipcode.com/cgi-bin/msg.cgi?showThread=Tip-MSVCFor&forum=totd&id=-1

Witch_King
09-07-2001, 11:37 PM
I don't use MSVC because your right, it's standard support isn't good enough, that's why I use VS.NET. Much better IDE than MSVC and full standard support.

Salem
09-08-2001, 12:39 AM
It depends on how old your C++ compiler is, and whether it is designed to implement the old or new C++ standard.



int func() {
// code
for (int i = 0; i < 10; i++);
return i;
}


In the old C++ standard, the scope of 'i' was the rest of the function, as if you had done...


int func() {
// code
int i;
for (i = 0; i < 10; i++);
return i;
}


The new C++ standard tightened up the rules a bit, and specified that the scope of 'i' is just the for loop.


int func() {
// code
{
int i;
for (i = 0; i < 10; i++);
}
return i;
}


For instance, I get a warning when I compile this function, but it otherwise compiles fine. You should at least get a warning from the compiler if it's supposed to meet the latest C++ standard.

Witch_King
09-08-2001, 01:02 AM
I could run the code as managed code using the CLR or else as unmanaged code. Unfortunately I have not had time to figure out which menu choice I need to select to turn on the controls for managed code, infact I have not needed to use that yet because I'm just studying the language, but in the future I'm likely to write all my code that way.

You know full well that you can set the warning level. God damn, where is that button? Aww, I'm going to sleep. I'll look into it when I get up.

zen
09-08-2001, 08:09 AM
I don't use MSVC because your right, it's standard support isn't good enough, that's why I use VS.NET.

VC++.NET still allows the non-standard use of variables outside the for loop (at least the beta does).

The way they've implemented it differently than VC6.0 though and now anything goes, you can redeclare variables outside the for loop even though they are still considered to be in scope after the loop has completed, so code like this compiles on the highest warning level without a murmur from the compiler -


#include <iostream>

using namespace std;

int main()
{
for (int i=0;i<10;i++)
;

for (int i=0;i<20;i++)
;

cout << i;

return 0;
}

I think Microsoft probably allow this kind of thing so that code written to the standard will compile and old code will not break, but I think it should generate a warning at least.

Even though support for the newer standard seems to be there, it still doesn't work as in this example -


#include <iostream>

using namespace std;

int main()
{
int i =100;

for (int i=0;i<10;i++)
;

for (int i=0;i<20;i++)
;

cout << i;

return 0;
}

'i' is overwritten by the 'i' in the loop. This does generate a warning message though but I don't no any other compiler (inc VC6.0) that would let this go. VS.NET is still in beta though, so I suppose this may change.

Witch_King
09-08-2001, 10:15 AM
I have not been hindered yet by VS.NET at least not when solving bigger issues. I do have enough patience to understand my compiler. I don't intend on using any other compiler.

It sounds like that teacher isn't too terrible. If you think that's bad than you are in for a shock. Take a subject like physics for example. Wait till you get a physics teacher that doesn't know what he/she is doing! If you know more than them than don't worry about it. Do not try to correct them but instead keep it to yourself and study the book. Those teachers are not there to teach the newest and the best techniques. They are hired by the government to make sure that students meet a certain level of standard, not the highest level. If you try to correct them too much than you will not enjoy the class. Take it as a chance to continue to study on your own because shortly after you are done you will have to work and there won't be any time like there is now to study independantly.

SilentStrike
09-08-2001, 11:21 AM
I am taking physics as well, but I had already taken AP Physics (looking at the syllabus, I know probably 80-85% of matieral already, but I am weak with waves, and taking the next class without a completely solid base is probably not a good idea). The physics teacher is good though. He said nothing during the first lecture that had a hint of being wrong, and knew a LOT of stuff I didn't.

Witch_King
09-08-2001, 02:34 PM
The worst case is when you have a teacher that doesn't speak english. I mean that. Somehow they get the job. I once had a physics teacher that didn't know what he was doing. The lectures were junk but he than made the midterm and final really easy to make up for the fact that nobody understood what was going on. Only in a big school.

SilentStrike
09-08-2001, 02:48 PM
Yeah, that could definitely be a problem. Fortunetely, all my professors thus far speak English well.

We have recitations (smaller classes with a TA) once a week which are supposed to help offset having professors like that. But yup, I hope I don't get any professor's who can't really speak English.

Witch_King
09-08-2001, 02:58 PM
Oh yeah, I remember those study periods. I used to go to a public University. I did my highschool upgrading there.

master5001
09-09-2001, 12:51 AM
You are certainly right about the type of error. Nonetheless, a teacher is just a person and people can be wrong. I have to agree with your teacher on the use of Vectors though. Depricated or not they are very useful. Hang in there, if your attitude remains the way it is then you won't gain too much from the class.

SilentStrike
09-09-2001, 09:53 AM
Quote from Bruce Eckel's Thinking in Java.

"The only self-expanding sequence in Java 1.0/1.1 was the Vector, and so it saw a lot of use. Its flaws are too numerous to describe here (see the first edition of this book, available on this book’s CD ROM and as a free download from www.BruceEckel.com). "

Deprecated is an official term in Java. It means it has been replaced by something more useful and functional. I was not referring to vector as an expandable array, rather Vector as java's initial flawed implementation of such.