frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Fingerprints are the new cookies

https://royfish.dev/fingerprints-are-the-new-cookies
199•royfish•6h ago•88 comments

Total Annihilation, rebuilt for modern computers

https://nanolathe.gg
425•jttnr•10h ago•180 comments

Whatever became of holography? (2011)

https://www.americanscientist.org/article/whatever-became-of-holography
100•cainxinth•5h ago•47 comments

Calculus with Julia

https://jverzani.github.io/CalculusWithJuliaNotes.jl/
50•subset•1d ago•1 comments

Cartographers of North Korea (2019)

https://cartographers-nk.wonyoung.so/
219•edent•9h ago•39 comments

X Is Bad, Though

https://lexontech.org/x-is-bad-though
36•ayaros•1h ago•17 comments

Doory – Open-Source Canva

https://github.com/shaongitbd/doory
46•acley•4h ago•8 comments

No portable way to detect string-to-float conversion errors in standard C

https://sebsite.pw/w/20261009-strtod.html
15•signa11•1d ago•5 comments

The gap in shared understanding of LLM capability is widening

https://twitter.com/karpathy/status/2109361546505966046
344•albertzeyer•8h ago•515 comments

Illustration Beyond Proof

https://terrytao.wordpress.com/2026/10/11/illustration-beyond-proof/
50•smilelamp•5h ago•0 comments

Terence Tao: Math 2.0 [pdf]

https://teorth.github.io/tao-web/slides/math-2-0-caltech-2026.pdf
355•Anon84•15h ago•401 comments

Vectorized CLZ and CTZ

https://purplesyringa.moe/blog/vectorized-clz-and-ctz/
28•zX41ZdbW•1d ago•3 comments

Google is illegaly cutting forest to build data centers

https://www.theguardian.com/technology/2026/oct/06/google-datacentres-finland-temporary-halt-envi...
284•heyimada•6h ago•74 comments

Building a VMM from scratch, #0: Why BoxLite is replacing libkrun

https://blog.boxlite.ai/building-a-vmm-from-scratch-0-why-boxlite-is-replacing-libkrun
3•dorianzheng•18h ago•0 comments

Local Indexing to reduce tool calling and token usage

https://tedhaley.ca/pensieve/
47•TedHaley•4h ago•10 comments

Chapter 1 of "Ways of Seeing" by John Berger (1972)

https://www.ways-of-seeing.com/ch1
93•rafael859•10h ago•14 comments

Passkeys are a trap

https://nonfunctional.substack.com/p/passkeys-are-a-trap-do-not-use-them
409•laurex•7h ago•229 comments

So, You’d Like To Sell Your Print Issues Of The Onion?

https://theonion.com/archivehunt/
288•mooreds•9h ago•40 comments

Programmable pigments: Photochromic nanoparticle inks for rewritable tattoos

https://www.cell.com/matter-light/fulltext/S3117-5848(26)00119-5
36•Bluestein•19h ago•4 comments

Recursive self-improvement through collective intelligence

https://pub.sakana.ai/mass/
86•hardmaru•6h ago•46 comments

I guess I'm using WebP now?

https://anderegg.ca/2026/10/08/i-guess-im-using-webp-now
94•Brajeshwar•2d ago•96 comments

NYC's "Click to Cancel" rule is now in effect

https://www.nyc.gov/main/click-to-cancel
408•gregsadetsky•11h ago•197 comments

Show HN: BetterWispr – Free, open-source dictation for Mac

https://betterwispr.com/
180•kartik017•17h ago•103 comments

ClickHouse C – Talk to ClickHouse using its native binary protocol

https://github.com/ClickHouse/clickhouse-c
23•saisrirampur•5h ago•1 comments

Shredding JSON columns gave Logfire up to 1000x faster queries

https://pydantic.dev/articles/dynamic-shredding-2026-01-26
15•acossta•6h ago•8 comments

apsw: Another Python SQLite Wrapper

https://github.com/rogerbinns/apsw
75•tosh•12h ago•16 comments

Tattoos you can turn on and off

https://www.livescience.com/technology/cool-chemistry-trick-allows-new-tattoos-to-turn-on-and-off
40•MortyDev•7h ago•13 comments

HashiCorp archives the Boundary open source repo

