5 ms·
I love Rust, but I miss C. If C can be updated to make it generally socially acceptable for new projects, I'd happily go back for some decent subset of things I
by jvanderbot 1y ago
I love Rust, but I miss C. If C can be updated to make it generally socially acceptable for new projects, I'd happily go back for some decent subset of things I do. However, there's a lot of anxiety and even angst around using C in production code.
- mikewarot 1y agoIf you can stomach the occasional Begin and End, and a far less confusing pointer syntax, Pascal might be the language for you. Free Pascal has some great string handling, so you never have to worry about allocating and freeing them, and they can store gigabytes of text, even Unicode. ;-)
- jvanderbot 1y agoIf my fellow devs cringe at C, imagine their reaction to Pascal
- mikewarot 1y agoC has all the things to hate in a programming language CaSe Sensitivity Weird pointer syntax Lack of a separate assignment token Null terminated strings Macros - the evil scourge of the universe On the plus side, it's installed everywhere, and it's not indent sensitive
- jvanderbot 1y agoAt this point, you're talking to someone who isn't here
- ioasuncvinvaer 1y agoExcept for null terminated strings these don't seem like mayor issues to me. Can you elaborate?
- 1718627440 1y ago> Lack of a separate assignment token What does that mean?
- kbolino 1y agoAssignment is = which is too close to equality == and thus has been the source of bugs in the past, especially since C treats assignment as an expression and coerces lots of non-boolean values to true/false wherever a condition is expected (if, while, for). Most compilers warn about this at least nowadays.
- tialaramex 1y agoEven with warnings this is just terrible. People need to stop inventing languages where "False" is true, or an empty container is false or other insane "coercions" of this kind. True is true, and false is false, if you're wondering whether this Doodad is Wibbly, you should ask that question not rely on a convention that Wibbly Doodads are somehow "truthy" while the non-Wibbly ones are not.
- zelphirkalt 1y agoYou mean "mere string replacement macros, instead of hygienic macros", of course : )
- cryptonector 1y ago> C has all the things to hate in a programming language > CaSe Sensitivity Wait, what, you.. you want a case-insensitive language? Like SQL? I love SQL, but please no more case-insensitive programming languages!
- tgv 1y agoOr try Ada.
- flohofwoe 1y ago> to make it generally socially acceptable for new projects... Or better yet, don't let 'social pressure' influence your choice of programming language ;) If your workplace has a clear rule to not use memory-unsafe languages for production code that's a different matter of course. But nothing can stop you from writing C code as a hobby - C99 and later is a very enjoyable and fun language.
- xxs 1y agoI was about the reply no amount of pressure can tell me how to program. C was totally fine for esp32
- TimorousBestie 1y ago> Or better yet, don't let 'social pressure' influence your choice of programming language ;) It’s hard. Programming is a social discipline, and the more people who work in a language, the more love it gets.
- spauldo 1y agoIf you're on UNIX or working in the embedded space, C is still everywhere and gets lots of love. C tends to get lots of libraries anyway because everything can FFI to it.
- Y_Y 1y agoI don't want to summon WB, but honest-to-god, D is a good middle ground here.
- bnferguson 1y agoFeels like Zig is starting to fill that role in some ways. Fewer sharp edges and a bit more safety than C, more modern approach, and even interops really well with C (even being possible to mix the two). Know a couple Rust devs that have said it seems to scratch that C itch while being more modern. Of course it's still really nice to just have C itself being updated into something that's nicer to work with and easier to write safely, but Zig seems to be a decent other option.
- pjmlp 1y agoAs usual the remark that much of the Zig's safety over C, has been present since the late 1970's in languages like Modula-2, Object Pascal and Ada, but sadly they didn't born with curly brackets, nor brought a free OS to the uni party.
- dnautics 1y ago(self-promotion) in principle one should be able to implement a fairly mature pointer provenance checker for zig, without changing the language. A basic proof of concept (don't use this, branches and loops have not been implemented yet): https://www.youtube.com/watch?v=ZY_Z-aGbYm8 https://www.youtube.com/watch?v=ZY_Z-aGbYm8
- purplesyringa 1y agoHow close are Zig's safety guarantees to Rust's? Honest question; I don't follow Zig development. I can't take C seriously because it hasn't even bothered to define provenance until now, but as far as I'm aware, Zig doesn't even try to touch these topics. Does Zig document the precise mechanics of noalias? Does it provide a mechanism for controllably exposing or not exposing provenance of a pointer? Does it specify the provenance ABA problem in atomics on compare-exchange somehow or is that undefined? Are there any plans to make allocation optimizations sound? (This is still a problem even in Rust land; you can write a program that is guaranteed to exhibit OOM according to the language spec, but LLVM outputs code that doesn't OOM.) Does it at least have a sanitizer like Miri to make sure UB (e.g. data races, type confusion, or aliasing problems) is absent? If the answer to most of the above is "Zig doesn't care", why do people even consider it better than C?
- modeless 1y agoFil-C is a modified version of Clang that makes C and C++ memory safe. It supports things you wouldn't expect to work like signal handling or setjmp/longjmp. It can compile real C projects like SQLite and OpenSSL with minimal to no changes, today. https://github.com/pizlonator/llvm-project-deluge/blob/deluge/Manifesto.md https://github.com/pizlonator/llvm-project-deluge/blob/delug...
- tialaramex 1y agoFil-C does seem like a quicker route if your existing idea was something like "rewrite it in Java" and it exists today whereas both C and C++ have only vague ambitions to deliver some future language which might meet your needs. I will be very surprised if there's widespread adoption of Fil-C for many new projects though.
- cryptonector 1y agoA big stumbling block is that Fil-C requires all C in the program to be built with Fil-C, including all libraries. That means that Debian and such would need to either adopt Fil-C (perhaps for some distros) or ship Fil-C and non-Fil-C libraries for all pkgs with libraries. The alternative is that you have to build everything yourself, and this gets painful if you need to support ELFs/DLLs.
- uecker 1y agoDo you really love Rust, or do you feel pressured to say so?
- grg0 1y agoHe grew up in a very stringent household. Everybody was writing Rust and he was like, "damn, I wish I could write C."
- deleted 1y ago[deleted]
- bmn__ 1y agohttps://github.com/tsoding/crust https://github.com/tsoding/crust