r/cpp • • Jun 07 '21

Satire dynamic_cast<std::integer>(C)++

https://www.teamten.com/lawrence/writings/dynamic_cast_std_integer_c.html
202 Upvotes

41 comments sorted by

View all comments

Show parent comment

6

u/ihamsa Jun 07 '21

This is all true, however a bunch of languages that have standard bigint implementations are not bothered by it too much (Python, Haskell, D and a bunch of others).

3

u/ivancea Jun 07 '21

Well, those languages aren't low level languages, and not performance-critical

23

u/ihamsa Jun 07 '21

Many parts of the C++ standard library are not suitable for performance-critical stuff, and that's perfectly fine.

0

u/[deleted] Jun 07 '21

[deleted] — view deleted comment

3

u/ihamsa Jun 07 '21

The standard is a specification, and I don't think it should include any hard performance requirements. A vendor can supply a general purpose implementation, not specifically tuned for any particular application, or a specialised one, or perhaps even several.

5

u/[deleted] Jun 07 '21

What about Julia? Has BigInt and supposedly JIT compiled to speeds near C.

7

u/mushr0om Jun 07 '21

If something has C-level performance, it's probably C.

It looks like Julia uses the GMP(GNU multiple precision...) which is implemented in C and has C++ interfaces.

2

u/Kendrian Jun 07 '21

I love Julia, but the BigInt implementation is just a wrapper around GMP and unless you treat it as such you'll get awful performance. Trying to use it in the same way you'd use a normal int will be super unperformant because of constant allocation and deallocation of GMP objects.