I see a lot of love for #c here. I have limited experience with it and frequently wonder why one would choose to do any high-level #programming in C.

It's so low-level, so explicit that a simple program seems to explode into a ton of nitty-gritty details that just distract from the core logic and intent.

Can you enlighten me? Why do you love C?

@iooioio Nitpick: C isn't actually low-level. The compiler does so much magic to your code, and processors are so alien to the architecture that C was designed for, that C is almost as high-level as Swift.

@wizzwizz4 It's just a matter of where you're coming from. Sure, it's not low-level if you're comparing it to assembler. But if there is no language-level support for strings and you have to think about allocating and/or freeing memory for even the most basic tasks, I fail to imagine many user-facing applications this language would be the right fit for.

@iooioio "hello" (appends a \0 automatically), and variadic arrays?

I'm not comparing it to assembler; I'm comparing it to C-in-the-past. Modern C is a very high-level language (with a runtime, even!) masquerading as a low-level one.

@wizzwizz4 Huh, ok. I probably just don't know what modern C looks like then.

Is it possible to declare a variable as a string and have the compiler ensure that it is always used as a string? Or do you still have to work with pointers to random chunks of memory and just hope no one messed up?

@iooioio You use compiler flags, but other than that, yeah. Use const char * as the type and enable strict typing.

Follow

@iooioio

C is low level in a sense that the language itself lacks facilities for user defined abstractions, so you have to push your abstractions out of the language and into the runtime. For a large project in the long term these abstractions matter much more than the language, and there are plenty of existing code you can borrow from.
The lack of language level support also gives a specific flavor to C abstractions, they are very opaque - the language will not help you to recognize/understand them, and very general - once you finally manages to get a good abstraction, you tend to want to use it for absolutely everything you can, since it was hard work to get it.
I made a reference counter, so now everything is reference counted! I made a file system abstraction, so now "everything is a file"! I made process manager/scheduler so now "everything is a process"! etc.

@wizzwizz4

@namark Those are some really good points. Thanks for sharing.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.