4 ms·
Almost all the integers I use in 'C' are highly constrained. I try very hard ( and nearly always succeed ) in writing code that manages those constraints proper
by ArkyBeagle 10y ago
Almost all the integers I use in 'C' are highly constrained. I try very hard ( and nearly always succeed ) in writing code that manages those constraints properly. This may include oversubscribing integers - using a long long instead of a long, perhaps.
This involves at least doing a depth-first examination of all invocations of that operation, and possibly writing tests for all of them. That encourages keeping things local.
I think the safety-think here is slightly inappropriate. Of course you can do it wrong. But it is in no way an unreasonable expectation that you not do that.
And again- for the general population out there - perhaps 'C' is not for you. I am a 'C' programmer only because of path dependencies in what's happened to me. I would not recommend it to anyone. That's not elitist - it's just how things played out.
- jstarks 10y agoI think it's apparent that we write in C because of network effects and not because it's the best tool for the job. It's great that people like you can handle it, but I'd much rather write in a language that keeps my stupid mistakes from becoming expensive security holes. It allows me to write code faster and to work with other non-perfect programmers.
- ArkyBeagle 10y agoYeah, but whither faster? When I was an imperfect programmer ( perfect to some epsilon TBD ) I wanted to be a more perfect programmer. This was not without cost. I suppose if you're not interested in that ( and I understand that impulse, believe me ) then ... I have to, by training, attribute all defects to process and human behavior. But as things emerge, maybe the tools will really fill the gap. But again, at a cost. I am, say, pretty good with Python but I am by no means a master. It would take having a full time exposure for months, perhaps years to make that claim. And this fragments us. It may well be that I'd actually be better fit for a job using Python but because I can't make this claim now, we get a false negative on fitness. I'm just using "me" and "Python" to construct an example.
- posterboy 10y ago> network effects C, like unix, is a small payload spreading like a virus, depending on the coder to keep it alive. The simplicity and the emergent behavior are as much an evolutionary advantage as a burden because of the UB. At 600 pages, the standard is not really simple anymore, as the RNA accrues more inputs from different vectors. I started to read the The UNIX-Haters Handbook [1] after I installed a Windows VM and saw the link here the other day. 1: http://web.mit.edu/~simsong/www/ugh.pdf http://web.mit.edu/~simsong/www/ugh.pdf
- 0xmohit 10y agoHave you tried using tis-interpreter [0] (an interpreter of C for detecting undefined behavior written in OCaml) written by Pascal Cuoq [1]. [0] https://github.com/TrustInSoft/tis-interpreter https://github.com/TrustInSoft/tis-interpreter [1] http://stackoverflow.com/users/139746/pascal-cuoq http://stackoverflow.com/users/139746/pascal-cuoq
- ArkyBeagle 10y agoI cannot say that I have. Looks very interesting. Thanks!