Hacker News new | ask | show | jobs
by cefstat 3821 days ago
> But Pascal was created about the same as C and had proper types.

The Pascal I remember (some version of Turbo Pascal in the early 90s) had strings where you had to declare the length as part of the type. Strings of different length had different types and you could not pass a string of length 30 to a procedure that expected a string of length 31. The way to solve this is to declare that all your strings had the same length and hope that it would be enough. It was horrible and at the time I found the C approach much more reasonable. Of course Pascal improved through the years and the C approach turned out to be a huge security problem.

3 comments

Pascal strings are weird.

The first byte tells you the string's length. If the MSB of the first bit is set, the string's first 4 bytes tell you the length of the string. I mean yes its not a horrible system, but there are better systems.

I'll be honest I like Rust's. Just keep the length and the pointer on the stack in a tuple.

ISO Extended Pascal and other Pascal dialects had open arrays.

Algol and Mesa were two other languages that you could generalize over array size.

For anyone interested in systems programming it is a good eye opener to delve into the system programming languages from 60 and 70's, before C escaped UNIX.

I didn't meant to say that Pascal hat the perfect solution, but that with that times technology, better solutions than the C one were possible, and more so with any language more modern than ancient Pascal.