Live data from Hacker News

Bounded Integer: Header-only C++ library replaces integers, adds explicit bounds

bitbucket.org

51–60 of 130 posts

Re: Bounded Integer: Header-only C++ library replaces integers, adds explicit bounds

#51
post #45
post #36

Earlier quoted context omitted.

Have you measured? Also, what do you mean by "this has to just trash performance for debug builds". Do you mean runtime performance?

Yes, that’s what I mean. And before you say ”debug performance doesn’t matter”: yes it does. I work in gamedev and it’s a huge problem that C++ has such awful debug performance, because it’s hard to debug a game if it’s running in single-digit framerates. It’s a large part of the reason why EASTL is so popular in gamedev.

> single-digit framerates

In more explicit terms-- you are a soft-realtime app developer trying to live in a world that rarely measures performance or even writes specs with your constraints in mind.

I wish you game devs would harp on this more. I'm just a lowly soft-realtime audio software dev. My voice doesn't carry because there aren't mountains of cash behind me to help echo it.

Re: Bounded Integer: Header-only C++ library replaces integers, adds explicit bounds

#53
post #42

Earlier quoted context omitted.

It does. I personally stick to those exclusively except for for loop index variables.

What would be different about loop variables? I don't really write C++.

I'm assuming here that they would use the `size_type` for the container they are iterating over. Otherwise I'm not sure.

Re: Bounded Integer: Header-only C++ library replaces integers, adds explicit bounds

#54
post #11

Earlier quoted context omitted.

int, long. The standard specifies their minimum sizes.

It specifies the minimum sizes, in the sense that sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) etc... but no requirements on how big they actually are. You could (in theory) end up with all of those being 9 bits wide on some weird platform.

No, they cannot all be 9 bits, they have higher minimums.

https://en.wikipedia.org/wiki/C_data_types#Basic_types

Re: Bounded Integer: Header-only C++ library replaces integers, adds explicit bounds

#55
post #45
post #36

Earlier quoted context omitted.

Have you measured? Also, what do you mean by "this has to just trash performance for debug builds". Do you mean runtime performance?

Yes, that’s what I mean. And before you say ”debug performance doesn’t matter”: yes it does. I work in gamedev and it’s a huge problem that C++ has such awful debug performance, because it’s hard to debug a game if it’s running in single-digit framerates. It’s a large part of the reason why EASTL is so popular in gamedev.

Why not use a debug release build. Like O1 with debug symbols.

Re: Bounded Integer: Header-only C++ library replaces integers, adds explicit bounds

#56

Maybe Ada's approach of every number type requiring explicit bounds is a good one.

I think that's a good part of ADA that should have been copied 30 years ago. That and you should be able to define overflow semantics as well.

Re: Bounded Integer: Header-only C++ library replaces integers, adds explicit bounds

#57
post #15

Earlier quoted context omitted.

X86 has also had saturation arithmetic since MMX was introduced.

You should never rely on the underlying CPU architecture's behavior on integer overflow when you write C or C++. It is undefined and not unspecified or implementation defined.

Undefined behaviour is undefined only by the standard - an implementation may choose to handle undefined behaviour in some documented, specific fashion. Undefined behaviour exists to give implementations exactly this flexibility.

Re: Bounded Integer: Header-only C++ library replaces integers, adds explicit bounds

#58
post #45

Earlier quoted context omitted.

Yes, that’s what I mean. And before you say ”debug performance doesn’t matter”: yes it does. I work in gamedev and it’s a huge problem that C++ has such awful debug performance, because it’s hard to debug a game if it’s running in single-digit framerates. It’s a large part of the reason why EASTL is so popular in gamedev.

> single-digit framerates In more explicit terms-- you are a soft-realtime app developer trying to live in a world that rarely measures performance or even writes specs with your constraints in mind. I wish you game devs would harp on this more. I'm just a lowly soft-realtime audio software dev. My voice doesn't carry because there aren't mountains of cash behind me to help echo it.

oh it's been harped on for years. But people with mountains of cash already wrote their own STL and heap allocators :-) Those are usually your main bottlenecks in usability of debug builds.

I've worked on games with "DebugOptimized" builds where it's optimized,but instrumented in other ways. That's probably the best solution. You only drop down to full debug if you absolutely can't debug a specific issue in an optimized build.

With Visual C++, if you are careful you can build a version with release runtimes and third party libs so only your code is debug. Microsoft makes it harder than it has to be though.

Re: Bounded Integer: Header-only C++ library replaces integers, adds explicit bounds

#59
post #55
post #45

Earlier quoted context omitted.

Yes, that’s what I mean. And before you say ”debug performance doesn’t matter”: yes it does. I work in gamedev and it’s a huge problem that C++ has such awful debug performance, because it’s hard to debug a game if it’s running in single-digit framerates. It’s a large part of the reason why EASTL is so popular in gamedev.

Why not use a debug release build. Like O1 with debug symbols.

We absolutely do, but it’s significantly harder to debug. Functions are inlined, variables are eliminated, loops unrolled, etc.

But yeah, very often it’s basically the only option, running an optimized build with debug symbols. This is why it’s such a problem with C++: debug builds are frequently pointless because the performance is so bad, which makes debugging a lot harder.

Re: Bounded Integer: Header-only C++ library replaces integers, adds explicit bounds

#60
post #30

At this point, when I see libraries like this all I can think is ”oh good, my compile times aren’t long enough, lets make EVERY INTEGER a template”. Also, while I can reasonably beliveve that most of the overhead goes away at -O2 or -O3, this has to just trash performance for debug builds, which is not unimportant.

I don't think you even looked at the library, but from I can tell, debug perf would not be impacted at all.
Post reply on HN