frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

C's Flexible Integer Sizes Were Not a Design Mistake

https://pikuma.com/blog/c-integer-sizes-not-a-mistake
23•ibobev•1d ago

Comments

gustavopezzi•17h ago
Author here. Thanks for sharing.
enriquto•49m ago
it's a great read!

would like to learn some tricks, like configuring gcc so that int is 64 bits, and so on

usrnm•50m ago
But not having fixed size integers (or integers tied to the size of a pointer) was. Both can be useful
quelsolaar•34m ago
At the time its was probably very hard to know what the fixed sizes should be.
pjmlp•11m ago
PL/I among other systems languages predating C, had the ability to explicitly define bit sizes for its types.
flowerbreeze•38m ago
Thank you for the article! Do I see a Turbo-C screenshot there or am I imagining it? It was my first IDE (I didn't know that's what it was called) when I started programming. I sometimes miss it, it was really good, especially the help system.

I agree with the article of course. I think most confusion comes not having learned about the purpose of having them be defined based on the architecture in the first place. It took me a long time before I stumbled upon how they really worked and why, because while I started it was either x86 or nothing. When x64 showed up, suddenly it became relevant and everybody started learning about C types more in depth as they ran into issues with sizeof.

Also, misuse in data protocols is where I think the bad reputation of the flexible type sizes came from. stdint was desperately needed for that reason and it came a bit late.

quelsolaar•35m ago
Good article.

C would probably not have survived unless it had this flexibility.

But its not justa historical thing. Today there are modern platforms like DSPs that have 32bit sized char, because that is the smallest addressable type. These platforms depend on C for tool chains, even if most "portable" C wont run correctly on them. The fact that you can build hardware like that, and not have to invent a new language / dialect to program them is a huge win for the world.

<edit> I didnt see the footnote about DSPs at first read </edit>

pjmlp•12m ago
C survived because UNIX carried it.
RobotToaster•21m ago
> A 'plain' int object has the natural size suggested by the architecture of the execution environment.

Shouldn't they be 64 bits on most modern systems then?

