Languages :: General :: Language and style |
|||
| By: trican |
Date: 29/07/2003 00:00:00 |
Points: 50 | Status: Answered Quality : Excellent |
|
I'm about to start a medium sized embedded project, my choice of language boils down to C or C++. My options i think are the following: C++ classes/methods/etc C++ code in a C like non-OOP manner C straight forward usual functions, etc Will my choice of language have an effect on: a) the number of cycles/instructions/speed of my final code (granted i expect that will be application dependant to a degree) b) Code density c) Efficient memory usage My perference would be C++ but perhaps its not the most efficient for a constrained platform like a low end ARM development environment? any thoughts would be appreicated |
|||
| By: fibdev | Date: 29/07/2003 21:11:00 | Type : Comment |
|
| So, if i understand you ... when you say: "C++ code in a C like non-OOP manner" do you mean no MFC (windows) or do you mean no objects? No matter what you're doing, OOP will offer you faster, memory friendly applications. Unless I'm way off on what your needs are, I would suggest using the newest compiler available. My answer is C++ Good luck with your project :) |
|||
| By: trican | Date: 29/07/2003 21:21:00 | Type : Comment |
|
| "...do you mean no MFC (windows) or do you mean no objects? ..." in this context i mean both - they're certainly wont be any windowing . what i meant here was really using C++ as if it was just C, so no classes or anything like that. I've got a pretty good C & C++ compiler comes with the ARM developer suite. I *thought* i read/heard someplace at *some point* that OOP methodology added alot of extra baggage to code size and also execution speed????? thus the basis of my question. Maybe not the case with new compilers though???? |
|||
| By: fibdev | Date: 29/07/2003 21:30:00 | Type : Comment |
|
| Honestly, I probably had no business commenting here. :) My knowlage of C is limited to M$ Visual Studio.net and what I've read in related books. Since I do most of my programming in Delphi, then I would have to say you are probably correct. I guess I would write a little code and compile it with a c and a c++ compiler and see how it turns out. |
|||
| By: trican | Date: 29/07/2003 22:04:00 | Type : Comment |
|
| i'm not claiming to be any expert here either! all comments welcome and very much appreciated! thing about wrinting a little code and testing it Fibdev, is that i *think* it'd need a fairly sizeable chunk to really stress/show whats good and whats bad - but trying to avoid writing a massive chunk of code twice. gut feeling is both would offer similar performance with general arithmetic type operations, just curious how the memory management would differ - now that said i'm no expert in memory management either :-( |
|||
| By: grg99 | Date: 29/07/2003 23:19:00 | Type : Assist |
|
| IT ALL DEPENDS ! If your application and you both fit naturally into a OO mode, then OO is the way to go. You get all the benefits of code reuse, yadda, yadda, yadda. If your app and/or you dont OO well, then you'll be carrying around a lot of OO overhead that isnt getting used or is getting misused. This happens a *lot* Another downside is you will be tempted to over-OO things. I've seen what should be 50 lines of code grow to 4 or 5 nested levels of objects and over 2000 lines of mostly dead or glue code ! While if you go with straight C, you won't be tempted to use too many objects or levels of abstraction, but you may end up with the typical pot of spaghetti code. Your decision! |
|||
| By: trican | Date: 29/07/2003 23:43:00 | Type : Comment |
|
| grg99 - another good post. I think thats the answer i was looking for :-) any chance you could elaborate on : "If your app and/or you dont OO well, then you'll be carrying around a lot of OO overhead that isnt getting used or is getting misused" |
|||
| By: VGR | Date: 30/07/2003 00:30:00 | Type : Answer |
|
| use standard modular coding, using the most optimized compiler you got. If it's C++, too bad, use C++, at least it has strong typing... Avoid C at all costs. Too bad you don't have a top-class Pascal compiler like Turbo, Delphi; Kylix etc :D |
|||
| By: mlmcc | Date: 01/08/2003 23:48:00 | Type : Comment |
|
| Agree with VGR. The lack of strong typing in C may make future enhancement (which will be numerous) difficult. Also as your skills increase and the user's requirements expand, you may find that O-O makes more sense. A good optimizing compiler should minimize the O-O overhead. mlmcc |
|||
| By: trican | Date: 01/08/2003 23:55:00 | Type : Comment |
|
| thanks guys for all the guidance - I'll like to award the point to multiple people (grg99 & VGR) how do I do that? |
|||
| By: VGR | Date: 01/08/2003 23:57:00 | Type : Comment |
|
| "split answer" |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