https://github.com/hashicorp/boundary
58•vmatsiiako•4h ago•12 comments

Valen's Memory Safety: A New Kind of Borrow Checking

https://verdagon.dev/blog/valen-group-borrowing
152•verdagon•16h ago•80 comments

Safe SIMD in Rust, even on the inside

https://shnatsel.github.io/safe-simd-in-rust-even-on-the-inside/
53•ravenical•1d ago•3 comments
Open in hackernews

Detecting if an expression is constant in C

https://nrk.neocities.org/articles/c-constexpr-macro#detecting-if-an-expression-is-constant-in-c
49•signa11•1y ago

Comments

wahern•1y ago
> This works. But both gcc and clang warn about the enum being anonymous... even though that's exactly what I wanted to do. And this cannot be silenced with #pragma since it's a macro, so the warning occurs at the location where the macro is invoked.

You can use _Pragma instead of #pragma. E.g.

  #define C(x) ( \
    _Pragma("clang diagnostic push") \
    _Pragma("clang diagnostic ignored \"-Wvisibility\"") \
    (x) + 0*sizeof(void (*)(enum { tmp = (int)(x) })) \
    _Pragma("clang diagnostic pop") \
  )
EDIT: Alas, GCC is a little pickier about where _Pragma is allowed so you may need to use a statement expression. Also, it seems GCC 14 doesn't have a -W switch that will disable the anonymous enum warning.
pjc50•1y ago
It's remarkable that people will say that doing this kind of thing is better than learning a language which actually lets you enforce this with the type system.

(or even just insist that users use the version of the language which supports "constexpr"!)

oguz-ismail•1y ago
What language is that? Is it available everywhere (everywhere) C is?
mitthrowaway2•1y ago
Indeed, usually if I'm using C these days it's because I only have access to a c compiler for my target platform, or because I'm modifying an existing C codebase.
uecker•1y ago
I do not think anybody said this. The point is that these macros work for early versions of C. If you need to support early versions of C, learning another language is not a solution. If you don't have to, you can use C23's constexpr.
trealira•1y ago
C used to seem like a beautiful and simple language to me, but as I used it and learned more about it, it seemed more complex under the surface, and kind of janky as well. It's just utilitarian.
wat10000•1y ago
Learning such a language doesn’t mean I can use it.
o11c•1y ago
The problem is that no such language exists.

There are many languages that provide one particular feature that C doesn't provide, but they do this at the cost of excluding numerous other features that C widely relies on.

kjs3•1y ago
"I have no idea what problem you're trying to solve, what the constraints are, what the use cases might be, what tools are available on the platform, what the job or regulations require, what the skillsets of the people involved are, what the timeline is...but I'm absolutely, unshakably certain that I have a magic bullet that will make all your problems go away."

FTFY.

sleirsgoevy•1y ago
The Linux kernel has even a way to determine whether the expression is compile-time, WITHOUT aborting compilation in either case.

The trick is this (copied vebratim from Linux):

#define __is_constexpr(x) (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))

Explanation: if x is a constant expression, then multiplying it by zero yields a constant 0, and casting a constant 0 to void* makes a null pointer constant. And the ternary expression, if one of its sides is a null pointer constant, collapses to the type of the other side (thus the type of the returned pointer will be int*, and the sizeof will match). And if x was not constant, then the lefthand side would not be considered a null pointer constant by type inference, the type of the ternary expression will be void*, and the sizeof check will not match.

With a few more clever tricks, it's even possible to implement a compile-time "type ternary expression", like this: TYPE_IF(2 * 2 == 4, int, long). This is left as an exercise for the reader.

amelius•1y ago
This reminds me of the days when Boost was a thing. It was full of tricks like this.
usrnm•1y ago
It still is a thing, though.
cperciva•1y ago
With a few more clever tricks...

I did this with my PARSENUM macro (https://github.com/Tarsnap/libcperciva/blob/master/util/pars...) to parse strings into floating-point, unsigned integer, or signed integer types (and check bounds) using a single interface.

bobbyi•1y ago
I thought this would work:

#define C(x) (sizeof(char[x]), x)

sizeof is a compile-time operation so x need to be known at compile time.

It didn't work as expected. It turns out there is an exception and the standard says that sizeof is actually calculated at runtime specifically for variable length arrays:

> The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is an integer. If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant.