    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Reviews</title>
        <link>https://members.accu.org/index.php/journals/2782</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">CVu Journal Vol 32, #2 - May 2020 + Programming Topics</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c410/">322</a>
                    (9)
<br />

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c65/">Programming</a>
                    (877)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c410-65/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c410+65/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Reviews</h1>
<p><strong>Author:</strong>&nbsp;Bob Schmidt</p>
<p>
<strong>Date:</strong> 01 May 2020 17:29:10 +01:00 or Fri, 01 May 2020 17:29:10 +01:00</p>
<p><strong>Summary:</strong>&nbsp;The latest roundup of reviews.</p>
<p><strong>Body:</strong>&nbsp;<p class="EditorIntro">We are always happy to receive reviews of anything that may be of use, or of interest, to software developers. The emphasis will tend to be on technical books, but we are also interested in less-technical works â€“ for example the humanities or fiction â€“ and in media other than traditional print books.</p>

<p class="EditorIntro">Do you know of something you think deserves â€“ or does not deserve â€“ a wider audience? Share it here. We're keen to highlight differing opinions on the same work, so if you disagree with a review here do send in your own! Contact Ian Bruntlett at reviews@accu.org.</p>

<h2>The Rust Programming Language</h2>

<p><img src="/content/images/journals/cvu32-2/Reviews/TheRustProgrammingLanguage.png"/></p>

<p><strong>By Steve Klabnik and Carol Nichols with contributions from the Rust community, published by No Starch Press (2018), 511 pages, ISBN: 978-1-59327-828-1</strong></p>

<p><strong>Reviewed by Daniel James</strong></p>

<p><i>Note: The cover illustration here shows the 2019 edition. ISBN: 978-1-718500440. This review applies equally to both print editions and to the online book.</i></p>

<p>This is the official book on Rust. Itâ€™s available free online (<a href="doc.rust-lang.org/book">doc.rust-lang.org/book</a>) and also as a paperback book. I read the dead-tree version but referred to the online version while playing with code, so this review is based on both. The online version has the advantage of being more up-to-date, but I didnâ€™t find many differences between the two. This was the first book on Rust Iâ€™d read, so it was mostly new material, though I had known of Rustâ€™s goal of eliminating certain classes of bugs by catching common errors at compile time.</p>

<p>The book opens with instructions for installation of the compiler and its associated tools, and illustrates the use of cargo â€“ the package-manager-cum-build-system â€“ by taking the reader through the process of writing a simple command-line number-guessing game. Cargo is a powerful part of the Rust environment, so the treatment here is useful. The programming exercise gives a flavour of the Rust language, but in doing so it uses (without fully explaining) some of the key language elements that are not described until later in the book, which I found unhelpful.</p>

<p>There follows some description of Rustâ€™s basic data types and flow control mechanisms before the book moves on to one of the supposedly â€˜difficultâ€™ areas of Rust: ownership. The concept of ownership itself is neither new nor particularly difficult, but Rustâ€™s tracking of ownership of memory is a key part of its correctness checking and the language imposes rules preventing, in particular, the sharing of mutable state. The book attempts to explain these rules and the concepts behind them, but to my mind makes fairly heavy weather of it. The reader is led through a series of examples of code that doesnâ€™t compile before the â€“ actually quite simple â€“ rules for taking and for borrowing resources are eventually spelt out. The authors take this opportunity to explain the sorts of error messages that the compiler may generate when the rules are broken, which hardly seems necessary as the Rust compiler gives quite clear, concise, errors; I think itâ€™s something the reader could have been left discover through trial and error.</p>

<p>Moving on through a description of Rustâ€™s approach to struct and tuple datatypes â€“ which could probably, with benefit, have been lumped together with the earlier section on basic data types â€“ we come to a short chapter on Rustâ€™s enum types and an introduction to matching. Rustâ€™s enums are not simple numbers, like those in (say) C, but are sophisticated discriminated union types. Enums are everywhere in Rust and they deserve to be covered earlier and in more detail. Matching, in Rust, is similar to that of a functional language like Haskell. I felt that this, too, deserved a chapter of its own, early on, with some real-world examples rather than the trivial ones presented here; instead there is an introduction to matching here, and a further chapter near the end of the book.</p>

