Overclockers Australia Forums

OCAU News - Wiki - QuickLinks - Pix - Sponsors  

Go Back   Overclockers Australia Forums > Software Topics > Programming & Software Development

Notices


Sign up for a free OCAU account and this ad will go away!
Search our forums with Google:
Reply
 
Thread Tools
Old 21st August 2012, 12:24 PM   #1
zach Thread Starter
Member
 
zach's Avatar
 
Join Date: May 2009
Location: chermside.bris.qld.au:80
Posts: 2,575
Default Mars Rover Curiosity C Coding Standard

I found this interesting.

I know this probably isn't the place and site discussion would be more suited, but I propose a thread for general software development banter, much similar to f=48's general photography banter.

It would be a thread for posting interesting articles, whitepapers, blogs etc related to development. I'm not sure how much traffic it would attract but I'm willing to copy-pasta interesting stuff I see and discuss.
zach is online now   Reply With Quote

Join OCAU to remove this ad!
Old 22nd August 2012, 3:59 PM   #2
SaTaN
Member
 
SaTaN's Avatar
 
Join Date: Jun 2002
Location: bellevue hill!
Posts: 4,391
Default

hardly surprising, the target isnt exactly a cheap device which can be thrown away or reset if it crashes
SaTaN is offline   Reply With Quote
Old 22nd August 2012, 8:25 PM   #3
SLATYE
SLATYE, not SLAYTE
 
SLATYE's Avatar
 
Join Date: Nov 2002
Location: Canberra
Posts: 25,773
Default

It'd be interesting to see what the performance difference is between highly-optimised code (ignoring these guidelines) and code that rigidly sticks to the guidelines. Lots of assertions and sanity checks must take a fair bit of processing power.

Not that it matters for Curiosity - it moves slowly anyway and it's got a relatively large amount of processing power available.
__________________
Main system: Phenom II X4 920 | 8GB (4x 2GB) DDR2-800 | Gigabyte M57SLI-S4 v2.0 | Leadtek Geforce 9600GSO 384MB | Enermax Modu82+ 525W | 1TB Hitachi HDD | 3.5" + 5.25" FDD
Laptop: Compal EL80 | C2D T7200 | 320GB Fujistu HDD | 2GB DDR2-667 | GF Go 7600
SLATYE is offline   Reply With Quote
Old 22nd August 2012, 10:08 PM   #4
Zoltag
Member
 
Join Date: Aug 2001
Location: London
Posts: 497
Default

Interesting to note that even sticking to these standards, the number of bugs found in the code wasnt noticeably reduced:

http://www.theregister.co.uk/2012/08...ware_coverity/

Quote:
Roughly 2,000 bugs were zapped in the rover's code...For a project with 2 million lines of code, it would therefore not be unusual for Coverity to be able to find about 2,000 defects
Zoltag is offline   Reply With Quote
Old 22nd August 2012, 10:49 PM   #5
SLATYE
SLATYE, not SLAYTE
 
SLATYE's Avatar
 
Join Date: Nov 2002
Location: Canberra
Posts: 25,773
Default

Most of the requirements aren't really to prevent mistakes in the code - humans make mistakes in any code, and this is no different.

Instead they're designed so that mistakes in the code don't have far-reaching consequences. For example, a mistake might cause an incorrect result, but it won't cause an infinite loop because loops have verifiable bounds. It might cause an incorrect input to one function, but the function will immediately throw an error rather than continuing to propagate the incorrect data. This system also allows the code to be more easily checked by automated tools; it's very possible that other software would have 2000 bugs that were found plus another 500 that were never spotted because there's no straightforward way to check.
__________________
Main system: Phenom II X4 920 | 8GB (4x 2GB) DDR2-800 | Gigabyte M57SLI-S4 v2.0 | Leadtek Geforce 9600GSO 384MB | Enermax Modu82+ 525W | 1TB Hitachi HDD | 3.5" + 5.25" FDD
Laptop: Compal EL80 | C2D T7200 | 320GB Fujistu HDD | 2GB DDR2-667 | GF Go 7600
SLATYE is offline   Reply With Quote
Old 23rd August 2012, 7:50 PM   #6
Foliage
Member
 
Foliage's Avatar
 
Join Date: Jan 2002
Location: Sleepwithyourdadelaide
Posts: 23,642
Default

A bug is better than a bug that causes the software to crash or require a watchdog timer to reset, that is all that these guidelines really prevent.
__________________
I like to construct strong views on random things, and then argue for absolutely no reason about them.
Foliage is offline   Reply With Quote
Old 24th August 2012, 10:52 AM   #7
Jay
Member
 
Jay's Avatar
 
Join Date: Jan 2002
Posts: 2,305
Default

Brings me back to systems engineering. It's better to have bugs that fail gracefully than ones that cause total failure, and it's much better to be able to know about the ones that do exist. In complex software it's about impossible to reach zero defects, and as defects approach zero more defects are likely to be reintroduced.

It's also probably for a bureaucratic paper-trail too.

Quote:
There should be no more than one statement or variable declaration per line. A single exception is the C for-loop, where the three controlling expressions (initialization, loop bound, and increment) can be placed on a single line.
Which you'd normally think is quite trivial.
__________________
Campaign for fixed width styles for OCAU! - Update: Kittehs saved!
Default. Sab.
Jay is online now   Reply With Quote
Old 24th August 2012, 10:54 AM   #8
aXLe
Member
 
aXLe's Avatar
 
Join Date: Jun 2001
Location: Brisbane
Posts: 945
Default

If you have time to read it, this is an interesting insight : http://www.fastcompany.com/28121/they-write-right-stuff
aXLe is offline   Reply With Quote
Old 24th August 2012, 11:05 AM   #9
zach Thread Starter
Member
 
zach's Avatar
 
Join Date: May 2009
Location: chermside.bris.qld.au:80
Posts: 2,575
Default

Quote:
Originally Posted by Jay View Post


There should be no more than one statement or variable declaration per line. A single exception is the C for-loop, where the three controlling expressions (initialization, loop bound, and increment) can be placed on a single line.

Which you'd normally think is quite trivial.

At least they use C99.
zach is online now   Reply With Quote
Old 24th August 2012, 3:40 PM   #10
MoorKhan
Member
 
MoorKhan's Avatar
 
Join Date: Feb 2004
Posts: 1,096
Default

I linked the coding standards document in the curiosity science thread too, but it didn't see much discussion there.

Quote:
Originally Posted by Zoltag View Post
Interesting to note that even sticking to these standards, the number of bugs found in the code wasnt noticeably reduced:

http://www.theregister.co.uk/2012/08...ware_coverity/
That might be a little misleading, as Coverity mostly deal with big name companies that presumably have quite stringent standards of their own. Coverity apparently charge quite a bit (and bill per line of code), so their clients are unlikely to be companies writing code without solid standards already in place.

The rationale behind the power of ten rule 5 (assertion density), indicates that in typical industrial code one defect is found every 10 to 100 lines of code - rather than every 1000 as Coverity reports in that article. So going on the 10-100 figure the number of bugs has been significantly reduced.
MoorKhan is offline   Reply With Quote
Reply

Bookmarks

Sign up for a free OCAU account and this ad will go away!

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +10. The time now is 6:25 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. -
OCAU is not responsible for the content of individual messages posted by others.
Other content copyright Overclockers Australia.
OCAU is hosted by Internode!