Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Turbo Pascal.

It has a similar set of capabilities to C (including pointers, in line ASM, arbitrary memory access, etc.), ability to call C code, so integrates nicely with C libs.

It has slightly better type handling - e.g. you can declare "feet" and "metres" types based on float, but the compiler won't let you assign one to the other (unless you force a cast).

The major safety advantage is that by default access to strings, arrays and memory management is bounds checked. You can turn this off with pragmas in the code for performance sensitive bits.

In fact, standard practice in C now is to use bounds-checked functions (the strn* functions, etc). Except instead of the compiler keeping track of data sizes for you, you have to do it manually!

Normal string handling is also faster in TP since it stores the length of the string, so it doesn't have to scan through to find the zero char during string operations.

Of course, all this is possible in C, but it's not part of the standard language and API. This has two disadvantages: 1) Lazy or inexperienced programmers will write the most dangerous code. Yikes! 2) Each careful programmer will solve the safety problems in their own way, code from different sources will not necessarily be compatible, forcing library APIs to fall back to the unsafe standard structures.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: