Not trying to be a troll but as someone who has also written a lot of C in the past why do you feel like this?
Not trying to be a troll but as someone who has also written a lot of C in the past why do you feel like this?
As when I’d pick Go because I was doing some concurrency, I can now explore a bunch of concurrency libraries, including some implementations that look a lot like Go channels. Want to watch a file for changes? I can do that all the way from taking to the kernel to picking a multi-platform library. I guess, I haven’t really found anything that I can’t do in C, and if I’m lazy, I can just embed and scripting language to handle things in a higher level. Macros are also very powerful! I’ve been writing code that writes code for me, export the thing to a .h file and import it using #include.
pkg-config —list-all has become my friend and I keep discovering that the world is written in C and the access to libraries is huge!
Also, idiomatic C is whatever you make it. There are a bunch of ways to skin a cat. Want a different platform? Build tool? Compiler? Debugger? Wanna write you own debugger? C is chill with that.
It’s also such a simple language that without much effort you can know everything about it (I don’t care that much about anything over C99). I don’t know the whole ecosystem, or standard libraries, or data structures and algorithms and whatnot, but the language itself is quite trivial.
With that said, I’m not using C in project teams. In that setting some strong conventions would likely be necessary or even better, something enforced by tools or the compiler (like Go), but yeah, I’ve been quite enjoying working with C and being kind of annoyed at other langs that I need to use for work because they keep doing all this stuff behind my back that is supposed to help me, but instead is a pain trying to debug and understand what is actually happening
- Access and control, nothing "behind your back"
- Low or high level, as you prefer
- Swap in different implementations (custom allocator, different async runtime, etc)
- Really powerful macros
- Strong conventions, safe by default (but you can break them, go into the weeds if needed)
Downsides compared to your list:
- More complex than C or Go (though less than C++)
- Only one production compiler, and everyone assumes `cargo` build system (though both are very good)
- Library ecosystem not quite as extensive (though there is a lot of good stuff on crates.io, and you can always write bindings to C)
The little things that seal the deal:
- Enums (tagged unions without the danger or boilerplate)
- Zero-cost closures
- Incremental compilation
- "If it compiles, it probably works"
- Standardized documentation via `rustdoc`
- Module system
Yes, I've tried rust and have even shipped some project with it! I think the things that didn't worked for me was the complexity. It felt like I had to keep a lot of things in mind to be effective, (traits can be a bit obscure, i.e. magic IMHO), also lifetimes and Option made the code complex by either having a bunch of math or .unwrap all over the place.
With that said tho, Rust would be one of my top picks for a professional setting or a codebase that I share with a team, because of the really good defaults that it has! I read once somebody comparing the Rust compiler with a bunch of tiny unit tests that the developer doesn't have to write, and I agree with that!
With C tho, for personal stuff I can do things that I've never do professionally (i.e. use the OS as my GC because when the process dies the OS is gonna "free" my memory allocations anyways! I know, terrible, but I'm having fun! ¯\_(ツ)_/¯)