Most active commenters
  • lelanthran(5)
  • josephg(3)

←back to thread

271 points mithcs | 17 comments | | HN request time: 0.001s | source | bottom
Show context
cachius ◴[] No.45953162[source]
A recent superpower was added by Fil aka the pizlonator who made C more Fil-C with FUGC, a garbage collector with minimal adjustments to existing code, turning it into a memory safe implementation of the C and C++ programming languages you already know and love.

https://news.ycombinator.com/item?id=45133938

https://fil-c.org/

replies(3): >>45953284 #>>45953390 #>>45954377 #
762236 ◴[] No.45953390[source]
Why would I want to run a garbage collector and deal with it's performance penalties?
replies(4): >>45953453 #>>45953598 #>>45953991 #>>45961132 #
jerf ◴[] No.45953598[source]
Because about 99% of the time the garbage collect is a negligible portion of your runtime at the benefit of a huge dollop of safety.

People really need to stop acting like a garbage collector is some sort of cosmic horror that automatically takes you back to 1980s performance or something. The cases where they are unsuitable are a minority, and a rather small one at that. If you happen to live in that minority, great, but it'd be helpful if those of you in that minority would speak as if you are in the small minority and not propagate the crazy idea that garbage collection comes with massive "performance penalties" unconditionally. They come with conditions, and rather tight conditions nowadays.

replies(6): >>45953687 #>>45953716 #>>45953741 #>>45953976 #>>45959310 #>>45960864 #
hypeatei ◴[] No.45953687[source]
I think these threads attract people that write code for performance-critical use cases which explains the "cosmic horror" over pretty benign things. I agree though: most programs aren't going to be brought to their knees over some GC sweeps every so often.
replies(2): >>45954755 #>>45956652 #
1. KerrAvon ◴[] No.45954755[source]
Outside of hobbyist things, performance-critical code is the only responsible use case for a non-memory safe language like C in 2025, so of course it does. (Even that window is rapidly closing, though; languages like Rust and Swift can be better than C for perf-critical things because of the immutability guarantees.)
replies(3): >>45956586 #>>45956777 #>>45958223 #
2. lelanthran ◴[] No.45956586[source]
> Outside of hobbyist things, performance-critical code is the only responsible use case for a non-memory safe language like C in 2025, so of course it does.

Maybe; I sometimes write non-hobbyist non-performance-critical code in C.

I'm actually planning a new product for 2026 that might be done in C (the current iteration of that product line is in Go, the previous iteration was in Python).

I've few qualms about writing the server in C.

replies(2): >>45959510 #>>45960437 #
3. sramsay ◴[] No.45956777[source]
I keep hearing this, but I fail to see why "the massive, well-maintained set of critical libraries upon which UNIX is based" is not a good reason to use C in 2025.

I have never seen a language with a better ffi into C than C.

replies(1): >>45960432 #
4. jstimpfle ◴[] No.45958223[source]
Productivity, portability, stability, mind-share, direct access to OS APIs... there's a lot of reasons to still use C.
replies(1): >>45958583 #
5. pjmlp ◴[] No.45958583[source]
Only if the OS is written in C, and has its APIs exposed as C APIs to userspace.

Quite a few OSes don't fit that rule.

replies(1): >>45960892 #
6. josephg ◴[] No.45959510[source]
> I've few qualms about writing the server in C.

Bad Unicode support. Lack of cross platform system libraries. Needing to deal with CMake / autotools / whatever. Poor error handling. No built in string, list or map types. No generics. Nullability. No sum types. No option, tuples or multi returns. Generally worse IDE support than a lot of languages. No good 3rd party package ecosystem. The modern idiocy of header files. Memory bugs. Debugging memory corruption bugs. …

I mean, yeah other than all those problems, C is a great little language.

replies(1): >>45961860 #
7. lmm ◴[] No.45960432[source]
> the massive, well-maintained set of critical libraries upon which UNIX is based

What massive, maintained set is that? Base Unix is tiny, and any serious programming ecosystem has good alternatives for all of it.

8. lmm ◴[] No.45960437[source]
> I've few qualms about writing the server in C.

Why are you not worried about becoming the next Cloudbleed? Do you believe you have superhuman programming abilities?

replies(1): >>45961607 #
9. mbac32768 ◴[] No.45960892{3}[source]
Could you name two of these that are important to you?
replies(2): >>45961147 #>>45961871 #
10. cryptonector ◴[] No.45961147{4}[source]
Or even one. I know there are operating systems in use that are not written in C, but the major ones are written in C. And anyways, it's not just the OS. There's a pile of C code. Fil-C is a fantastic idea. I think Fil is going to make it good enough to use in production, and I badly want to use it in production.
11. lelanthran ◴[] No.45961607{3}[source]
> Why are you not worried about becoming the next Cloudbleed?

The odds are just too low.

> Do you believe you have superhuman programming abilities?

I do not believe I have superhuman abilities.

12. lelanthran ◴[] No.45961860{3}[source]
> Bad Unicode support. Lack of cross platform system libraries. Needing to deal with CMake / autotools / whatever. Poor error handling. No built in string, list or map types. No generics. Nullability. No sum types. No option, tuples or multi returns. Generally worse IDE support than a lot of languages. No good 3rd party package ecosystem. The modern idiocy of header files. Memory bugs. Debugging memory corruption bugs. …

You make some good, if oft-repeated, points; but for my product:

1. Bad Unicode support - I'm not sure what I will use this for; glyphs won't be handled by a server program and storage/search of UTF8/codepoints will be handled by the data store (PostgreSQL, if you must know).

2. CMake/autotools/etc - low list of 3rd party dependencies, so a plain Makefile works.

3. Worse IDE support than a lot of languages - not sure what you mean by this. C has LSP support, like every other language. I haven't noticed C support in editors to be worse than other languages.

4. No 3rd party package ecosystem - That's fine, I'm not pulling in many 3rd party packages, so those that are pulled in can be handled with the Makefile and manual updates.

5. The modern idiocy of header files - this confuses me; there is still no good alternative to header files to support exporting to a common ABI. Functions, written in C, will be callable from any other language because header files are automatically handled by swig for FFI.[1]

6. Memory bugs + debugging them - thankfully, using valgrind, then sanitisers in my build/test step makes this a very low priority for me. Not that bugs don't slip through, but single-exit error handling using goto's and cleanups make these kinds of bugs rare. Not impossible, but rare. Having the test steps include valgrind, then various sanitisers reduces the odds even more.

For the rest, yeah, nice to have "No built in string, list or map types. No generics. Nullability. No sum types. No option, tuples or multi returns. ", but those are optional to getting a product out. If C had them I'd use them, but I'm not exactly helpless without them.

The downside of writing a product in C, in 2025, isn't in your list above.

========================================

[1] One of my two main reasons for switching to C is because the product was so useful to paying clients that they'd like more functionality, which includes "use their language of choice to interact with the product.". Thus far I've hacked in solutions depending on which client wanted what, but there's limits to the hacked-in solutions.

IOW, "easily extendable by clients using their language of choice" is a hard product requirement. If it wasn't a hard requirement they can continue using the existing product.

replies(1): >>45962369 #
13. pjmlp ◴[] No.45961871{4}[source]
Android, userspace is Java, and what is exposed on the NDK is a tiny portion, as it is only meant for games and implementing native methods for better performance beyond what JIT/AOT do, or bindings to existing libraries.

About 80% of the OS APIs are behind JNI calls, when using the NDK.

iOS, iPadOS, watchOS, the large majority of userspace APIs is based on Objective-C, or Swift, bare bones C is only available for the POSIX leftovers.

You need to call the Objective-C runtime APIs for anything useful as an app that Apple would approve.

For the Plan 9 geeks, Inferno, OS APIs are exposed via Limbo.

For folks that still find mainframes and micros cool, IBM i, IBM z/OS, Unisys ClearPath MCP, Unisys OS 2200.

For retrogaming folks, most 8 and 16 bit home computers.

14. josephg ◴[] No.45962369{4}[source]
> You make some good, if oft-repeated, points

They're oft repeated because they're real problems.

> a plain Makefile works.

> C has LSP support, like every other language. I haven't noticed C support in editors to be worse than other languages.

Makefiles aren't supported well by clion or visual studio. LSP requires a compile-commands list to be able to work - which is a pita to export from makefiles. XCode and visual studio both require their own build systems. Etc etc. Its a mess.

Even if you set up LSP properly, debugging can still be a PITA. Most of the time, it doesn't "just work" like in many other languages.

In comparison, all Go projects look the same and all tooling understands them. Same for C#, Rust, Typescript, Zig, and many others.

> 5. The modern idiocy of header files - this confuses me; there is still no good alternative to header files to support exporting to a common ABI.

Other languages don't need header files, and yet they manage to export public interfaces just fine. Header files only exist because computers had tiny amounts of RAM in the 70s, and they couldn't keep everything in memory while compiling. The fact we keep them around in 2025 boggles my mind.

Header files create 2 problems:

1. You have to write them and keep them up to date as your function signatures change, which is pure overhead.

2. They slow down compilation, because the compiler has to re-parse your headers for every codegen unit. Yes, PCH exists - but its platform specific and complicated to set up yourself. You can use unity builds instead, but thats fiddly and it can cause other headaches.

> The downside of writing a product in C, in 2025, isn't in your list above.

What would you say the downsides of writing a product in C in 2025 are?

> One of my two main reasons for switching to C is because the product was so useful to paying clients that they'd like more functionality, which includes "use their language of choice to interact with the product."

Yeah; I agree that this is one area where C shines. I really wish we had better ways to do FFI than C ABI compatibility everywhere. Rust, Swift, Zig, C++ and others can of course all compile to static libraries that look indistinguishable from C object files. But if you're using those languages, writing a C API is another step. If you're already working in C, I agree that its much easier to write these APIs and much easier to keep them up to date as your code changes.

replies(1): >>45962642 #
15. lelanthran ◴[] No.45962642{5}[source]
> Makefiles aren't supported well by clion or visual studio.

