tags:

views:

380

answers:

9

I've been programming c++ for about a year now and when i'm looking about i see lots of references to STL.

Can some one please tell me what it does?

and the advantages and disadvantageous of it?

also what does it give me over the borlands VCL or MFC?

thanks

A: 

The STL has Iterators. Sure, collections and stuff are useful, but the power iterators is gigantic, and, in my humble opinion, makes the rest pale in comparison.

Space_C0wb0y
+22  A: 

It's the C++ standard library that gives you all sorts of very useful containers, strings, algorithms to manipulate them with etc.

The term 'STL' is outdated IMHO, what used to be the STL has become a large part of the standard library for C++.

If you are doing any serious C++ development, you will need to be familiar with this library and preferably the boost library. If you are not using it already, you're probably working at the wrong level of abstraction or you're constraining yourself to a small-ish subset of C++.

Timo Geusch
what does it give me over borland VCL or microsoft MFC?
Jonathan D
@Jonathan D: Portability, of the code you write and also yourself and your skills.
Teddy
Jonathan D: The ability to get a C++ job. Claiming to know C++ without the ability to use the STL is going to get yuo rejected at the first level of any job interview.
Martin York
Also, a lot of the other important C++ libraries like Boost do expect and use standard c++ containers semantics. If you're not familiar with the idioms, they feel strange to use whereas it will feel natural people who are familiar with the standard C++ library. Also, MFC is a particularly bad example of a C++ library, mainly due to its need for backward compatibility. Please do not try to learn good C++ library design from MFC.
Timo Geusch
Jonathan D: While MFC has some string and container classes, it's secondary to the GUI elements. The STL (or, more accurately, the container classes, iterators, and algorithms) is completely unconcerned with the GUI, but gives you very powerful tools to organize and process data. I know nothing of VCL, but the MFC and STL are two very different libraries that do mostly different things.
David Thornley
+1  A: 

"advantages and disadvantageous" compared to what? To writing all that code yourself? Is not it obvious? It has great collections and tools to work with them

Andrey
+2  A: 

It provides common useful tools for the programmer! Iterators, algorithms, etc. Why re-invent the wheel?

Bryan Denny
A: 

Wikipedia has a good overview: http://en.wikipedia.org/wiki/Standard_Template_Library

The STL fixes one big deficiency of C++ - the lack of a standard string type. This has cause innumerable headaches as there have been thousands of string implementations that don't work well together.

The string type in the Standard Library was never part of the STL, or at least of the STL designed by Stepanov and Lee.
anon
@Neil You're right. It is part of the C++ Standard Library (http://en.wikipedia.org/wiki/C%2B%2B_standard_library), not the STL (http://en.wikipedia.org/wiki/Standard_Template_Library). but then I think many people say "the STL" when they mean "the C++ Standard Library". (The fact that they are many doesn't make them right, of course.)
Daniel Daranas
Even so, you still find a lot of string libraries in C++ code. Remember RogueWave, CString + everyone used to think they could do it better? Not to mention that the reference counting in std::string wasn't thread-safe in a lot of implementations.
Lou Franco
A: 

It stands for standard template library

It is a set of functions and class that are there to save you a lot of work.

They are designed to use templates, which is where you define a function, but with out defining what data type it will work on.

for example, vector more or less lets you have dynamic arrays. when you create an instance of it, you say what type you want it to work for. This can even be your own data type (class).

Its a hard thing to think about, but it is hugely powerful and can save you loads of time.

Get reading up on it now! You want regret it.

thecoshman
+3  A: 

The STL is the Standard Template Library. Like any library it's a collection of code that makes your life easier by providing well tested, robust code for you to re-use.

  1. Need a collection (map, list, vector, etc) they're in the STL
  2. Need to operate on a collection (for_each, copy, transform, etc,) they're in the STL
  3. Need to do I/O, there's classes for that.

Advantages

1, You don't have to re-implement standard containers (cus you'll get it wrong anyway)

Read this book by Nicolai M.Josuttis to learn more about the STL, it's the best STL reference book out there.

Glen
A: 

It gives you another acronym to toss around at cocktail parties.

Seriously, check the intro docs starting e.g. with the Wikipedia article on STL.

Dirk Eddelbuettel
Programmers don't go to cocktail parties. They go to LAN parties.
John Dibling
+4  A: 

STL stands for Standard Template Library. This was a library designed mainly by Stepanov and Lee which was then adopted as part of the C++ Standard Library. The term is gradually becoming meaningless, but covers these parts of the Standard Library:

  • containers (vectors, maps etc.)
  • iterators
  • algorithms

If you call yourself a C++ programmer, you should be familiar with all of these concepts, and the Standard Library implementation of them.

anon
Rumor has it STL actually stands for "Stepanov and Lee!" (Rumor *had* it, anyway...)
John Dibling