<p>Next weâ€™re led through Rustâ€™s module system and collection types â€“ concentrating here on string types and the issues caused by the fact that Rustâ€™s strings are Unicode stored in UTF-8 â€“ after which comes â€˜Error Handlingâ€™. Rust is, unsurprisingly, very big on handling of errors, and weâ€™ve had sneak previews of some of the material here in earlier chapters. I would have preferred to have had a fuller description up-front.</p>

<p>Next comes coverage of Rustâ€™s type traits, generic types, and lifetimes â€“ all in the same chapter. Lifetimes are another of the notoriously â€˜difficultâ€™ areas of the language: the idea is simple in concept â€“ the compiler needs to know the lifetimes of references in order to enforce its checking for dangling pointers, and often it needs some help from the programmer. This means that the language includes a special syntax for describing lifetimes and the programmer has to understand it, and when to use it. This is pretty important stuff in Rust and, to my mind, deserves more prominent treatment, earlier in the book. Traits and generics are important too, of course, but theyâ€™re not related to lifetimes and not fundamental to Rustâ€™s primary goal of catching errors at compile time, and could have been treated later.</p>

<p>After a section on Rustâ€™s automated testing facilities the reader is led through an exercise in writing a grep-like command-line tool before being introduced to closures and iterators. This is followed by additional coverage of the cargo tool and Rustâ€™s online package repository crates.io before the reader is treated to Rustâ€™s take on smart pointers. The discussion of smart pointers and how they fit into Rustâ€™s compile-time correctness checking scheme is important and deserves to have been covered earlier in the book (but after enums and lifetimes, upon which it depends).</p>

<p>There then follows a chapter on â€˜Fearless Concurrencyâ€™, which explains why Rustâ€™s refusal to allow shared access to writable state leads naturally to safe threading, and one on Rustâ€™s Object-Oriented features (traits again) and the fuller treatment of patterns and matching that weâ€™ve been looking forward to for the last 12 chapters.</p>

<p>Finally there is a section on advanced features, which includes a discussion of â€˜unsafeâ€™ Rust code, which is not guaranteed by the Rust compiler to be correct (this includes code written in C or another alien language), followed by one last worked example in which a multi-threaded web server is coded in Rust. The book ends with some appendices, the last of which contains a brief description of Rustâ€™s macro language.</p>

<p>I didnâ€™t hate this book â€“ it was an interesting read and I learned a lot about Rust â€“ but youâ€™ve probably gathered that I didnâ€™t entirely like it, either. I found the order in which language features were presented to be illogical â€“ the reader is forever being asked to take a feature from a future chapter on trust while working through an example â€“ and I felt that there was a lack of meaningful examples. Although the introduction states that the reader is expected to know another language it goes on to explain a number of quite basic programming concepts while glossing over several things that are peculiar to Rust and should have been covered in more depth. There are diagrams to show the layout in memory of Rustâ€™s strings, for example, even though theyâ€™re pretty unsurprising, but no diagrams showing the layout of the smart pointer types or enums with data fields about which I had wondered while reading their descriptions. At times the book left me with more questions than it answered. The index, by the way, is terrible. I referred to it several times, and never found an entry for the thing I was trying to look up.</p>

<p>I felt, at the end, that I could read Rust code, but I wasnâ€™t confident that I knew how to write it. I had no feeling for the idioms of the language â€“ perhaps in part because of the bookâ€™s habit of introducing each topic by showing code that doesnâ€™t work and then fixing it.</p>

<p>That said: the free online version of the book is certainly accessible and economical, and although it wasnâ€™t my cup of tea, but it may be yours.</p>

<h2>Programming Rust</h2>

<p><img src="/content/images/journals/cvu32-2/Reviews/ProgrammingRust.jpg"/></p>

<p><strong>By Jim Blandy and Jason Orendorff, published by Oâ€™Reilly (2018), 598 pages, ISBN: 978-1-491-92728-1</strong></p>

<p><strong>Reviewed by Daniel James</strong></p>

<p>Recommended.</p>

<p>I read this book (PR) right after <em>The Rust Programming Language</em> (TRPL). Please be aware that I wasnâ€™t approaching PR with the same fresh innocence as I had TRPL, and although I have tried not to allow this to colour my review, I am not sure that I have succeeded completely.</p>

