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

Mostly good rules for C development in these situations but see John Carmack for a disagreement about rule 6.

http://number-none.com/blow/john_carmack_on_inlined_code.htm...



Interesting to note that the description of how the flags and main loop works in practice makes the resulting program close to ladder logic,[0] still used in programming PLCs. Having used it the global state is annoying at first but does make the program easy to reason about.

The ladders inputs and outputs almost become like a set of invariants like you would find in a functional program, but the monad for state is implicit.

[0] https://en.wikipedia.org/wiki/Ladder_logic


Rule #6 increases readability. eg:

    int foo;
    // a page of code
    foo = bar + 5;
    // more code
vs

    // a page of code
    int foo = bar + 5;
    // more code
This keeps everything in one place. It's more readable and easy to follow.

I feel like the topic of inlined code is similar but is not quite the same.




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

Search: