Embedded Systems Software, Computer Networking and Geeky Fun

nerd1951.com

February 27, 2007

Quick Cannonball Update

Filed under: News, Projects, Cannonball — harvey.sugar @ 2:42 pm

I’ve been running benchmarks that compare the run time of state machines implemented as the State Design Pattern vs. a switch statement implementation and a function table implementation. So far the results have been inconsistant and I am debugging the benchmark code and trying to interpret the results. The final results and the bench mark code should be posted in the next few days.

• • •
 

Why C++ needs a standard threading library

Filed under: Rants — harvey.sugar @ 2:41 pm

I’ve read a few negative comments lately on the work being done by the C++ Standards Committee in the area of multi-threading. Some of the complaints include that “they are trying to turn C++ into Java” or that “threading is OS-specific and therefore should not be part of the language.”

One comment that I really didn’t understand is that “C++ should not include threading if it does not include garbage collection.” I’ve been writing multi-treaded/multi-tasking code for years and have done just fine managing memory myself, thank you.

There are plenty of precedants for supporting multiple threads of execution in programming languages. Back when the Pascal programming language was popular, I wrote some embedded systems code in Concurrent Pascal. Concurrent Pascal was never a main stream language but it did influence Modula-2 and the Ada programming language which is used widely for mission-critical systems. Java, of course, includes thread support in the langauge.

But why should C++ include support for threads? I think the single compelling reason is the implementation of the C++ Standard Library. The Standard Library includes many data structures that require critical sections in order to be thread safe. If there is no standard for threading; specifically defining critical sections (or Mutex) then the Standard Library must be customized for every operating system. This makes the Standard Library less reliable and opens the Pandora’s Box of subtle behavior differences accross implementations. So we need a standard for thread support in C++ in order to have a truly standard library at all in a multi-threaded environment.

• • •
 

February 23, 2007

Was the Universe written in LISP?

Filed under: Geeky Fun — harvey.sugar @ 4:05 pm

It’s rare to find a really funny tech comic that hits the mark and hasn’t been done by Dilbert.  I think this one is great!  It’s amazing how much stuff has been hacked together using PERL (or C) and works so well.  I think this explains why Quantum Mechanics and General Relativity don’t fit together cleanly.

Was the Universe written in LISP?

This comic is from http://xkcd.com/ (this image is licensed under the Creative Commons License which says it’s alright to share this image but no sell it)

• • •
 

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.

• • •
 

February 13, 2007

Cannonball Update: Behind the scenes

Filed under: News, Cannonball — harvey.sugar @ 11:59 am

It’s been very quiet around here on nerd1951.com but that doesn’t mean that nothing is going on. I’ve been hard at work behind the scenes; coding performance tests for the various software components that I will need to implement Cannonball.

I started working with the FIFO queues but I still have a lot of work to do before I’ll have any data to report. There are so many implementation options that performance testing the FIFO queues is a pretty big job. In the mean time I’ve started testing the “abstraction costs” of using the State Pattern (see Design Patterns) vs. the traditional state machine implementations in C using case statements or arrays of functions. I started on this test because I already have source code for these implementations. I just needed to strip out some extra stuff so that I’m only measuring the difference in the state machine implementations and not any extra code.

So what is “abstractions costs?” Abstraction costs are the additional resources, memory space and instruction cycles, required to implement a piece of software at a higher level of abstraction. C++ is designed to allow us to consciously make the tradeoff between abstraction and performance but we need to understand what the abstraction costs are in order to make an informed decision.

The other thing slowing down the FIFO Queue evaluation is that like most embedded systems C++ programmers I haven’t paid much attention to templates up until recently.  I found that the coverage of templates in Stroustrup’s The C++ Programming Language did not include all the techniques used by Alexandrescu in Modern C++ Design so I just picked up a copy of C++ Templates: The Complete Guide to dig deeper into programming with C++ templates.

Templates have gotten a bad rap in the embedded systems community. Most embedded system programmers perceive C++ Templates as an unnecessary complexity. The other problem is that until recently many cross-compilers, used by embedded systems programmers, have not done a good job of supporting templates or the C++ standard library. Now days a lot of embedded systems development is done using the GNU Gcc compiler which does a good job of supporting templates.

• • •
 

February 5, 2007

Why I’m living car free

Filed under: News, Rants — harvey.sugar @ 12:29 pm

I’ve mentioned a few times that I’m experimenting with living car free. After a year of doing this I’ve decided the experiment was a success and I’ll continue to live car free more-or-less permanently.

Why? Global warming - that’s it. As someone with a background in science, I’ve read the evidence and decided that I, personally should do what I can. OK, I’m not entirely car free. I use a car once or twice a week to do shopping or run errands but my daily commute and most of my shopping and social life are done via bus, subway or walking. I’m not trying to be some kind of eco-evangelist and I’m not telling you to give up your car. I’m just saying that this is my indvidual contribution to solving the problem.

If you’re not quite sure about global warming, check out what the Chicago Tribune has to say about it: New tack on global warming. Now the Chicago Tribune is not some lefty eco-utopian publication so now the mainstream media seems to accept the evidence too.

As engineers, we all have a unique opportunity to contribute solutions. Most of our carbon emmisions come from transportation and generating electricity. We should be at the forefront of developing energy saving technologies so that we don’t have to make drastic life-style changes to solve this problem.

• • •
 

February 4, 2007

IT Professionals, Software Engineers and Electrical Engineers

Filed under: News, Rants — harvey.sugar @ 9:34 am

I don’t consider myself an “IT Professional” but the press, the IEEE Computer Society, and the ACM seem to have forgotten that not every software engineer or computer programmer works with “Enterprise Applications.” Almost every article I read about computer professionals lumps us all in the same box. I’ve read articles lamenting that we are not outwardly-focused or that we do not have enough business knowledge. Recently I’ve read that the ACM leadership is advocating adding more business oriented classes to engineering education. I believe that this is due to some serious communication gaps between business, the technical community, and higher education.

First of all as an engineer it’s not my job to identify business solutions so much as implement them. What happened to the role of marketing and management in this function? I think that there is often an inability in business to articulate business problems that require IT solutions and communicate these problems to the technical staff. So rather than look for managers that have good communications skills, management blames the IT staff for not understanding business problems.

Another large part of the problem is higher education. Computer Science, Electrical Engineering, and Information Systems Management are three different but overlapping disciplines.

What most managers are looking for are graduates of an Information Systems Management program. This program should be part of the business school and includes a basic education in business management with a concentration in enterprise application development. Computer science classes in database management systems, Java programming, and data communications should be included but are only part of the program. These programs teach both the business skills and technical skills that most managers are looking for.

In the last few years we have seen the rise of Computer Engineering programs in many technical colleges and universities. These programs usually consist of a basic education in electrical engineering and some computer science. I believe these programs should be aimed at training digital designers, systems programmers and embedded systems engineers. These programs should not be teaching web development or database management systems. The Computer Engineering programs do not teach the software engineering or management skills required for large enterprise application development.

Computer Science should be training the hard-core software engineers and programmers needed to implement complex software systems such as the operating systems, network software, and database management systems that enterprise applications are built on. The students should receive a good education in the theory behind software engineering and the best practices for developing complex software. These programs should not be watered down by teaching business and marketing classes.

If an engineer or computer programmer wants to take on more of a marketing or managment role, that’s what MBAs are for.

• • •