Go to Post Oh, for the days of 30-page rulebooks! - EricH [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-11-2006, 16:47
♥♣♠♪'s Avatar
♥♣♠♪ ♥♣♠♪ is offline
DemiOmniGod
FRC #1546 (Chaos Inc.)
Team Role: Programmer
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Baldwin
Posts: 5
♥♣♠♪ will become famous soon enough
Re: C or C++

Quote:
Originally Posted by efoote868
Too bad its not so easy to describe #define, or any other preprocessors to them .
All you have to do is explain what compilation is and everything else should be easy.
__________________
Programming && English !mix

Our website
  #2   Spotlight this post!  
Unread 14-11-2006, 21:00
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: C or C++

I think most of us would agree that we would rather have the flexibility and added features of C++, particularly object oriented-ness.

The problem with C++ is that along with its added features comes added bloat and inefficiency. Unless the architecture and processing power were SUBSTANTIALLY and unnecessarily upgraded, all of the people who keep complaining that C is primitive would be complaining that their code wouldn't run if we upgraded to C++. Memory allocation/deallocation is no small task, especially when handled in software. C++ is good for PCs where functionality is a greater priority over efficiency and there is an abundance of computational power, but not so great for our application. In industry, C is not considered outdated, it is the standard in the world of embedded programming and for good reason. C is sleek and slim.

Heated seats, radios and air conditioning are good to have but race cars don't have them and do just fine without them. Our robots, like race cars are designed minimalistically. There is nothing on a FIRST robot that is not absolutely necessary and that goes for code too.

Any problem that can be solved in C++ can be solved in C. The solution may not be as coder friendly, but chances are it will be smaller and take fewer processor cycles to execute.
__________________
1139 Alumni

Last edited by Rickertsen2 : 14-11-2006 at 21:02.
  #3   Spotlight this post!  
Unread 14-11-2006, 22:43
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: C or C++

Quote:
Originally Posted by Rickertsen2
I think most of us would agree that we would rather have the flexibility and added features of C++, particularly object oriented-ness.
Why? What particular itch would be scratched by having OO in your robot-programming toolkit?
Quote:
Any problem that can be solved in C++ can be solved in C.
That's obviously true -- because the first implementation of a C++ compiler was as a preprocessor that produced straight C code. If you want to use C++ to program your robot, just get a copy of the old AT&T Cfront program.
  #4   Spotlight this post!  
Unread 14-11-2006, 23:09
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,562
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: C or C++

Quote:
Originally Posted by Alan Anderson
Why? What particular itch would be scratched by having OO in your robot-programming toolkit?
Well it would let you use << instead of printf's. Heck you could overload << operator to output motor values or set the target of a PID loop or other mostly useless but amusing things, I suppose.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #5   Spotlight this post!  
Unread 15-11-2006, 08:21
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: C or C++

Quote:
Originally Posted by Kevin Sevcik
Quote:
Originally Posted by Alan Anderson
Why? What particular itch would be scratched by having OO in your robot-programming toolkit?
Well it would let you use << instead of printf's. Heck you could overload << operator to output motor values or set the target of a PID loop or other mostly useless but amusing things, I suppose.
I was asking about Object Oriented, not Operator Overloading. My question is this: how would object-oriented programming be useful in programming a FIRST robot?

Modular programming is obviously a good thing, but I don't really see a good use for classes and inheritance and polymorphism and such.
  #6   Spotlight this post!  
Unread 14-11-2006, 23:17
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
Re: C or C++

It's amazing the misconceptions that have been posted here about the differences between C and C++. C++ code doesn't have to be bloated compared to equivalent C code. When using the advanced features you do have to know what you're doing if you don't want to pay a size or performance penalty.

I used C for years and then moved to C++. Moving back to C was an extreme shock. Having to jump through hoops to do reasonable encapsulation and using funky naming conventions to keep the code organized and readable is a roaring pain. The lack of proper const types is inhibiting.

Some here seem to think that using C++ entails a lot of new and free calls to create and destroy objects. If your C code isn't using a lot of malloc and free calls, there will be no difference. And for a FIRST robot you really don't need any dynamic memory allocation.

C++ is a much better language and with proper use can even produce smaller, faster code than C. Not to mention if the code is properly written, it's easier to understand, maintain, and more robust.
  #7   Spotlight this post!  
Unread 15-11-2006, 08:13
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,355
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: C or C++

I always thought the problem with object oriented languages and microcontrolers was the async nature of OO. In other words OO is terrible for RTOS's.
  #8   Spotlight this post!  
Unread 15-11-2006, 08:30
Happy Birthday! Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: C or C++

Quote:
Originally Posted by Gdeaver
I always thought the problem with object oriented languages and microcontrolers was the async nature of OO. In other words OO is terrible for RTOS's.
Actually C++ is quickly gaining in popularity in the embedded world. The last project I worked on at Motorola was almost entirely C++ code running on an embedded control board under the pSOS and OSE RTOSes.
  #9   Spotlight this post!  
Unread 15-11-2006, 12:48
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
Re: C or C++

Quote:
Originally Posted by Gdeaver
I always thought the problem with object oriented languages and microcontrolers was the async nature of OO. In other words OO is terrible for RTOS's.
Object oriented languages aren't any more asynchronous than purely procedural languages. If you're talking about the message passing paradigm, that's just OO speak for function calls.

That said, however, most microcontroller programs have to deal with asynchronous events.
  #10   Spotlight this post!  
Unread 15-11-2006, 15:40
chris31 chris31 is offline
Team 2021 Captain
AKA: Chris Davidson
FRC #2021 (FA Robotics)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2006
Location: Atlanta, GA/ Fredericksburg,VA
Posts: 949
chris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond repute
Send a message via AIM to chris31
Re: C or C++

http://www.virginiafirst.org/workshop_info.shtml

I figure it just a typo but look at "Beginning Programming - part 1". Maybe they know something we dont know. Im pretty sure its a typo though.
  #11   Spotlight this post!  
Unread 15-11-2006, 15:46
X-Istence X-Istence is offline
Melt the RC controller!
AKA: Bert JW Regeer
no team
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Montville
Posts: 151
X-Istence will become famous soon enoughX-Istence will become famous soon enough
Send a message via AIM to X-Istence Send a message via MSN to X-Istence
Re: C or C++

I screw it all. Let's go back to the PBASIC boards from a few years ago.
__________________
My Blog!
  #12   Spotlight this post!  
Unread 15-11-2006, 18:47
chris31 chris31 is offline
Team 2021 Captain
AKA: Chris Davidson
FRC #2021 (FA Robotics)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2006
Location: Atlanta, GA/ Fredericksburg,VA
Posts: 949
chris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond repute
Send a message via AIM to chris31
Re: C or C++

Quote:
Originally Posted by X-Istence
I screw it all. Let's go back to the PBASIC boards from a few years ago.
LOL. I have never used to PBASIC boards but I like the C ones just fine.
  #13   Spotlight this post!  
Unread 15-11-2006, 21:34
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: C or C++

I'm going to try to clarify somethings about using OOP on the current breed of controllers.

Using any kind of memory management on the PIC18s would incur a performance penalty in terms of pointers, indirect addressing, management overhead, etc. I don't care how few malloc()/free() calls there are; it only takes one. In order to perform indirect addressing, you have to copy the pointer to a special register. Every dereference requires this, on a byte-by-byte basis. I'm not even sure you can perform an indirect function call. (Remember, code is stored seperate from data.)

I agree that using OOP principles is a Good Thing(tm). But the limits of the PIC18 processors are such that full-blown OOP (or even just objects) as it is normally implemented is impractical.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 16:41.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi