frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

SectorC: A C Compiler in 512 bytes

https://xorvoid.com/sectorc.html
124•valyala•4h ago•22 comments

Tiny C Compiler

https://bellard.org/tcc/
9•guerrilla•47m ago•2 comments

The F Word

http://muratbuffalo.blogspot.com/2026/02/friction.html
57•zdw•3d ago•21 comments

Brookhaven Lab's RHIC concludes 25-year run with final collisions

https://www.hpcwire.com/off-the-wire/brookhaven-labs-rhic-concludes-25-year-run-with-final-collis...
29•gnufx•3h ago•24 comments

FDA Intends to Take Action Against Non-FDA-Approved GLP-1 Drugs

https://www.fda.gov/news-events/press-announcements/fda-intends-take-action-against-non-fda-appro...
3•randycupertino•8m ago•1 comments

Speed up responses with fast mode

https://code.claude.com/docs/en/fast-mode
65•surprisetalk•4h ago•79 comments

Software factories and the agentic moment

https://factory.strongdm.ai/
104•mellosouls•7h ago•198 comments

Hoot: Scheme on WebAssembly

https://www.spritely.institute/hoot/
147•AlexeyBrin•10h ago•26 comments

Stories from 25 Years of Software Development

https://susam.net/twenty-five-years-of-computing.html
107•vinhnx•7h ago•14 comments

OpenCiv3: Open-source, cross-platform reimagining of Civilization III

https://openciv3.org/
856•klaussilveira•1d ago•262 comments

You Are Here

https://brooker.co.za/blog/2026/02/07/you-are-here.html
5•mltvc•43m ago•1 comments

Italy Railways Sabotaged

https://www.bbc.co.uk/news/articles/czr4rx04xjpo
23•vedantnair•49m ago•14 comments

The Waymo World Model

https://waymo.com/blog/2026/02/the-waymo-world-model-a-new-frontier-for-autonomous-driving-simula...
1101•xnx•1d ago•619 comments

First Proof

https://arxiv.org/abs/2602.05192
71•samasblack•7h ago•51 comments

Vocal Guide – belt sing without killing yourself

https://jesperordrup.github.io/vocal-guide/
246•jesperordrup•14h ago•82 comments

Al Lowe on model trains, funny deaths and working with Disney

https://spillhistorie.no/2026/02/06/interview-with-sierra-veteran-al-lowe/
67•thelok•6h ago•12 comments

Show HN: A luma dependent chroma compression algorithm (image compression)

https://www.bitsnbites.eu/a-spatial-domain-variable-block-size-luma-dependent-chroma-compression-...
12•mbitsnbites•3d ago•0 comments

I write games in C (yes, C)

https://jonathanwhiting.com/writing/blog/games_in_c/
146•valyala•4h ago•122 comments

Start all of your commands with a comma (2009)

https://rhodesmill.org/brandon/2009/commands-with-comma/
524•theblazehen•3d ago•195 comments

Show HN: I saw this cool navigation reveal, so I made a simple HTML+CSS version

https://github.com/Momciloo/fun-with-clip-path
34•momciloo•4h ago•5 comments

Reinforcement Learning from Human Feedback

https://rlhfbook.com/
95•onurkanbkrc•9h ago•5 comments

Selection Rather Than Prediction

https://voratiq.com/blog/selection-rather-than-prediction/
15•languid-photic•3d ago•5 comments

72M Points of Interest

https://tech.marksblogg.com/overture-places-pois.html
39•marklit•5d ago•6 comments

The AI boom is causing shortages everywhere else

https://www.washingtonpost.com/technology/2026/02/07/ai-spending-economy-shortages/
198•1vuio0pswjnm7•11h ago•289 comments

A Fresh Look at IBM 3270 Information Display System

https://www.rs-online.com/designspark/a-fresh-look-at-ibm-3270-information-display-system
51•rbanffy•4d ago•11 comments

France's homegrown open source online office suite

https://github.com/suitenumerique
627•nar001•8h ago•277 comments

Coding agents have replaced every framework I used

https://blog.alaindichiappari.dev/p/software-engineering-is-back
263•alainrk•9h ago•437 comments

Unseen Footage of Atari Battlezone Arcade Cabinet Production

https://arcadeblogger.com/2026/02/02/unseen-footage-of-atari-battlezone-cabinet-production/
126•videotopia•4d ago•40 comments

Where did all the starships go?

