Hacker News new | ask | show | jobs
by srcmap 3066 days ago
I used C++ for embedded CPU 68332 (25 MHz CPU) with 4MB of SRAM in ~1996 for DNA sequencer machine.

~100 + classes, single inheritance, 1,2, 3 Axis motor controls, CCD Camera, Laser, serial com channel, scripting engines, etc.

No template, no virtual functions. Worked very well at that time.

The compiler setup at that time is AT&T cfront generate C from C++ code ran in Mac and embedded C cross compiler generated the target code.

The classes are shared within company for different machines (biotech robots) to maximize code reuse.

3 comments

Very interesting, thanks.

I got introduced to C++ via Turbo C++ 1.0 for MS-DOS, in 1993.

So if it was good enough for 640 KB max, with 64KB executables, it shouldn't be an issue in most micro-controllers, but the biggest issue is the existing dev culture.

Forgot to mention couple other design decisions:

  No new, delete operators in any C++ code. 
  ISR code was also in C++.

  All objects are statically allocated - with 4MB of SRAM, one can easily see why.   It allows tightly control memory usage by the developer. 

  All regression tests are automated.   There were test scripts for all functional HW/SW components.  Found one bug triggered  in 24.9 days time frame (31 bit timer counter wrap around for 10 milliseconds timer call) - from that point on - all firmware release pass 3 months continuous test on multiple systems before release.  


  Agree with your point: Dev culture matter a lot.   This was a mac (powerpc mac) base dev house.   C++ was the big thing in the SW (Mac) side of the dev team.    


  In my career, I worked on  15+ projects - most were embedded system projects.   Only two projects are C++.   The other project only small subset is C++.   On this project - 90% of code base running in target are C++ and full OO design and 80% of the classes reuse from other projects.
Thanks for sharing.

I eventually moved into Java/.NET stacks, but still follow on C++, as my to go tool when they need some unmanaged help.

Very interesting. Was the build environment all inside MPW?
I don't remember. Long time ago.... Likely just steps inside makefile.

Not really a big fan of the Mac at that time - It was before Steve Jobs came back and merge the OS with Next? The Mac was very unstable. I remember it crash 3-5 times a day for my daily tasks - editing, cross compile.

The C++ you wrote in 1996 is basically a different language from the C++ that you're encouraged to write today.
> The C++ you wrote in 1996 is basically a different language from the C++ that you're encouraged to write today.

We can differentiate between (a) what the language spec says, and (b) what various individuals advocate.

The code we write is generally constrained by (a), but we can usually substitute our own best judgment for (b).*

* Except when the people mentioned in group (b) have sway over the C++ standard.

Sounds like a sweet spot kind of project for C++.