Live data from Hacker News

OMG: Our Machinery Guidebook

ourmachinery.com

1–10 of 31 posts

Re: OMG: Our Machinery Guidebook

#6
post #4

I.e., use a double parameter that specifies seconds, instead of an uint32_t that specifies milliseconds. This can have surprising and sometimes unpleasant consequences; see https://0.30000000000000004.com

Better yet, use std::chrono. Yes, it's C++. But this is an example of how properly applied bits from C++ can make things easier to reason about and type-safe, rather than "let's avoid C++ as much as possible".

No ambiguity for the programmer as to what the underlying units are, and no unnecessary int/float conversions. All the book-keeping and conversions are taken care of by the compiler with zero run-time size or perf overhead.

Re: OMG: Our Machinery Guidebook

#7
Quick typo under OMG-CODEORG-2:

    #pragma once

    #ifdef __cpluspus // 
Can't say I'm a fan of OMG-CODEORG-3, however, it sounds like compilation time is a key metric for them.. I prefer a John Lakos style "physical components" set up which emulates a type-as-module inclusion style. At least OMG-CODEORG-3 clearly states that include order becomes important as a result.

Re: OMG: Our Machinery Guidebook

#9

Quick typo under OMG-CODEORG-2: #pragma once #ifdef __cpluspus // Can't say I'm a fan of OMG-CODEORG-3, however, it sounds like compilation time is a key metric for them.. I prefer a John Lakos style "physical components" set up which emulates a type-as-module inclusion style. At least OMG-CODEORG-3 clearly states that include order becomes important as a result.

Agree, CODEORG-3 adds a bunch of pain. There's a reason other languages don't have headers but since C programmers have to live with them can't I just include the single relevant header and move on with writing my code. Yes there is a shared cost to that (compile time) but '#pragma once' is well supported and futzing with header order is a non trivial time-sink too.

On the same lines the template 'cute tricks' are where you get your performance, stability and readability from C++. I definitely agree that you should drop into assembly to see what the compiler is doing with your code but that can and should apply to heavily templated code too.

Re: OMG: Our Machinery Guidebook

#10
post #4

I.e., use a double parameter that specifies seconds, instead of an uint32_t that specifies milliseconds. This can have surprising and sometimes unpleasant consequences; see https://0.30000000000000004.com

What practical problems do you think this could cause in specifying or measuring time?
Post reply on HN