Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

March 9, 2006

Setting the Stage for C++ Boost

Filed under: C++ Boost — tabrez @ 2:57 pm

C++ is a modern language. There is a difference between calling a programming language to be “still applicable” and calling it to be “modern”. “still applicable” languages exist because they are efficient enough to solve the problems for which they were originally created and that such problems still exist. Modern languages, on the contrary, solve the problems of today, and solve them efficiently. For a language that was created in 1970s, when today’s problems were unimaginable, C++ grew with the time, gone through constant modifications so that it can better reflect the requirements of every age. One excellent proof of the constant improvements that C++ language has undergone to remain competent enough to meet the new challenges is the C++ Standard Library.

To see the tremendous improvement in the productivity levels obtained by using the higher-level utilities of C++ standard library, consider the following examples: the first one reads a set of names from the standard input, sorts them in the alphabetical order, and then prints them out to the standard output:

C++:
  1. vector<string> names;
  2. string name;
  3. while(cin<<name)
  4.     names.push_back(name);
  5. sort(names.begin(), names.end());
  6. copy(names.begin(), names.end(), ostream_insterter(cout, "\n"));

Lines 2, 3, and 4 can be further simplified, but I wanted them to be that way. Consider another example, which checks whether a string is a palendrome or not:

C++:
  1. compare(pal.begin(), pal.end(), pal.rbegin());

The C++ Standard Library : A Tutorial and ReferenceNo, there isn’t anything missing out there. That’s all the code that you need to check for a palendrome. Try writing these two samples without using the C++ standard library, and you will see the difference. Its not just a time-consuming effort to write them in C-style of programming but it also needs more investments in terms of testing and the maintenance jobs. Still a large number of C++ programmers do not make sufficient use of it. But those who do, look at C++ language from a completely different perspective - as a modern and a highly productive software development tool. Like, there hardly would be any memory management chores to do by the programmer, except when creating the low-level libraries.

C++ Templates: The Complete GuideWhen one gets used to this style of software development with C++ - making use of its standard library - one starts to wish for more such utilities that could solve their everyday problems equally effectively. Changes to the C++ language/standard library are not made very frequently in order to provide a level of stability to the it. The void thus created has been partially addressed by another excellent collection of quality libraries, called C++ Boost Libraries. Its not an official part of the C++ language, but its portable, efficient, rich in functionality and is very close to the philosphy of standard C++ library. Infact, many of the new additions proposed for the next version of C++ standard library are picked from the Boost libraries. A large number of C++ programmers have already started to make use of these libraries, making it unofficially official part of the C++ language ;)

Some example libraries present in Boost are: filesystem access library, thread libarary, network socket library, regular expression library, lambda template library etc. There is a large set of collections, algorithms and iterators too. Look at the complete list of libraries if you are interested: there is a list according to the categories of the libraries and an alphabetical list.I will soon follow this up with a few examples using some of these C++ Boost libraries.



If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Boost Filesystem Library: Writing Portable C++ Programs to Acess The Filesystem
  • C++ Boost Filesystem Library(Part II): Example Programs
  • Installing C++ Boost on SuSE and Fedora
  • How to Test C++ Boost Installation
  • Installing C++ Boost on Slackware/Zenwalk
  • Installing C++ Boost 1.34.1 on Slackware/Zenwalk
  • C++ Development Environment on Windows using Eclipse Ganymede and Nuwen MinGW

  • Readers who viewed this page, also viewed:


    1 Comment »

    1. [...] Boost Filesystem library allows us to write portable code to access files and directories from a C++ program without using the operating system specific system/library calls. I have written about the Boost family of libraries in an earlier post, and have posted the procedure to install and get started with the Boost libraries on various OS distributions here. In this post, I will be talking about one of the popular Boost libraries – the Filesystem library. Lets first consider how a C++ program that needs to check for the existence of a file might look like: [...]

      Quote

      Pingback by Every Flavour Beans » Boost Filesystem Library: Writing Portable C++ Programs to Acess The Filesystem — May 10, 2006 @ 5:41 pm

    RSS feed for comments on this post. TrackBack URI

    Leave a comment

    Subscribe without commenting


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost