Home
Fractals
Tutorials
Books
My blog
My LinkedIn Profile

BOOKS i'm reading

Napoleon Hill Keys to Success: The 17 Principles of Personal Achievement, Napoleon Hill, ISBN: 978-0452272811
The 4-Hour Workweek: Escape 9-5, Live Anywhere, and Join the New Rich (Expanded and Updated), Timothy Ferriss, ISBN: 978-0307465351
The Fountainhead, Ayn Rand, ISBN: 0452273331
Web Hosting Canada

mailto:olivier@olivierlanglois.net

08/01/07

Permalink 10:13:31 pm, by lano1106, 126 words, 2862 views   English (CA)
Categories: Linux/UNIX

sed & awk

sed & awk, Dale Dougherty, Arnold Robbins, ISBN: 1565922255

I had to do some text processing and I wanted to learn sed & awk so I picked this book that is, to my knowledge, the only book completely dedicated to these tools. The chapter on 'advanced' sed programming is very scary because when using 'advanced' sed features, the syntax is cryptic. It is nice to know that these features are there but I want to stay away from them and perhaps use awk or perl for the tasks that would require those 'advanced' features. Still, when you stick with the 'basic' and 'intermediate' sed features, you can do cool things easily in shell scripts.

Overall, the book was not thrilling to read but it does a good job to teach you these text processing tools.

Permalink 09:49:22 pm, by lano1106, 231 words, 2932 views   English (CA)
Categories: C++, C++

Exceptional C++ Style: 40 New Engineering Puzzles, Programming Problems, and Solutions

Exceptional C++ Style: 40 New Engineering Puzzles, Programming Problems, and Solutions, Herb Sutter, ISBN: 0201760428

By having read the 3 books in the serie, I must say that this is my favorite because it has really answered a lot of small questions I had for a long time about several aspects of C++.

The only thing that I have disliked is that Mr. Sutter has contradicted himself with one of the advice that he was giving in the first book. The advice was to not write an assignment operator in terms of its copy constructor with the in place new operator and the explicit destructor and I did agree with the reasoning. Now in this book, it is written that is ok to use that idiom if and if and if and he goes for about a paragraph to describe the condition where it is ok to use the pattern. I can imagine that the author had to admit that there might be exceptional situation where it is ok to use that technique in a heated debate but my opinion is that out of context, he should not have mention that it might be ok to use that technique without devoting an entire item on that topic. It did just confuse me and I had to reread the item in the first book to convince me that there was effectively a contradiction between the 2 books and that it was not just my memory playing games with me.

07/31/07

Permalink 09:54:07 pm, by lano1106, 126 words, 2418 views   English (CA)
Categories: C++, C++

More Exceptional C++

More Exceptional C++, Herb Sutter, ISBN: 020170434X

Mr. Sutter's books biggest strength to my opinion is that they bring together a bunch of original advanced C++ topics that you cannot find anywhere else. This book has its share of very original content but I feel like the ratio original content vs topics that you can find in other books is lower in this book than with the other books of the serie. The most interesting section in this book in my opinion is the one on exception safety and the less original section is the one on generic programming and STL as you can find much of the information contained in this section in other books such as Effective STL from Scott Meyer or C++ Template from David Vandervoorde and Nicolai M. Josuttis.

Permalink 09:35:48 pm, by lano1106, 386 words, 4359 views   English (CA)
Categories: C++

How to efficiently add or update an item in a C++ STL map

In item 24 of the book Effective STL, Scott Meyers explains to be careful about using the overloaded subscript operator (std::map::operator[]) when efficiency is important. The reason behind this advice being that when that operator is used to refer to an item that is not yet in the container, it will insert a new pair in the map by using the default constructor of the value part and then usually an assignation will be performed on the value reference returned by the operator. For non-trivial constructors and assignment operators, this can result to unnecessary overhead.

He then proceeds to present a function called efficientAddOrUpdate() that calls std::map::lower_bound() then performs some tests on the returned iterator to make sure that it is not equal to end() iterator and if the key pointed by the iterator is equivalent to the key used with lower_bound(). If the test is successful, then the value pointed by the iterator is updated or else std::map::insert() is called with the std::map::lower_bound() returned iterator as hint for the insertion point.

Few days ago, I had to recreate the efficientAddOrUpdate() function without my copy of Efficient STL book available and I have being struggling for a good half an hour to an hour trying to recall the implementation details or find them back by doing searches on the Internet. I have finally come to the following realization by giving up searching the Internet and looking at the <map> header file source code:

Scott Meyers efficientAddOrUpdate() function code is almost identical to the operator[] member source code function minus minor modifications

Here is the source code operator[]:

mapped_type& operator[](const key_type& _Keyval)
{   
    // find element matching _Keyval or
    // insert with default mapped
    iterator _Where = this->lower_bound(_Keyval);
    if (_Where == this->end() || 
        this->comp(_Keyval, this->_Key(_Where._Mynode())))
    _Where = this->insert(_Where,
            value_type(_Keyval, mapped_type()));
    return ((*_Where).second);
}

and efficientAddOrUpdate() code derived from it would be:

iterator efficientAddOrUpdate(map &m,
         const key_type& _Keyval,const val_type& _Val)
{
    iterator _Where = m.lower_bound(_Keyval);
    if (_Where == m.end() ||
        m.key_comp()(_Keyval, _Where->first)))
    {
        return m.insert(_Where,value_type(_Keyval, _Val));
    }
    else
    {
        _Where->second = _Val;
        return _Where;
    }
}

07/30/07

Permalink 08:22:27 pm, by lano1106, 283 words, 1946 views   English (CA)
Categories: C++, C++

Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions

Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions, Herb Sutter, ISBN: 0201615622

This book presents advices more or less in the same format than books from the Effective C++ serie. What is similar is that topics are divided in 47 small items of few pages each. The difference is that the author first ask questions to the readers or propose exercises and encourage the reader to put down the book and to take the time to think about the problem and then come back to read his answer. This format is more or less original as I have seen something similar in Tom Cargill's C++ Programming Style book.

I have read this book pretty fast which is a good sign of my interest in a book but in the same time this book did not leave me, at first, a strong impression that will make me remember this reading for a long time. It is hard for me to say exactly why but I think that it is because most items focus on very small details of C++. Some of these problems are very hard and probably is an indication that the book targeted audience is advanced C++ users which is not a bad thing by itself but I was not convinced that mastering these small details actually has a high impact on someone programming skills.

It took few months to let the wisdom contained in this book to sink in and I have found myself many times, in my day to day programming, confronted to problems where the material of this book helped to make wise design decisions. So now, I think that this book is very valuable for anyone that has mastered the C++ programming language and is ready to master tougher C++ issues.

<< Previous Page :: Next Page >>

Olivier Langlois's blog

I want you to find in this blog informations about C++ programming that I had a hard time to find in the first place on the web.

< Previous | Next >

December 2024
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

Search

Custom Search

Misc

XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 1

powered by
b2evolution