Hacker News new | past | comments | ask | show | jobs | submit login

Defaulting to bignums would turn every + in the program from O(1) to O(N). That makes secure programming pretty difficult - this attack's already bad enough:

http://arstechnica.com/business/2011/12/huge-portions-of-web...




It's that, or have every + risk integer overflow.

It's a small thing, but it's nice to do. Or at least detect overflows and move to bignum in the default numerical implementation. It's not end-of-the-world if you don't, but it helps avoid a lot of bugs...


I really recommend having the program trap on overflow. There are some proposals like as-if-infinitely-ranged, which is like bignums but without having to actually store a bignum.

It's really problematic to use them, though. Every integer would turn into a pointer, and the O(N) thing really is a problem. If you're doing secure coding you need careful control of data dependencies, since they create side-channel leaks, and nobody who makes "safe" languages appreciates this.

Plus most people don't need numbers that big. I think it was even a mistake to make size_t 64-bit.


C actually makes it really hard to trap on overflow. It's one of the biggest reasons C kinda sucks.

The way a lot of HLLs do it is to detect a potential overflow, and convert to bignum if needed.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

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

Search: