4 ms·
Writing code in C is very unpleasant, verbose and repetative. For example, if I want to have a structure in C and have a way to print its contents, or free its
by codedokode 2y ago
Writing code in C is very unpleasant, verbose and repetative. For example, if I want to have a structure in C and have a way to print its contents, or free its memory and memory of nested structures, or clone it recursively, it is very difficult to make automatically. I found only two options: either write complicated macros to define the structure and functions (feels like writing a C++ compiler from scratch), or define structure in Python and generate the C code from it.
I looked at C++, but it seems that despite being more feature-rich, it also cannot auto-generate functions/methods for working with structures?
Also returning errors with dynamically allocated strings (and freeing them) makes functions bloated.
Also Gnome infrastructure (GObject, GTK and friends) requires writing so much code that I feel sorry for people writing Gnome.
Also, how do you install dependencies in C? How do you lock a specific version (or range of versions) of a dependency with specific build options, for example?
- codr7 2y agoSimplify. If you try to write the same complicated mess in C as you would in any other language it's going to hurt. Not having a package manager can be a blessing, depends on your perspective.
- int_19h 2y agoThere's no amount of simplification that'll free you from the need to manually check and handle/propagate errors or deallocate resources in C. You might be able to reduce the amount of code you need to write, but it's still several lines of C versus one line of something else - and if you make a mistake or even forget something in those several lines, things will often compile and run fine, but you'll have memory leaks or sporadic crashes.
- codr7 2y agoI don't have these issues in C, you're projecting. Not that I write bug free software by any means; no one does, though some like to pretend.
- int_19h 2y agoUnless you're writing "hello world" level software, the best you can say about any significant amount of code written in C is that you don't know about any such issues in it.