What my uni course thinks of the Standard Template Library

Chat about anything not covered in these forums, but keep it civil!

Post » Thu Mar 26, 2009 1:01 pm



What do fellow programmers think?
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Thu Mar 26, 2009 1:48 pm

"It is clunky"

It's the fastest and best optimised set of classes for arrays, maps, etc that I know to exist..

"Method names are often verbose"

This is a good thing, and in a time when every single - even ten year old - development environments have intellisense, what is the problem? Better to have full names than to shorten them and confuse.

"Use of methods is rarely intuitive"

Sometimes I feel inclined to agree with this; I find myself ocassionally looking at documentation for it, but on the whole it's no harder than any other library.

"..no bounds checking.."

I'm not sure what to make of this; it seems to be a design decision whether libraries error check, though I'd argue that for the sake of speed and streamlining - as well as programmer control in some instances - that for STL, this is the right way to go (for other libraries it may well not be).

"Names of methods and classes aren't mainstream"

Why aren't they? There's no example cited, but the storage classes at least seem to be suitably named.

"Iterators"

I used to be a fan of not using iterators, but since I've used them I can see their advantages; they're quicker and more intuitive than looping and looking up via indexes.

Seems like a load of tosh.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Thu Mar 26, 2009 2:00 pm

the no bounds thing is wrong. In debug mode, it checks for you, and if your out it crashes with an error :P Besides its a 'bug' if your program accesses outside the bounds....cant wait to see what ashley thinks ;)
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Thu Mar 26, 2009 2:04 pm

Yeah, that's what I meant; I think they mean that it should check bounds in release/debug and stop a crash/exception, which is totally wrong for a library like this. It should present you with every bug you should have, not hide them.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Thu Mar 26, 2009 2:08 pm

B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Thu Mar 26, 2009 2:12 pm

Well put.. my biggest worry is that people like this may transfer these views onto students; they shouldn't be allowed to teach such crap, even if they don't like STL.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Thu Mar 26, 2009 2:45 pm

AAAAARRRRGGGGGGHHHHH!
This is wrong, wrong, wrong, wrong! You should definitely at least link them to this thread. They need to know why that is wrong.

"The main problem with the STL is that it was clearly written by a committee"
Why is that clear? Which committee wrote it? What suffered as a result? As an interesting thing to note, my copy of the <vector> header has the copyright notice "Copyright (c) 1992-2008 by P.J. Plauger". Written by a committee or written by one guy? :P

"It is clunky"
Why? What does 'clunky' mean? Does it mean slow? The source code is available, meaning the compiler can make optimisation and inlining decisions that are impossible when using .lib libraries. This actually makes it extremely fast. I once tried to write my own container faster than vector. I thought it'd be easy, and took lots of dangerous shortcuts to make it faster. It was slower. Does clunky mean badly designed? The STL is one of the best designed libraries out there, probably ahead of its time too.

"Method names are often verbose"
Which method names? find? begin? end? front? back? copy? sort? Verbose? Is this a joke?
If you don't like the std:: prefix, stick using std::find at the top and you can use find like a global function.

"Use of methods is rarely intuitive"
Which methods? Is my_vector.pop_back() to remove the last element really something hard to get your head round?

No bounds checking is done on arrays(vectors)
Incorrect. vector::operator[] does not bounds check, which is a deliberate decision. vector::at() bounds checks, and throws out_of_range exceptions if you pass an invalid index. Also, iterators are bounds checked in debug mode, so i++ will throw an exception if you're already at the end of an array. If it was a pointer, I'd be running in to undefined memory and left pretty clueless about what the problem is. This has saved my ass many a time.

The names of methods and classes is often non-mainstream
You mean, everyone in the world agreeing that a vector is called a vector isn't mainstream? Again, I point to find as well.

Iterators are used instead of pointers
A strong benefit instead of a problem. As mentioned, they are bounds checked when debugging, so you can never have an iterator to random memory (how many pointers have you had pointing to nowhere?). They are equally as fast as using pointers. The syntax is also identical for any container. Whether you're using a binary tree, a linked list or a contiguous array, i++ means move to the next element, wherever it is. This simplifies the readability of code greatly, and also means if I suddenly decide I want to use a vector instead of a linked list for my container, I just need to change a few typedefs. I wouldn't even need to change any code! Better yet, the syntax is pretty much identical to that of pointers. I don't get why this is listed as a problem.

Does not always interface well with C++
Like where? The containers support any C++ object with the proper copy constructors and such, and they even work combined with normal C arrays.

In short, this is obviously not researched at all, just a list of completely fabricated "problems", and is amazingly inaccurate. Every C++ programmer should learn and use the STL.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sat Mar 28, 2009 12:25 pm

I like pumpkin pie.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966


Return to Open Topic

Who is online

Users browsing this forum: No registered users and 3 guests