Embedded Systems Software, Computer Networking and Geeky Fun

nerd1951.com

February 15, 2007

Learning/Teaching C++ the way I learned Java

Filed under: News, Rants, Books — harvey.sugar @ 2:22 pm

My introduction to C++ was a week long in-house course for experienced C programmers back in 1990. The course started out by introducing class definitions, public, protected and private data. Then we quickly moved on to virtual functions, inheritance and polymorphism. This was pretty intense and a bit overwhelming for a bunch of C programmers whose only knowledge of classes and objects came from a quick read of Grady Booch’s Object-Oriented Analysis and Design with Applications. Classes and objects were purely theoretical constructs to us and our course used some pretty random examples. But this is the normal sequence for C++ instruction. Teach C then teach class definition, constructors and all the rest with very little motivation for using classes.

When I learned Java, the approach was quite different. We started using classes from Java’s vast array of class libraries from the start. Then we were taught how to define our own classes. We learned about inheritance and polymorphism through the use of container classes then we learned how to write class and interface hierarchies.

Now I find myself teaching a short course at work in C++ programming for experienced C programmers. I was delighted to find a book, Accelerated C++: Practical Programming by Example, which teaches C++ programming the way I learned Java programming. From the first chapter, the examples and problems use classes from the C++ Standard Library. Only after writing programs using real, useful classes do you learn how to create your own classes. I am convinced that this approach leads to a deeper understanding and appreciation of object oriented programming in C++ and the C++ Standard Library.

• • •
 

November 15, 2006

More Resources for Non-Designers

Filed under: Tools, Books — harvey.sugar @ 9:26 pm

I found The The Non-Designer’s Design Book so useful that I’ve just ordered The Non-Designer’s Web Book by the same author. Again, much of what makes well designed web pages applies to user interfaces in general.

Speaking of web page design check out useit.com, Jacob Nielsen’s website on web usability. He has a lot to say about usability and the web and backs up what he has to say with surveys of real users. I’ve learned alot from the articles on useit.com.

• • •
 

November 12, 2006

The Non-Designer’s Design Book

Filed under: Tools, Books — harvey.sugar @ 11:50 pm

I don’t usually review books on my BLOG.  I usually save that for amazon.com so that more people can have the benefit of my learned opinions ;).  In the case of The Non-Designer’s Design Book I’m making an exception because I don’t think many software engineers would seek out a book about layout design for printed matter such as posters or brochures. 

This book is an excellent reference for just presenting information for many kinds of media.  It is centered around four guiding principles; Contrast, Alignment, Repitition, and Proximity.  The book has chapters explaining each of these principles in detail and how they relate to each other.  The book is full of illustrations that make the ideas stick with you.

The author promises that after you read her book you will never look at a printed page the same way again.  I found that I can’t look at data presented on a computer screen the same.  This book is an easy read,  You could read it in a few hours and it will change the way you design user interfaces.

• • •
 

August 4, 2006

So Many Books - So Little Time

Filed under: News, Books — harvey.sugar @ 12:03 am

I have three new books sitting on my desk and it’s killing me that I don’t have the time to just sit down and read them.  I usually catch up on my reading on the bus but lately I’ve been alternating between the bus and riding my bicycle to work which cuts into my reading time.  I’m experimenting with living car-free for a year - don’t ask, it’s my own special form of insanity.

But back to the books.  First in the queue is Modern C++ Design: Generic Programming and Design Patterns Applied.  I originally picked up this book because I liked the Small-Object Allocator in Chapter 4.  Upon skimming the rest of the book, I was impressed that the book included an Appendix on multi-threading.  Modern C++ Design looks like an excellent source of ideas for implementing design patterns in C++.

The second book I picked up is Linux Network Architecture.  So much has changed since Stevens gave us a tour of the BSD protocol stack in The Implementation (TCP/IP Illustrated, Volume 2).  The Linux Networking Architecture is a good follow up to Stevens, describing the architecture at a useful level and not just regurgitating the source code.

Some reviewers have complained that the translation of this book from German was poorly done and made the book difficult to follow.  I did find some of the wording awkward at first but as I read the book either I got use to the phrasing or the translation got better.

Finally there is Network Algorithmics,: An Interdisciplinary Approach to Designing Fast Networked Devices (The Morgan Kaufmann Series in Networking).  This book is unique in its holistic approach to hardware and software optimization for fast networking.  Its other outstanding feature is that it discusses the differing requirements of routers and end nodes such as Web servers.

And, at some point I want to read some fiction!

• • •
 

May 19, 2006

Just the facts

Filed under: Rants, Books — Harvey @ 9:58 am

There was a time when many C programmers understood how the compiler mapped their code into machine language. Compilers were simpler then and the C programming language was a close model of how the underlying hardware operated. This knowledge led to techniques for hand optimizing C code for maximum performance.

Processors and compilers are much more sophisticated and complex today and most programmers do not have intimate knowledge of their compilers’ code generators. The old hand optimizing coding tricks have become little more than folklore and can actually degrade performance in some cases. Modern compilers perform optimizations that would be completely non-intuitive to human programmers. The compilers are doing a lot of work behind the scenes that we don’t see or understand.

This brings me to the use of C++ instead of C for embedded systems. Most embedded systems programmers feel that C++ is not suitable for embedded systems because of vague notions about processing overhead and extra storage requirements. C++ has the reputation for generating slow, bloated code. C++ does too much behind the scenes. In reality this is just folklore that is just as out of date as the hand optimizing tricks of the 1980s. Before you decide C++ is unsuitable you need some real facts.

So where can you find the facts? I would start with Stanley Lippman’s excellent book, Inside the C++ Object Model. The object model is the central feature that distinguishes the C++ programming language from C. This book digs into the guts of the C++ object implementation and will give you a good understanding of potential pitfalls that can cause performance and resource problems with C++. This is not just folklore. The book contains actual performance figures obtained from profiling real code.

Next I would check out  Scott Meyers’ books; Effective C++ and More Effective C++.  Scott’s books are filled with techniques for writing better C++ programs many of which are aimed at avoiding problems with code bloat and performance.

Finally, do some exploration on your own. I’ll have some numbers on code I’m writing posted soon but don’t take my word for it. Write some code in C and C++ and profile it yourself. Linux and most development environments have profilers and using them can yield some surprising results. Get the facts, as Sargent Joe Friday use to say “Just the facts.”

• • •