Hacker News new | ask | show | jobs
by PennRobotics 1038 days ago
I did what you described just yesterday. I couldn't remember offhand if the compiler I was using would automatically convert a uint8_t to an int (because I didn't want to have to add two levels of parentheses by explicitly casting the high byte and then shifting) and very quickly threw together a

    // test if we need a<<8|b
    //              or (a<<8)|b
    //              or ((int)a<<8)|b
    //              or (((int)a)<<8)|b
    #include <cstdio>
    #include <cstdint>
    int main()  { uint8_t a = 2; uint8_t b = 38; printf("%d\n", a<<8|b); }
More than half of the time is the uninteresting parts: writing the includes, creating a temp file, exiting to compile, forgetting a parenthesis, reediting and resaving, compiling again, running, deleting...

In a REPL---particularly one with stdio/stdlib included by default---this would take 30 seconds but instead takes 3 or 4 minutes. It's not much, but tight feedback loops really, really keep you in a great mental state.