On Friday, 17 November 2017 at 12:18:47 UTC, Atila Neves wrote:
That's the whole point of using a safe language, otherwise we'd be fine with C.


Personally, I would prefer to teach new students to program in C first - precisely because it's an unsafe language - or at least, can be used unsafely.

(that's how i first learnt to program - and actually I taught myself).

Because of C, I 'had to' learn how to write code in a defensive manner.

These days people often start with a safe language instead, and often use it within an overly sophisticated IDE ( a bit like having your mother hold your hand everytime you cross the road). I think that encourages laziness, in terms of defensive programming/thinking. Programmers become complacent and leave too much stuff up to compile time checks.

I think people can write more correct code in the beginning, by simply changing the way they think about the code and how it might interact in the wider ecosystem...and, maybe even by not relying on sophisticated IDE's (at least at the early stages).

Of course compile time checks are needed. But they should not be at the expense of writing code correctly in the first place. They should come in at the latter stage of defensive programming, not the first stage.

If you check the validity of an object before going on to reference/modify it, then no compile time check is ever needed.

nice Dr Dobbs article about it here:

http://www.drdobbs.com/defensive-programming/184401915

Reply via email to