<p>This book begins, appropriately enough with a short chapter entitled â€˜Why Rust?â€™. As expected, this stresses Rustâ€™s emphasis on type-safety. Less expected was the categorization of Rust as specifically a systems programming language â€“ Iâ€™d view it as being just as suitable for applications work. The point being made is that efficient close-to-the-metal languages like C and C++ that are typically used for systems work are significantly less typesafe than â€˜softerâ€™ languages like Python. As a C++ programmer, I found the comparison rankled, but the authors do have a point.</p>

<p>The second chapter provides a whistle-stop tour of Rust, touching on a great many language features without really explaining any. This is exactly what I complained about in TRPL, but that doesnâ€™t seem to matter here: the presentation makes it clear that the tour is merely a preview to whet the readersâ€™ appetites â€“ like a trailer in the cinema. Itâ€™s a flourish of special effects and weâ€™re not supposed to be able to deduce the whole plot from it.</p>

<p>Chapter 3 begins the description of Rust in earnest. The basic data types are discussed, with comments on their acceptable values and ranges. The detail here seems more complete and better arranged than in TRPL and itâ€™s all easy reading. Tuples, arrays, vectors, strings and slices are all introduced here, though not structs or (sadly) enums which are, as in TRPL, left until far too late.</p>

<p>The next couple of chapters discuss ownership (along with moving/taking and borrowing) and references. Lifetimes are introduced here, too, almost incidentally. These are the two â€˜difficultâ€™ topics, where Rustâ€™s strictness causes most problems for newcomers, and the treatment here is fairly painless but perhaps underplays their importance. Rustâ€™s smart pointer types <code>Box</code> and <code>Rc</code> are also discussed here.</p>

<p>Chapter 6 is entitled â€˜Expressionsâ€™, but is actually an introduction to most of the statement types that are still to be introduced. This is not unreasonable as Rust is an expression-oriented language and most statements can be expressions. Functions are introduced, here, in passing, and thereâ€™s enough of an overview of matching to allow <code>if</code> and <code>while</code> to be covered sensibly.</p>

<p>Chapter 7 deals with error handling. As Rust handles errors using <code>Result</code> values that are actually enums, it seems odd to talk about errors before explaining in detail what an enum is. The description here is clear enough, I think, but could have been clearer had the authors simply been able to say â€˜<code>Result</code> is an <code>enum</code> typeâ€™ and had the reader already known what an enum was.</p>

<p>Chapter 8 discusses modules in Rust, and introduces Rustâ€™s notion of a crate (or external library). Crates are expected to contain their own tests and documentation, so unit tests and document comments are covered here, too, as are dependencies and the role played by the cargo tool in managing them.</p>

<p>Chapter 9 discusses structs and introduces methods and derived traits. Traits were introduced briefly in the tour in chapter 2, but havenâ€™t been covered in any detail, so the discussion of derived traits really demands a little more explanation than is here, but what is here is clear enough. We also touch here on Rustâ€™s generic types.</p>

<p>Chapter 10 brings the long-awaited discussion of enums and of matching. The discussion of enums is thorough and includes a description of how the compiler arranges enum objects, whose fields may be of different sizes, in memory. The discussion of matching might have given more examples of matching of patterns against enum types â€¦ but by now weâ€™ve become so familiar with seeing matches against <code>Result</code> and <code>Option</code> types, introduced ahead of time, that there isnâ€™t much new to tell.</p>

<p>Chapter 11 brings a discussion of Rustâ€™s traits, and how they are used to add functionality to types, and to implement generic behaviour. This discussion is carried on in the next couple of chapters in which operator overloading (which depends on traits) and utility traits are discussed. Utility traits include things like <code>Copy</code> and <code>Clone</code> (among others) that are used to add system-defined behaviours to user-defined types so that the compiler can handle them efficiently. Their treatment here is thorough and well-explained.</p>

<p>Chapters follow on closures, iterators, collections, strings and text, and input and output. The last touches on networking while noting that it is beyond the scope of the book. Then comes a chapter on concurrency â€“ one of the longest in the book â€“ which shows how Rustâ€™s type-safety prevents the sharing of mutable data between threads, and shows how communication between threads can nevertheless be safely achieved.</p>

<p>A chapter on macros gives a good overview of writing macros for Rust with a number of practical examples, and finally a chapter on unsafe code brings the book to a close.</p>

