Hacker News new | past | comments | ask | show | jobs | submit login

Which breaks down every time a C API needs to be called, and that linked API still has plenty of functions with separate pointer and length parameters.



You can do it like in Free Pascal/Delphi: store the string both length-prefixed (for fast length access and bounds checking) and zero terminated (for passing to functions that expect zero terminated strings).


And then the callee corrupts it.


If the callee is meant to corrupt it then it is your fault for misusing it (unless the corruption is intentional and you plan to recalculate the length after calling it). If it wasn't meant to corrupt it then it is a bug and if it is in your code then it is your fault for not using the string functionality that you already have in place to avoid the bug in the first place. If it is not in your code, as long as you had to use it you'd have that bug regardless of what language or framework you used since it is out of your control and there isn't anything you can do about it.


Aka, C's community version of "you are holding it wrong".


Is there a language that doesn't allow any abuse of an API, including APIs that were not written in that language?


Yes, any system languages that doesn't need to depend on the existence of C.

If you are going to mention Assembly as possibility, check ClearPath where there is no Assembly, NEWP has full control over the hardware stack.




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

Search: