3 ms·
C is used for low level libraries for it's lean and mean performance. It sacrifices checks and safety features for this, and allows the programmer full control.
by dryicerx 17y ago
C is used for low level libraries for it's lean and mean performance. It sacrifices checks and safety features for this, and allows the programmer full control. Do you see professional race cars with ABS and Automatic Stabilization? No, you give the Driver FULL and TOTAL control, same with C and other low level languages. C has only a few data types that are as basic as you can get, I mean what do you expect use something like STL strings?
If you start having type checking and various other easy-to-code and child-safety features, you are bloating and giving up performance in the low level libraries, if this happens imagine what the performance on the higher up application level would be.
- praptak 17y ago"For example, professional cooks don't use consumer grade safe knifes, they use hardcore deadly knives for their performance." They also wear cut-resistant gloves.
- dryicerx 17y agoheh, just did a ninja edit and replaced with the race car analogy after realizing that. HN comments need to be ACID
- berglundma 17y agoI think the cooking analogy holds. Sure, those people DO use knife-proof gloves and for good reason. They need to be able to cut through things of the same basic structure as human meat! So it goes with code: if you are working on a low level libs and languages you should be protecting yourself with well thought out data and exception handling. If you don't, you might just cut your hand, I mean, data off!
- nkurz 17y agoI suppose that butchers might use cut-resistant gloves, but in the professional kitchens I've shared I've never seen them worn by a chef.
- deleted 17y ago[deleted]
- krschultz 17y agoI'd prefer my libraries be rock solid secure even if I lose some (or even a lot of) performance for it. Hardware is always getting cheaper. Losing data integrity and the trust/confidence of your users is extremely expensive, and can be fatal for a startup. Performance is not the most important metric for a lot of applications. I'd prefer the safe but slow 5 star crash test rated sedan with a good alarm over the race car that is going to blow up after a few races, in library terms.
- pyre 17y ago> Hardware is always getting cheaper. This is a poor justification. A few years ago a house was a good investment because 'housing prices will always be going up.'
- bmj 17y agoThat, and not every program runs on ever-faster hardware.
- evgen 17y agoPlease provide even a single deluded fantasy in which the price/performance ratio for a particular piece of hardware or component in the hardware stack will not continue to trend in the direction of more bang for the buck.
- tow21 17y agoI don't know if this counts as "deluded", but how about: resource exhaustion of raw materials required in hardware manufacture. See, for example: http://blogs.wsj.com/informedreader/2007/05/25/a-metal-scare-to-rival-the-oil-scare/ http://blogs.wsj.com/informedreader/2007/05/25/a-metal-scare... which talks primarily about LCD displays (we're fast running out of Gallium/Hafnium/Indium), but points out that copper is likely to get significantly more expensive throughout this century. That's going to increase the price/performance ratio of practically everything.
- 17y ago
- tumult 17y agoprofessional race cars absolutely have ABS. in fact ABS systems are so effective that their use has been restricted in the likes of formula 1 etc.
- jrockway 17y agoActually, c-strings are a speed-for-memory trade-off. At the expense of saving a few bytes of memory per string, most operations are O(n) time (strlen, for example). If c-strings were in the form of <length><data> instead of <data><\0>, this bug would be avoided. This is not a performance issue, only bad design and convention. (The other problem was using memcpy and strcmp on the same data. You can't treat blocks of memory as strings; a type system would eliminiate this confusion at no runtime cost.)