<p>PR has some 20% more pages than TRPL, and feels as though it contains about twice as much information with much clearer explanations â€“ though of course it could just be that the material seemed clearer because the subject matter wasnâ€™t all new to me, in which case TRPL must take some of the credit! I was annoyed by a few snide digs at C++ for being less safe than Rust â€“ yes, of course a Rust <code>enum</code> is more typesafe than a C <code>union</code> â€¦ but you donâ€™t use a C union in C++ you use something like <code>std::variant</code> â€“ those things aside the book is readable and informative. I felt that the ordering of material wasnâ€™t optimal â€“ in particular: Rustâ€™s enum is pervasive and needs to be explained early on â€“ but for the most part the book doesnâ€™t use features that havenâ€™t yet been covered, so there are few surprises. The index isnâ€™t great, but I did find most things that I tried to look up, so itâ€™s better than many.</p>

<h2>C++ Templates The Compete Guide, Second Edition</h2>

<p><img src="/content/images/journals/cvu32-2/Reviews/CppTemplates.jpg"/></p>

<p><strong>By David Vandevoorde, Nicolai M Josuttis, Douglas Gregor, published by Pearson Addison-Wesley (2018), 770 pages, <a href="http://www.tmplbook.com/">http://www.tmplbook.com/</a></strong></p>

<p><strong>Reviewed by Paul Floyd</strong></p>

<p>Recommended for advanced users. I would suggest that beginners start with something else.</p>

<p>I read the first edition of this book sometime back in 2003 (reviewed here <a href="https://accu.org/index.php?module=bookreviews&amp;func=search&amp;rid=506)">https://accu.org/index.php?module=bookreviews&amp;func=search&amp;rid=506)</a>. A great deal has changed in the 15 years between the two editions â€“ 3 new revisions of the C++ standard in particular. This shows up in the page count, and even visibly with the second edition being about 2cm thicker.</p>

<p>This being an â€˜upgradeâ€™ read, I thought that I would just be able to skim over the â€˜new bitsâ€™ in just a few days. Boy, was I wide of the markâ€¦ several weeks more like it. Even though, when I look at the two chapter listings, clearly the two books have the same structure, my feeling was that the second edition was an entirely different experience. In part this is due to the large amount of extra material, and also in part a change in my perspective. Back then I thought that I knew a bit about template programming. Now Iâ€™m sure that I know little about it.</p>

<p>The book covers templates in depth for all C++ versions up to and including C++17, plus a bit on additions expected a bit in C++20, especially concepts. I wonâ€™t list the chapters (there are 28 of them, plus 5 appendices). There are 3 parts to the book, â€˜Basicsâ€™, â€˜Templates in Depthâ€™ and â€˜Templates and Designâ€™. I did laugh (out loud even) at the start of part 2 when I read that part 1 (â€˜Basicsâ€™) â€œ<em>is sufficient to answer most questions that may arise in everyday C++</em>â€. I doubt that your average C++ programmerâ€™s needs get much past chapter 2 and perhaps chapter 9 (covering instantiation and error messages).</p>

<p>As you would expect, everything regarding templates is covered. Function and Class Templates, Nontype Parameters, much about traits/policies and meta programming. Thereâ€™s also a lot on overloading and name lookup. Thereâ€™s considerable coverage of how templates interact with language features, which is very important if you want to understand which types will be used to instantiate your template functions (and to a lesser extent classes). There is some nitty-gritty, but this is no â€˜C++ Templates in 7 Daysâ€™. The last few chapters cover a few concrete examples such as Tuple and Variant template classes.</p>

<p>The book contains a lot of examples in the form of snippets, often in the form of a few definitions followed a list of 4 or 5 example uses with comments like â€œ// OK T deduced as long intâ€ or â€œ// ERRORâ€. I found that this bogged down the compiler in my head, and I would often spend 5 or 10 minutes trying to think through why a certain piece of code would resolve to which types. Perhaps I should have skimmed through quickly a first reading and then a more thorough second pass.</p>

<p>I donâ€™t know what sort of reader will benefit from this book. It is neither a tutorial/cookbook nor a straight reference book. I suppose that, as it says on the cover, â€˜guideâ€™ is the best way to describe it. Compiler writers (there are a few sections on parsing) and template library writers will want a copy. After that, if you already have copies of Stroustrup, Meyers and Josuttis then you will also want to get this one.</p>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
