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

I suppose I could but that'd be too complicated for my taste. In fact I wouldn't even need to go that far. Many of the most useful things are implemented as extensions to C89 in the popular compilers. Instead I stuck to pure C89 which I knew would be universally implemented. I like knowing that I can set GCC to ansi + pedantic and have a reasonable expectation of no drastic surprises.

C89 is primitive but charming in the simplicity. For instance while I disliked being forced to declare a function's variables before any code I now see that it encouraged me to keep functions very small. I would find ways to use fewer variables. Instead of 'for(int i = 0; i < max; i++)' I would use 'while(--max >= 0)', anything to avoid moving my cursor to the top of the function.

On the other hand I miss C++'s exceptions. Checking for errors all over the place gets ugly and bloats the codebase. What would otherwise be a two line copy operation between two objects gets two if blocks added which handle the miniscule chance of memory allocation failure in some other deeper frame.



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

Search: