frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Testing the Swift C compatibility with Raylib (+WASM)

https://carette.xyz/posts/swift_c_compatibility_with_raylib/
32•LucidLynx•2d ago

Comments

acarette•2d ago
Thanks for sharing it!

I might be interested on how to build the WASM build more easier with Swift tools. I guess some tools exist to facilitate the final builds, but did not found it...

Do not hesitate to comment if someone experienced this before.

keldaris•1h ago
Out of curiosity, how does the size and performance of the generated WASM compare to just compiling the same Raylib example from the equivalent C code via Emscripten? In other words, how much overhead does the choice to use Swift add here or in general?
flohofwoe•1h ago
Raylib has a C API though, and this is 'easy-mode' in any language (even without integrated bindings generation like Swift or Zig have - e.g. it's fairly trivial to write a bindings generator that uses Clang's ast-dump json file format as input and translates the API declarations into another language.

A more interesting question would be how well the C++ interoperability works that was added in Swift 5.9, does it work with all C++ headers, even headers that make extensive use of template code. Also how does Swift extract information needed for lifetime tracking, e.g. C++ APIs that return smart pointers and object lifetime ends on the caller's side. Does this only work for C++ stdlib smart pointer types, or are custom types also supported.

repelsteeltje•1h ago
For sure — that's where it gets difficult.

Show me a real C++ interop example. Does function, constructor and operator overloading resolve correctly? How about C++26 reflection?

Someone•47m ago
> A more interesting question would be how well the C++ interoperability works

They’re using it in their work on FoundationDB. Looks good, but has limitations. Swift can call C++ and vice versa, Swift classes can inherit from C++ and vice versa, but not for all code, and may need work adding annotations on the C++ side. See https://github.com/apple/foundationdb/blob/main/SWIFT_GUIDE.....

There’s a good video on that work from a few years ago that was discussed on HN in https://news.ycombinator.com/item?id=38444876.

enbugger•1h ago
> So, if you want to build games using raylib, why not learn learning or use Swift for that?

Never ever worked for me. Imagine, you actually learned basic Swift and Raylib, now you want "advanced" features in your game like navigation/pathfinding, model loading, ImGui, skeletal animation (those are actually vital for gamedev). You realize that

- Navigation is only ReCast which is pure C++ library,

- ImGui has C++ API as first-class citizen,

- Decent animation with compression is only open-sourced by OzzAnimation which is pure C++ project.

For gamedev interfacing with C is never enough, half of ecosystem is built heavily on C++. Even C++ interop is not enough (see Dlang). Without all those libraries you are bound to make boring 2d platformers.

Same for Zig, Odin, C3 etc.

flohofwoe•1h ago
> ImGui has C++ API as first-class citizen

Dear ImGui via the C bindings is actually quite nice and not much less convenient than the C++ API (the only notable difference is that the C API has no overloads and default params).

E.g. here's a control panel UI (from the below ozz-animation sample) with the 'Dear Bindings' approach (using a custom 'ig' prefix)):

https://github.com/floooh/sokol-samples/blob/d8429d701eb7a8c...

Dear ImGui is a bit of an outlier for C++ libraries though, since it is essentially a C API wrapped in a namespace.

OzzAnimation is also fairly trivial to wrap in an (abstracted) C API, for instance I use this in some of the sokol-samples:

https://github.com/floooh/sokol-samples/blob/master/libs/ozz...

Implementation: https://github.com/floooh/sokol-samples/blob/master/libs/ozz...

...used in this sample:

https://github.com/floooh/sokol-samples/blob/master/sapp/shd...

...WASM live version:

https://floooh.github.io/sokol-html5/shdfeatures-sapp.html

TL;DR: quite a few C++ libraries out of the game-dev world are actually quite easy to access from C or languages that can talk to C APIs, mainly because the game-dev world typically uses a very 'orthodox' subset of C++ (no or very restricted C++ stdlib usage, no rtti, no exceptions, ideally no smart pointers in the public API).

adamrezich•7m ago
> Without all those libraries you are bound to make boring 2d platformers.

Perhaps if you're completely devoid of imagination.

It is in fact possible to make video games without deferring to open-source libraries for every single aspect of it.

leecommamichael•10m ago
> So, if you want to build games using raylib, why not learn learning or use Swift for that?

Because Apple won't fix Swift's abysmal compile times, and there are languages with similar or better ergonomics without that flaw.

LiteLLM Python package compromised by supply-chain attack

https://github.com/BerriAI/litellm/issues/24512
615•theanonymousone•5h ago•254 comments

Run a 1T parameter model on a 32gb Mac by streaming tensors from NVMe

https://github.com/t8/hypura
76•tatef•1h ago•40 comments

Hypothesis, Antithesis, Synthesis

https://antithesis.com/blog/2026/hegel/
80•alpaylan•2h ago•41 comments

No Terms. No Conditions

https://notermsnoconditions.com
108•bayneri•1h ago•31 comments

Show HN: Gemini can now natively embed video, so I built sub-second video search

https://github.com/ssrajadh/sentrysearch
63•sohamrj•2h ago•25 comments

Show HN: Email.md – Markdown to responsive, email-safe HTML

https://www.emailmd.dev/
24•dancablam•1h ago•2 comments

Testing the Swift C compatibility with Raylib (+WASM)

https://carette.xyz/posts/swift_c_compatibility_with_raylib/
32•LucidLynx•2d ago•9 comments

Nanobrew: The fastest macOS package manager compatible with brew

https://nanobrew.trilok.ai/
102•syrusakbary•6h ago•59 comments

Microsoft's "Fix" for Windows 11: Flowers After the Beating

https://www.sambent.com/microsofts-plan-to-fix-windows-11-is-gaslighting/
769•h0ek•8h ago•557 comments

Tony Hoare and His Imprint on Computer Science

https://cacm.acm.org/blogcacm/tony-hoare-and-his-imprint-on-computer-science/
22•matt_d•3d ago•3 comments

LaGuardia pilots raised safety alarms months before deadly runway crash

https://www.theguardian.com/us-news/2026/mar/24/laguardia-airplane-pilots-safety-concerns-crash
179•m_fayer•2h ago•139 comments

Debunking Zswap and Zram Myths

https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-what.html
125•javierhonduco•7h ago•30 comments

Ripgrep is faster than grep, ag, git grep, ucg, pt, sift (2016)

https://burntsushi.net/ripgrep/
257•jxmorris12•11h ago•104 comments

Secure Domain Name System (DNS) Deployment 2026 Guide [pdf]

https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-81r3.pdf
70•XzetaU8•5h ago•6 comments

curl > /dev/sda: How I made a Linux distro that runs wget | dd

https://astrid.tech/2026/03/24/0/curl-to-dev-sda/
118•astralbijection•7h ago•49 comments

WolfGuard: WireGuard with FIPS 140-3 cryptography

https://github.com/wolfssl/wolfguard
38•789c789c789c•1h ago•23 comments

Opera: Rewind The Web to 1996 (Opera at 30)

https://www.web-rewind.com
161•thushanfernando•9h ago•99 comments

io_uring, libaio performance across Linux kernels and an unexpected IOMMU trap

https://blog.ydb.tech/how-io-uring-overtook-libaio-performance-across-linux-kernels-and-an-unexpe...
34•tanelpoder•4h ago•13 comments

Apple Business

https://www.apple.com/newsroom/2026/03/introducing-apple-business-a-new-all-in-one-platform-for-b...
125•soheilpro•2h ago•111 comments

Box of Secrets: Discreetly modding an apartment intercom to work with Apple Home

https://www.jackhogan.me/blog/box-of-secrets/
241•jackhogan11•1d ago•90 comments

So where are all the AI apps?

https://www.answer.ai/posts/2026-03-12-so-where-are-all-the-ai-apps.html
243•tanelpoder•3h ago•247 comments

Log File Viewer for the Terminal

https://lnav.org/
269•wiradikusuma•12h ago•42 comments

Country that put backdoors in Cisco routers to spy on world bans foreign routers

https://www.theregister.com/2026/03/24/fcc_foreign_routers/
10•beardyw•10m ago•1 comments

The Jellies That Evolved a Different Way to Keep Time

https://www.quantamagazine.org/the-jellies-that-evolved-a-different-way-to-keep-time-20260320/
20•jyunwai•4d ago•5 comments

LLM Neuroanatomy II: Modern LLM Hacking and Hints of a Universal Language?

https://dnhkng.github.io/posts/rys-ii/
73•realberkeaslan•7h ago•26 comments

MSA: Memory Sparse Attention

https://github.com/EverMind-AI/MSA
76•chaosprint•3d ago•5 comments

iPhone 17 Pro Demonstrated Running a 400B LLM

https://twitter.com/anemll/status/2035901335984611412
689•anemll•1d ago•314 comments

Autoresearch on an old research idea

https://ykumar.me/blog/eclip-autoresearch/
406•ykumards•23h ago•90 comments

BIO – The Bao I/O Co-Processor

https://www.crowdsupply.com/baochip/dabao/updates/bio-the-bao-i-o-co-processor
79•hasheddan•2d ago•21 comments

NanoClaw Adopts OneCLI Agent Vault

https://nanoclaw.dev/blog/nanoclaw-agent-vault/
97•turntable_pride•4h ago•28 comments