https://www.datawrapper.de/blog/science-fiction-decline
103•speckx•4d ago•129 comments

Show HN: Kappal – CLI to Run Docker Compose YML on Kubernetes for Local Dev

https://github.com/sandys/kappal
37•sandGorgon•2d ago•17 comments
Open in hackernews

Generalizing Printf in C

https://webb.is-a.dev/articles/generalizedprintf/
41•oliverkwebb•2mo ago

Comments

theamk•2mo ago
On GNU systems, if you want to generalize printf, all you need is vfprintf - because there is:

"fmemopen(3)" that creates FILE* that writes to pre-allocate dbuffer

"open_memstream(3)" that creates FILE* that writes to auto-allocated buffer;

and if that's not sufficient, there is "fopencookie(3)" which takes general callbacks and creates FILE* that redirects all operations to those callbacks.

If that does not work for some reason, then having custom callback with user-passed 3 parameters is too much. Why add dedicated FILE* or "size" parameters which are only ever used in one specific case? Do a generic "void * context" argument ("int (write)(char data, void * context)" + "void * context") and let user figure out how to use it.

pizlonator•2mo ago
Yeah

Pretty sure a vfprintf-like function sits at the bottom of the printf stack in all of the libc's I've surveyed (which includes BSDs). And yeah, BSDs also support memstream APIs, for example https://man.openbsd.org/fmemopen.3

nwellnhof•2mo ago
fmemopen and open_memstream are both part of POSIX, so they're not restricted to GNU systems and can be used portably. fopencookie is a GNU extension, though.
kazinator•2mo ago
sprintf can be safely used.

- For some conversions, you can establish an upper bound on how many characters they will produce. E.g. a positive decimal integer not more than 9999 does not consume more than four characters.

- It's possible to specify truncation. e.g. "%.64s" prints at most 64 characters from the string argument.

- There are enirely static cases that can be worked out at compile time, e.g.

  char big_enuf_buf[BIG_ENUF_BUF_SIZE];
  sprintf(big_enuf_buf, "%x-%04x-%04x", MAJOR, MINOR, BUILD); // preprocessor constants
Even if the buffer isn't big enough, and the behavior is formally undefined, it is entirely analyzable at compile time and we have support for that: the compiler can work out that the conversion needs, e.g., 13 bytes, including null termination, but the buffer only has 12.

The reasons for analyzing to it wouldn't necessarily just be for diagnostics, but possibly for compiling it down to a literal:

  char big_enuf_buf[BIG_ENUF_BUF_SIZE] = "A1-0013-000A";
lelanthran•2mo ago
If you really hit the pathological edge case of needed sprintf at runtime with runtime-only buffer sizes, you can still work out the size safely, albeit slowly.

I've done it to make a "safe" sprintf function that allocates the destination buffer, so that the caller cannot overrun it: https://github.com/lelanthran/libds/blob/56d6e18c8970b84c9fa...

theamk•2mo ago
btw, what you did is called "asprintf" in many stdlibs
kevin_thibedeau•2mo ago
idx should be a size_t.
einpoklum•2mo ago
Actually, there are historical reasons why `int` may be used. Look at the definition of the %n format specifier - it expects an `int *` argument. And all of the famirly functions return `int`'s ... see also:

https://stackoverflow.com/q/45740276/1593077

einpoklum•2mo ago
A popular standalone printf-family library in the embedded world is, well, printf :

https://github.com/eyalroz/printf

which is independent of a C standard library (it doesn't actually do any I/O itself). Originally by Marco Paland, now maintained, or 'curated' by myself (so, this is a bit of a self-plug, even though I can barely claim authorship). It offers this generalization :

  int fctprintf(void (*out)(char c, void* extra_arg), void* extra_arg, const char* format, ...);
  int vfctprintf(void (*out)(char c, void* extra_arg), void* extra_arg, const char* format, va_list arg);
The library is not performance-oriented, but rather small-code-size-oriented. The family of functions therefore all have a single backing implementation. You might think that implementation must use the function generalization quoted above, but actually it uses a gadget with some more functionality:

  typedef struct {
    void (*function)(char c, void* extra_arg);
    void* extra_function_arg;
    char* buffer;
    printf_size_t pos;
    printf_size_t max_chars;
  } output_gadget_t;
jmclnx•2mo ago
And in the old days, there was disp_printf() from Zortech. That was a very nice printf. You supplied the row and column to allow printing anywhere on the terminal.