News for hackers. Stuff that matters.
Re:The descent to C by waps on Tuesday January 28, 2014 @09:03AM (#7137076)
Don't you think that pascal's standard safeties will prevent mistakes ?

1) array bounds checking (which can be used for safe hardware access instead of peek/poke)

2) pascal-style strings (with actual support for them, both in the language and in the standard library) (meaning a missing \0 doesn't erase the entire memory)

3) type-safe pointers

4) no pointer arithmetic

5) no preprocessor

...

Re:The descent to C by weland on Tuesday January 28, 2014 @10:08AM (#7137435)
> 1) array bounds checking (which can be used for safe hardware access instead of peek/poke)

How? Peek/poke at the wrong address will generate an error in any case, and any MMU-less platform worth using will have the memory-mapped peripherals into a lower region, where it doesn't get thrashed by writing past the end of a buffer. I have seen bugs occurring because of data located past a buffer getting thrashed, but I don't remember seeing one in the context of hardware access.

> 2) pascal-style strings (with actual support for them, both in the language and in the standard library) (meaning a missing \0 doesn't erase the entire memory)

That shouldn't happen in C, i.e. there are library routines you should use so that it doesn't happen. Not that string processing isn't a pain :-).

> 3) type-safe pointers

No complaints here :-)

> 4) no pointer arithmetic

That's not always good, but it does decrease the likelihood of certain types of bugs, so yep!

> 5) no preprocessor

Also yep :)

Re:The descent to C by acqq on Tuesday January 28, 2014 @05:29PM (#7140254)
2) "That shouldn't happen in C"

It happens every day and it will as long as there's C. Zero-terminated strings are part of the standard library and almost infinite number of other libraries. You can't pretend it doesn't exist as the most common convention.

For 1) see waps' comment with byte absolute.

One complete program from that time which uses that feature: http://kd5col.info/swag/INTERRUP/0019.PAS.html

Re:The descent to C by pjmlp on Tuesday January 28, 2014 @09:56AM (#7137367)
Additionally all those safety mechanisms can be turned off for performance, but only on the exact spot where it really matters, instead of being scattered all around the code.
Re:The descent to C by waps on Tuesday January 28, 2014 @10:26AM (#7137563)
Example of absolute array:

var EGAVGAScreen : Array[0..41360] of Byte absolute $A000:0000;

Et voila : bounds-checked memory mapped hardware access.

(note: the very well known "Crt" unit uses a memory mapped video buffer like this. So if you programmed a turbo pascal program, chances were good it was using this trick for screen output. Advantage : the speed is unbeatable)