Sunday, 7 January 2007

2007, the year of software reliability?




A new year is upon us, and everything feels so different! I've been pondering if 2007 could be a year to remember for software. Reliability is definitely one area I can see which has scope for improvement in this year's releases.

Following on from my last discussion: The problem with programming? Do we as software developers really need to expose ourselves and users to crash opportunities as at present? It's an interesting point to debate. C++ gives programmers control over memory resources, direct address access and pointer arithmetic. Invalid data can cause out of bounds memory accesses and likewise programmers are only fallible humans which can make mistakes as well. Programmers shouldn't count on being able to always beat the language at what it does best!

As Bjarne says "People push what they know and what they have seen work; how could they do otherwise?". It's surprising to see people code C++ like they do C, pointers arithmetic, allocating memory and magic globals etc which should be neatly wrapped up in a state system, design pattern or other standard approach.

A few examples of problems in C++ which can trip programs up:
  • Memory management delegated to programmer, no built in garbage collection of inaccessible objects/allocations means resource leaks can occur.
  • Using pointers means NULL pointers will cause crashes.
  • The type system is not type-safe like Ada, Java, Haskell and C#.
  • Direct address access for memory and data means a the program could over or under-run.
Would it be better to write non-kernel/system libraries in a language which does not permit these issues? It seems logical to cut down on the opportunity for errors.

In practice I see that performance critical crunching code (like a quantiser etc) really benefits greatly from a C++ implementation which can use the points above; the compiler just can't convert the code into as optimal an implementation itself. Let's only write a more optimal block of code when we really need to though, the profiler shows us when that is necessary ;)

Labels: ,

2 Comments:

At 12 January 2007 02:09 , Blogger Robert said...

How would you compare C++ to Lisp?

Do you also work with specialized programming languages, or are you only interested in all-purpose programming languages?

 
At 13 January 2007 23:40 , Blogger Jon Grant, UK, 東京 said...

Hi Robert, Thanks for the comment.

I'll keep my reply short. Aside from the different style of code, C++ is a systems programming language, Lisp isn't. C++ is also fairly standard compared to Lisp varieties, in addition it's easier for programmers to get into (but not as "easy" as VB?) and includes enough features to cover most bases. On the other hand Lisp is great for language extensions and AI. So they both have benefits.

I work with certain specialised languages (i.e. Cg/HLSL, PS2 Vector Unit asm), and have worked in M-Code in the past.

As a side note, Microsoft's F# looks like an interesting scripting language on the horizon!

 

Post a Comment

<< Home