I dunno what IDE support I might need - once the Makefile is written I'm not going to be constantly adding and removing packages on a frequent basis.

As for IDE's, I am not using Clion, Visual Studio or XCode. Vim, Emacs and VSCode work fine with C projects, even when debugging interactively.

> What would you say the downsides of writing a product in C in 2025 are?

Slower initial development compared to HLL like Go, Python, etc. Well, it's slow if you want to avoid the major classes of bugs, anyway. You can go fast in C, but:

a) It's still not going to be as high-initial-velocity as (for example) Python, Java or C#

and

b) You're probably going to have a lot more bugs.

My standard approach to avoiding many of the pitfalls in using C (pitfalls which are also applicable to C++) is to use a convention that makes it easier to avoid most logic bugs (which, in the process avoids most memory bugs too). This convention does require a little more upfront design, but a lot more code.

So, yeah, I'll go slightly slower; this is not a significant enough factor to make anyone consider switching languages.

> Other languages don't need header files, and yet they manage to export public interfaces just fine.

Only for the isolated ecosystem of that language. C header files can be used to automatically perform the FFI for every single mainstream language.

So, sure, other languages can an export an interface to a file, but that interface probably can't be used for FFI, and in the rare cases where it can, it can't be automatically used.

C headers can, and are, used to automatically generated bindings for other languages.

replies(1): >>45962837 #
16. josephg ◴[] No.45962837{6}[source]
> As for IDE's, [...] Emacs and VSCode work fine with C projects, even when debugging interactively.

I'm pretty sure VSCode still needs a compile commands file to do proper syntax highlighting. Again, difficult and annoying to generate automatically with makefiles.

To be clear, I'm not saying you can't set it all up. I'm just saying the IDE experience writing C is worse - obviously worse - than the experience programming in other modern languages.

> I'll go slightly slower; this is not a significant enough factor to make anyone consider switching languages.

Well, I can disprove that right now. I'm anyone. And the poor velocity writing C is a big reason I don't use it. Its just so much work to do simple things - like validate a UTF8 string. Or make a resizable array. Or write a function which can return either a value or an error.

In C, I feel like I'm a human compiler doing a bunch of things I want my compiler to do for me. C is slower to write and easier to mess up compared to more modern languages like Zig or Rust.

I did a side by side test a few years ago, implementing the same program in a variety of languages. The C code was about 2x as large as the same program in typescript, but it ran much faster. It was also much harder to debug. Zig and Rust were half the size of my C code and just as performant!

I don't see any reason to spend more work to achieve the same - or a worse - result.

> C header files can be used to automatically perform the FFI for every single mainstream language.

Every single one? I roll to doubt. Does the javascript ecosystem parse C header files for FFI? Does Java? C#? Rust? I know LuaJIT and Zig do, but I'm not sure about any others.

If C headers were only used for FFI, I wouldn't mind them so much. But they're also needed within a C program. And the semantics are idiosyncratic and weird. Want to inline something? It probably has to go in the header file as a static method. Want a global? Declare it in the header as an extern, and put it in exactly 1 C file. Structs? Did you want to declare the whole type or make it opaque? Because those are different. Functions can have different type signatures in header files and C files, but only in certain ways. And so on. So many weird, stupid rules you need to learn.

And by the time you've done all that, you're almost certainly leaving performance on the table as a result of not compiling the whole program in a single codegen unit.

Its 2025. Why waste your limited time on this earth acting as a human compiler? The computer can do a way better job of it.

replies(1): >>45963026 #
17. lelanthran ◴[] No.45963026{7}[source]
> I'm pretty sure VSCode still needs a compile commands file to do proper syntax highlighting. Again, difficult and annoying to generate automatically with makefiles.

TBH, I can't remember when I set VSCode up, or even if I did (may have just used a plugin and called it a day). ISTR something about clang, but it all just works so I didn't go into it to maintain

> To be clear, I'm not saying you can't set it all up. I'm just saying the IDE experience writing C is worse - obviously worse - than the experience programming in other modern languages.

If it is worse than Go, Java or C# in VSCode, I honestly did not notice, having used VSCode with all those languages.

> I don't see any reason to spend more work to achieve the same - or a worse - result.

Thankfully, the extra effort is very small, so I don't care because the extra payoff is so large.

> Every single one? I roll to doubt. Does the javascript ecosystem parse C header files for FFI? Does Java? C#? Rust? I know LuaJIT and Zig do, but I'm not sure about any others.

Okay, maybe not every single one, but Javascript (Node.js) and Java are definitely supported in Swig. C# supports native calling by default anyway so no swig support necessary, and Rust already can FFI into C code.

So, from your list, everything is supported.

> Its 2025. Why waste your limited time on this earth acting as a human compiler?

I'm not acting as a human compiler. Missing some optional features doesn't make me a human compiler (what a strange take, though. You sound personally aggrieved that someone who has delivered using Java, C#, Go, Python and more can be productive in C with only a small difference in velocity).

More language features rarely translate into more successful products. The most successful products, in terms of deployment numbers, were built with the least exciting technologies - plain Java prior to 2015, etc.