Hacker News new | ask | show | jobs
by ldar15 5305 days ago
In Systems Programming Languages? For "writing operating systems"? There are people who argue we should be writing our operating systems in high level languages anyway. Assuming the premise is we should be using a low-level language, then how does the author reconcile that with "but I want the language to hold my hand when it comes to math".

Choosing "overflow" or "underflow" to mean "I fucked up" is totally arbitrary. Variables usually indicate values that have a domain - a range of valid numbers. Saying "I don't want to think about what that it is, but oh if X hits 2 billion and change then warn me when some math fails" is no better than having it not fail at all. In most cases there's already a problem.

So, simply, writing "OS quality" code means explicitly checking inputs to ensure they are in the permissible range. Once you know what the range is, you know if your code needs to go up to 64bit math to handle them.

UPDATE: Some explanation for the downvote would be appreciated.

2 comments

There have been many security holes and crashes caused by undetected integer overflow. The rationale is that detecting this condition would be a useful step toward preventing that category of bug.
The rationale, then, is that the compiler should catch mistakes that lead to security holes. On that basis, then, we'll be adding GC memory management, so we never access freed memory, also strongly defined types - e.g. bounded integers, and bounded arrays too. Writing the OS an ADA would satisfy this chap?

"catching security holes" is the compiler version of "think of the children".

Writing an entire operating system without touching a low-level language is largely the stuff of fantasy. High-level languages are, after all, built on top of low-level languages.
http://en.wikipedia.org/wiki/Lisp_machine

The C compiler in that machine was written in Lisp. :)