Quickie Poll -- C vs. C++

I even had a FP accelerator board that came with a RMB-compatible

*compiler*. For the time, that one _flew_. IIRC it used some obscure Intel iapx432 or i860 floating point chip, not a 68881.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
ElectroOptical Innovations
55 Orchard Rd
Briarcliff Manor NY 10510
845-480-2058
hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs
Loading thread data ...

For small projects (as the OP asked) it is often very important how transparent the compilation process is. For small embedded targets, I nearly always read the generated assembly code to see that the result is satisfactory.

The more powerful abstractions are used, the less transparent the translation process is.

Properly used, C++ can at times produce nearly as good code as C, but it will be more tedious to tune the source. Also, the minimum run-time overhead is larger with most compilers.

--

Tauno Voipio
tauno voipio (at) iki fi
Reply to
Tauno Voipio

On Linux or Windows C++. STL and objects make life a lot easier. I looked into C++ for microcontrollers. IMHO C++ should be useful there as well. A lot of programmers emulate objects in C nowadays. Why not have the compiler deal with it and reduce the chance on bugs?

32

Depends on the project. Some of my projects need less than 1kB some need >500kB. In some cases the memory is limited. Clever coding can perform miracles.

I'd be happier to know how it was tested and with what optimisation setting it was compiled.

--
Failure does not prove something is impossible, failure simply
indicates you are not using the right tools...
nico@nctdevpuntnl (punt=.)
--------------------------------------------------------------
Reply to
Nico Coesel

I don't disagree with anything you've stated except perhaps the main point. There are just some projects that don't need the power, and thus the complexity, of C++. Simpler is better. Always.

--
Randy Yates                      % "She's sweet on Wagner-I think she'd die for
Beethoven.
Digital Signal Labs              %  She love the way Puccini lays down a tune,
and
mailto://yates@ieee.org          %  Verdi's always creepin' from her room." 
http://www.digitalsignallabs.com % "Rockaria", *A New World Record*, ELO
Reply to
Randy Yates
[snip C++ previous comments]

Very well stated.

A statement one frequently hears, that is misleading, is that one isn't doing true OO unless one uses inheritance, and in particular virtual functions, and therefore one is not utilizing the advantages of C++. This perspective is really only valid in certain very large software engineering projects. For the average engineer doing signal processing or communications, there is a large advantage to using the encapsulation and polymorphism aspects of C++, without even touching these "true OO" features.

C has weak encapsulation: a program is a flat set of function definitions and external variables. The "static" keyword can provide only one level of limited encapsulation. In C++, functions can be encapsulated within classes (e.g. they can be methods), and there are namespaces. There are the private/public feature of class membership; and you have the "friend" keyword, and while both of these are arguably blunt instruments, they are very useful and they are missing from C.

(All members of a "struct" in C are public, and while you can include function pointers -- messy -- you can't include functions.)

C has almost no polymorphism. In C++, there are templates, and there is generalized operator overloading.

The neat thing (for me) about C++ is that the above features allow you to organize your programs in a vastly better, and ultimately simpler fashion; yet it still maintains the model of separate compilation; it is still very efficient. You do not have to give up entirely, and go to an interpreted model, just to get OO-style programming language features.

Steve

Reply to
Steve Pope

But since C is a subset of C++, there's nothing preventing you from writing just as simple a program in C++.

If you're using some C++ feature that is not in C, you are doing so for a reason. In a not insignificant number of cases, the reason is that the C++ feature makes the program even simpler. (e.g. not having to use function pointers, having complex number already in the language standard, etc.)

Steve

Reply to
Steve Pope

That's (pretty much) true. However, there is more to it than just the syntax. The C compiler itself is simpler and I believe more robust, and error messages are easier to understand.

That is certainly possible. I still would jump on C for a simple project. I am much more familiar with it than C++, and it's simpler. Sometimes even having the ability to do something fancy can be a distraction, e.g., it gives you a choice you must decide.

--
Randy Yates                      % "How's life on earth? 
Digital Signal Labs              %  ... What is it worth?" 
mailto://yates@ieee.org          % 'Mission (A World Record)', 
http://www.digitalsignallabs.com % *A New World Record*, ELO
Reply to
Randy Yates

Op Wed, 25 Aug 2010 23:50:17 +0200 schreef Tim Wescott :

Depending on the task at hand: Korn shell, C, Java.

Shell is good for simple things on a high level, C allows better control over I/O and program flow, Java allows the same control but with much richer libraries.

I would describe myself as being competent. I find it comforting to know that until now I never did have to know the intricate details of both C and C++; just C is enough.

  1. Assuming you mean the size of its ALU.

16 kiB and up.

I would be happier knowing the quality of the code and the description of its interface. If I knew nothing other than the language, I would be happier knowing that somebody internal could debug it if necessary.

Yes.

Usually.

Yes, sympathetic hardware engineers do exist. But unfortunately they can be so enthusiastic about their design that it becomes hard to follow them.

--
Gemaakt met Opera's revolutionaire e-mailprogramma:  
http://www.opera.com/mail/
(remove the obvious prefix to reply by mail)
Reply to
Boudewijn Dijkstra

Could it have been the Weitek 1167(?)?

Reply to
JosephKK

Found it--Infotek. This is an announcement of the second version of the compiler. IEEE Computer Society News, February 1986.

Infotek Systems, BC204 Basic Compiler Compiler The BC 204 is compatible with HP 9000 Series 200/300 technical workstations and compiles Hewlett-Packard Basic version 4.0. Compiled programs operate with Infotek's FP 200 or FP 210 floating-point coprocessors and the HP 98635 floating-point coprocessor. Cost: $880. Infotek Systems, 1400 N. Baxter St., Anaheim, CA 92806; (714) 956-9300.

A company history is at

formatting link

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
ElectroOptical Innovations
55 Orchard Rd
Briarcliff Manor NY 10510
845-480-2058
hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

Found it--Infotek. This is an announcement of the second version of the compiler. IEEE Computer Society News, February 1986.

Infotek Systems, BC204 Basic Compiler Compiler The BC 204 is compatible with HP 9000 Series 200/300 technical workstations and compiles Hewlett-Packard Basic version 4.0. Compiled programs operate with Infotek's FP 200 or FP 210 floating-point coprocessors and the HP 98635 floating-point coprocessor. Cost: $880. Infotek Systems, 1400 N. Baxter St., Anaheim, CA 92806; (714) 956-9300.

A company history is at

formatting link

Foggy memory is clearing up: the first coprocessor board was a 432, but the second one was a 68881.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
ElectroOptical Innovations
55 Orchard Rd
Briarcliff Manor NY 10510
845-480-2058
hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.