Post AcsUfATIWyhetbQsXA by holgerschurig@emacs.ch
 (DIR) More posts by holgerschurig@emacs.ch
 (DIR) Post #Acqe4qRs6pBVb1AF1c by louis@emacs.ch
       2023-12-15T22:56:37Z
       
       1 likes, 1 repeats
       
       I recently develop a strong urge for programming in #C (again). Despite its shortcomings, it is timeless and has much to offer to the curious programmer. Great new projects are programmed in C and compilers got really good at spotting potential bugs (say hello to -Wall -Wextra -pedantic).In times of "safe" languages like Go and Rust, it is really fun to get down to the roots of computing with C. Last but not least, the Emacs core is written in C. That's another strong reason to get my hands dirty again.
       
 (DIR) Post #AcqegbvwWXDhaCEoPQ by cjd@pkteerium.xyz
       2023-12-15T23:03:29.716660Z
       
       0 likes, 0 repeats
       
       I wanna write a fully asynchronous stdlib for OpenCL and just code in that
       
 (DIR) Post #AcqgoCNJdKSMXVmrgm by adx@hachyderm.io
       2023-12-15T23:27:12Z
       
       0 likes, 0 repeats
       
       @louis I’ve been programming a Gemini client for myself in C lately. It’s been nice to do a mid-sized project in the language again. Sometimes it does get frustrating needing to write a whole function with lots of error checking that’s 1 line in some other languages.
       
 (DIR) Post #AcqlJ51BR5lKW3PqHg by pkw@mastodon.sdf.org
       2023-12-16T00:17:35Z
       
       0 likes, 0 repeats
       
       @louis I learned c later in my programming journey so i can totally relate.I like doing the malloc delete dance.  And counting the size of things before allocating.  And adding 1 if it's going to be a string :PAlso it's neat to use man pages for dev work.
       
 (DIR) Post #AcqnSp7baprQ1CC3Vo by galdor@emacs.ch
       2023-12-16T00:41:48Z
       
       0 likes, 0 repeats
       
       @louis you absolutely should. It’s a great way to train yourself at being more attentive and precise when programming.
       
 (DIR) Post #AcqyUBgcHaBrmqQGEi by yeti@emacs.ch
       2023-12-16T02:45:19Z
       
       0 likes, 0 repeats
       
       @louisI'll read this again...Stephen KellSome Were Meant for CThe Endurance of an Unmanageable Languagehttps://www.humprog.org/~stephen//research/papers/kell17some-preprint.pdf...soonish!
       
 (DIR) Post #AcsTvbMuCG1YzhiNrU by holgerschurig@emacs.ch
       2023-12-16T20:12:20Z
       
       0 likes, 0 repeats
       
       @louis Beside -Wall etc look also into clangd (e.g. with eglot or lsp-mode). It has "clazy" built in, and can do some semantic checking. It's nowhere near as good as Coverity, but hey, it's FOSS.
       
 (DIR) Post #AcsUfATIWyhetbQsXA by holgerschurig@emacs.ch
       2023-12-16T20:20:35Z
       
       0 likes, 0 repeats
       
       @louis Here is my .clang-tidy file, which is honored by clangd: https://0x0.st/HYuP.txtAnd I meant "static analyzer", not "semantic checking". Basically, clangd has built-in what "scan-build" can do.So, while editing, I get clang's warning. And when I compile, I use GCC. So two different compilers look over my code, and this is quite helpful.Drawback of clangd: you need a compilation database. But both CMAKE and Meson (which I prefer) create them. If you're on pure makefiles, than you'd need something like https://github.com/rizsotto/BearBest of this: this all works not only with C, but also with C++. I program mostly in "mild C++", without STL or Boost, but with Qt, even non-GUI programs. They have all the containers I ever need, and with a much more eye-pleasing C++ code than idiomatic C++ code with tons of < > and : characters sprinkling your code.
       
 (DIR) Post #AcsaBfoo1ENB9boOiO by louis@emacs.ch
       2023-12-16T21:22:26Z
       
       0 likes, 0 repeats
       
       @holgerschurig Hey, thanks so much for all that valuable knowledge 🙂  I'm currently running through some books and videos to refresh my rusty C knowledge and still use basic Emacs c-mode. Still trying to figure out the whole ecosystem around C. What's the actual difference between clang and GCC (besides GCC being GNU)? Would be great if you could share some insights on that.
       
 (DIR) Post #AcsfbpDCDUExaSVegi by holgerschurig@emacs.ch
       2023-12-16T22:23:14Z
       
       0 likes, 0 repeats
       
       @louis They are two different compilers. Sometimes one is faster, sometimes the other, but basically they are equivalent, i.E. you cannot say "compile all with X and your programs are 20% faster". The clang suite has things like clazy (code style checker), scan-build (static analyzer), the C source code formatter and all of this built into the language server "clangd" that the GCC suit is lacking. On the other side, for Linux programs GCC is more batle proofed because all distros are compiled by default with GCC.Clangs static analyzer is however more advanced than the GCC one.Also they spit out slightly different warnings. For that reason some CI/CD environments use both. I similarly do that by using clangd via eglot (so I get its warnings and checks first) and GCC for the actual compile step. I program in a style that no compiler spits out any warning at all. That makes the programs somewhat robust.But still not as robust as using the (glacially slow) Rust compiler, or the (slow when you have maaaaany source files) Nim compiler.
       
 (DIR) Post #AcuaNvwSHqiyx19iam by fourier@functional.cafe
       2023-12-17T20:34:05Z
       
       0 likes, 0 repeats
       
       @louis Just wait until you need to do some strings manipulations or so... :(
       
 (DIR) Post #AcucbAuu7aNn4Gs81I by fourier@functional.cafe
       2023-12-17T20:58:50Z
       
       0 likes, 0 repeats
       
       @louis tbh C is not bad. Just for anything significant you have to have a bunch of libraries at hand - unicode, collections and data structures, algorithms etc and a lot of discipline in handling errors and resource allocation, and at some point you would wonder why not to introduce some parts of C++ here and there, just because it helps you to solve some tedious tasks without compromising on performance. At work I'm free to use both C (with all necessary libs, we have own inhouse OS with stuff) and C++ and sometimes with I just drop to write some  C++ since it feels the solution might be way cleaner and easy to maintain without much of a performance penalty, of a cost of having, you know, c++, which is not yet very well known by embedded engineers