Category Archives: Tech Book

Tech Book: Effective Python, Brett Slatkin

I’ve been learning Python for a few months and am starting to use it at work, so I thought it was about time to read a book about Python. This book has been excellent. No only does it follow format of the time-honoured ‘Effective’ series pioneered by Scott Meyers, it also features practical, useful code examples. In particular, his JsonMixin class was immediately relevant to some work I’ve been doing to generically serialise to/from JSON documents – see Item 26 “Use Multiple Inheritance Only for Mix-In Utility Classes”.

The author has also taken the time to record hours of video lessons for Safari Online subscribers, so you can view additional material as he works through the items in the book.

Leave a comment

Filed under Python, Tech Book

Tech Book: Algorithms in a Nutshell, Heineman, Pollice & Selkow

algorithmsinanutshellI really enjoyed reading this book, probably the best endorsement I can give for a technical book. The authors introduced the common computer science algorithms that you would expect in a good desktop reference, giving each a block of pseudo code, some analysis of algorithmic complexity and implementation trade-offs, and finally a proper implementation in a standard programming language (usually Java). The later chapters cover slightly more advanced techniques, typically with a practical example. My favourite was their randomised algorithm for estimating a solution to the famous “n-queens” problem (developed by Knuth in 1975).
Five Stars

Leave a comment

Filed under Tech Book

Tech Book: Effective Modern C++, Scott Meyers

EffectiveModernC++When Scott Meyers announced his retirement from C++ duties, I thought I’d get a copy of his latest book. There’s plenty in it to interest even seasoned C++ developers – as always, Scott’s insight and in-depth examples are worth studying. I’ve tried out most of the C++11 features, but still learnt a lot working through this book.

Uniform Initialisation and Auto
Meyers points out that compared to parentheses or just plain “=”, braced initialisation can be used in the most contexts, avoids his famous “C++’s most vexing parse”, and will issue compiler errors if narrowing occurs. However, for types that can take a std::initialiser_list in their constructor, the compiler is required to favour std::initialiser_list over any other interpretation. That’s a deterrent to use of braced initialisation with types that have a std::initializer_list constructor – and also precludes using auto with braced initialisation.

auto x = { 4 }; // type of x is inferred to be std::initializer_list<int>!

How to use the new “= delete” idiom
Meyers recommends declaring deleted methods as public to get better error messages from compilers that check for accessibility before deleted status. He also points out that you can declare non-member functions as deleted (I’d only seen examples of copy-constructor/copy-assignment operator as deleted before).

Use of noexcept on move operations
This one is a classic example of a combination of language features having an unexpected effect. std::vector::push_back offers the strong exception guarantee. It can achieve this using any copy constructor and being sure not to change the original contents of the vector until any new elements or copies have been constructed. Hence, move constructors are only preferred if it is exception-safe to do so – which means they must be marked as noexcept (and if that isn’t appropriate, you just won’t get move semantics pushing instances of your type into a std::vector).

Recursion with constexpr
Having toyed with template meta-programming in the past, this use of constexpr appeals to me:

constexpr int pow( int b, int exp ) noexcept
{
    return (exp == 0 ? 1 : b * pow( b, exp-1 ));
}
constexpr auto eight = pow( 2, 3 );

void testConstExpr()
{
    std::cout << "2^3 = " << eight << "\n";
}

It’s much more succinct than the equivalent TMP version, and still performs the calculation at compile time.

Summary
In the past, I’ve recommended Effective C++ for developers who have little experience of the language and wish to improve their skills. I think this book is a bit too advanced for that, particularly given the chapters on template type deduction and decltype being in the first part of the book! So read this book if you’ve got a few years’ experience of C++ already, but look at Effective C++ (3rd Edition) to improve on the basics.

Four stars

Leave a comment

Filed under C++, C++ Code, Programming, Tech Book

Tech Book: Swift for the Really Impatient, Matt Henderson & Dave Wood

SI love the title of this book, the authors kept the content as concise as possible and showed that it really is possible to give a decent introduction to a programming language in just 156 pages (and less than 1cm). The book is quite practical you can read it cover-to-cover to pick up the features of the language, then you can use the handy code snippets as a quick reference guide (and the index is pretty good for this too, not always the case).

I bought a 2015 edition, the only downside being that this seems to be aimed at Xcode 6 and is now slightly out of date. With Swift being an evolving language, that’s to be expected – some readers might prefer to work with the electronic copy and remain up to date.

It’s also worth mentioning that, if your aim is to write a simple iOS app in Swift, you might be better off working through a tutorial and learning Swift that way, along with picking up tips and tricks for working with Xcode. See FoodTracker and To Do.
Five Stars

Leave a comment

Filed under Programming, Swift, Tech Book

Tech Book: 9 Algorithms that Changed the Future, John MacCormick

AlgorithmsThatChangedTheFutureThis excellent book introduces algorithms that are heavily used in daily life, yet are unknown to the general public. The author aims to introduce them without requiring advanced knowledge:

I assumed that the great algorithms would fall into two catagories. The first category would be algorithms with some simple yet clever trick at their core – a trick that could be explained without requiring any technical knowledge. The second category would be algorithms that depended so intimately on advanced computer science … Imagine my surprise and delight when I discovered that all the chosen algorithms fell into the second category!

The book is a fun read and despite knowing some of the details already, it helped to build my appreciation of the algorithms and their applications.

The algorithms covered are:

  • Search engine indexing
  • PageRank
  • Public key cryptography
  • Error-correcting codes
  • Pattern recognition
  • Data compression
  • Databases – reliability and consistency
  • Digital signatures

There’s also an excellent chapter on unsolvable problems, with a nod to Alan Turing.
20141005-142632.jpg

Leave a comment

Filed under Tech Book

Tech Book: Seven Databases in Seven Weeks

Seven Databases in Seven Weeks – a guide to modern databases and the nosql movement
I picked this book to learn about NOSQL which seems to be a current buzzword. I have experience writing SQL-based applications with Watcom and SQL Server, but the new database back-end choices are impressive and have neat ideas that can be generalised for other applications (e.g. resilience).

Leave a comment

Filed under Tech Book

Tech Book: Paradox, Jim Al-Khalili

paradox

Paradox – The Nine Greatest Enigmas in Science – Jim Al-Khalili
I’m enjoying the mixture of history and pop science – Al-Khalili explains physics as well as anyone.
FiveStars

Leave a comment

Filed under Tech Book