flohofwoe•13m ago
It should indeed, and in hindsight it would have been better to move int to 64 bits (especially for C's integer promotion, which only really makes sense when the promotion happens to the register width.

But porting 32-bit code to 64-bit was a big deal back then, and C99 with its new fixed-width integer types overlapped with the first AMD64 CPUs (and Microsoft's MSVC didn't start to support C99 until around 2015 anyway), I guess keeping int on 32-bits in the popular compilers was deemed 'safer' for porting existing code. I guess we can already be lucky that all the big compilers agreed on the same int width.

userbinator•10m ago
On x86-64, you need an extra prefix to do 64-bit operations (while 64-bit addressing is the default), so it's a question of "are you sure you need the 64 bits and 32 isn't enough?"
Alpha3031•5m ago
[delayed]
pjmlp•10m ago
Kind of, the mistake was not doing like PL/I where besides default machine specific sizes, the developer could explicitly assert the required sizes.
flohofwoe•3m ago
C99 kinda fixed that with the `(u)int_leastN_t` types (which are hardly used in practice though). And shame that it took Microsoft 16 years to even start supporting C99 though so we were basically forced to do our own custom integer defines long after the C standard had fixed the issue.
adrian_b•7m ago
I agree that the C flexible integer sizes were still necessary at the time of its creation, when some important computers still had word sizes that were not powers of two.

Nonetheless, I started to use C for programming only in 1990, when I got access to the Microsoft C and Borland Turbo C compilers.

At that time, 36 years ago, the C flexible integer sizes were already obsolete.

Since that time until now, while using C on a great variety of computers, from servers and workstations to the smallest microcontrollers, I have seen plenty of portability problems created by the existence of the flexible integer sizes.

The only programs that had no portability problems were those that never used the flexible integer sizes, but only integers with a definite size, e.g. 8-bit, 16-bit, 32-bit or 64-bit.

While sizeof solves the problems of memory allocation or copying, it does not help much in preventing unexpected integer overflows, because writing code with multiple paths that would check or prevent overflow for different integer sizes is cumbersome.

lmz•2m ago
Meh. In today's world if exact sizes were not a requirement then you should use the int_fastN_t types to at least guarantee the width you are expecting instead of using the fixed size types (which may not be optimal) or using plain "int" which may be smaller than expected.

OpenAI Feared "Optics" of what might appear on Hacker News

https://authorsguild.org/news/ag-v-openai-top-execs-knew-mass-book-piracy-was-illegal/
117•papergirl•3h ago•77 comments

Does Georgism work? Five years later

https://www.astralcodexten.com/p/does-georgism-work-five-years-later
331•silveraxe93•1d ago•236 comments

Meta Blocks President Lula's Facebook Page, Campaign Ads 2 Weeks from Election

https://www.reddit.com/r/worldnews/comments/1wr3id3/meta_blocks_president_lulas_facebook_page_and/
30•rbanffy•43m ago•10 comments

Flip Fluid on Flip Dots

https://mitxela.com/projects/flipflip
67•blutack•1d ago•9 comments

Go Concurrency Distilled

https://antonz.org/go-concurrency-distilled/
215•chmaynard•18h ago•73 comments

PipePipe: NewPipe hard fork implementing SponsorBlock

https://github.com/InfinityLoop1308/PipePipe
410•Qision•1d ago•226 comments

Improving site performance by shipping more CSS

https://github.blog/engineering/architecture-optimization/improving-site-performance-by-shipping-...
38•torutofu•20h ago•21 comments

DeepSeek Elastic Compute (DSec)

https://arxiv.org/abs/2609.22978
238•shenli3514•15h ago•79 comments

Show HN: Reladraw – A diagram language where you decide where to place things

https://github.com/reladraw/reladraw
299•jpwalsh234•16h ago•82 comments

C's Flexible Integer Sizes Were Not a Design Mistake

https://pikuma.com/blog/c-integer-sizes-not-a-mistake
23•ibobev•1d ago•16 comments

A searchable library of forgotten public-domain film clips from 1915 onward

https://www.movingimagearchive.com/
172•momentmaker•2d ago•26 comments

Biology might not be quantum, but its math is quantumlike

https://www.quantamagazine.org/biology-might-not-be-quantum-but-its-math-is-quantumlike-20260923/
67•pseudolus•2d ago•23 comments

What is the size of Yemen? (2024)

https://theborys.substack.com/p/what-is-the-size-of-yemen
163•kspacewalk2•6h ago•35 comments

ASML says it sold 'absolutely nothing' in Europe in 2026

https://www.tomshardware.com/tech-industry/semiconductors/asml-says-its-sells-absolutely-nothing-...
273•MC995•1d ago•619 comments

Fifteen years later, the Apple Cards origin story

https://lexontech.org/fifteen-years-later-the-apple-cards-origin-story
393•ksec•1d ago•102 comments

The internet discovers TLA+. Now what?

https://reasonable.io/blog/tla-tutorial/
6•matt_d•4h ago•1 comments

Reverse-engineering the Intel 8087's tangent algorithm: more than CORDIC

https://www.righto.com/2026/09/8087-tangent-cordic.html
78•pwg•16h ago•11 comments

Drawgent: Coding agent on a live Excalidraw canvas

https://tangled.org/yanndegat.tngl.sh/drawgent
144•parasitid•17h ago•41 comments

LP Voting and Investor Consent for AIFs

https://taghash.io/blog/lp-voting-and-investor-consent-for-aifs-a-practical-workflow
3•koolhead17•1d ago•0 comments

An agent used DNS to reach an external chatbot

https://alignment.openai.com/misalignment-reports/an-agent-used-dns-to-reach-an-external-chatbot/
94•apsec112•1d ago•98 comments

Exploding variance of means of exponentials: least-squares to the rescue

https://francisbach.com/spectral_log_density_estimation/
29•matt_d•1d ago•0 comments

How I changed teaching after AI managed to do all my homework assignments

https://thelastsoftwareengineer.substack.com/p/how-i-changed-teaching-after-ai-managed
200•azhenley•2d ago•179 comments

Promising discoveries about the potential for life on one of Saturn’s icy moons

https://www.fu-berlin.de/en/presse/informationen/fup/2026/fup_26_116-enceladus-cassini-mikroben-s...
57•geox•1d ago•30 comments

Turning GLM-5.3-Flash into a Jev-like decision model

https://www.privatemode.ai/blog/system-one-from-glm-flash
92•flxflx•17h ago•38 comments

How to keep enjoying programming in a world of LLMs

https://discourse.haskell.org/t/how-to-keep-enjoying-programming-in-a-world-of-llms/14705
223•signa11•23h ago•269 comments

Snap Wants to be a State Actor??–Kansas v. Snap

https://blog.ericgoldman.org/archives/2026/09/snap-wants-to-be-a-state-actor-kansas-v-snap.htm
43•hn_acker•1d ago•12 comments

Evolving programming languages in the AI era

https://dashbit.co/blog/evolving-ai-era
90•pjm331•2d ago•56 comments

Modern Object Pascal Introduction for Programmers

https://castle-engine.io/modern_pascal
174•birdculture•2d ago•75 comments

Bob Mackie dressed stars–if they were brave enough

https://www.economist.com/obituary/2026/09/24/bob-mackie-dressed-stars-if-they-were-brave-enough
7•andsoitis•1d ago•1 comments

Generate fonts where every LLM token is the same width

https://ampdot.mesh.host/token-space-fonts.html
61•z-mach9•1d ago•12 comments