5 ms·
It's amazing what credible competition can do. If only C had the same kind of pressure.
by vunie 7y ago
It's amazing what credible competition can do. If only C had the same kind of pressure.
- eps 7y agoDon't you even dare. C is near-perfect in the simplicity of its core. You want bells and whistles, you hook up a library.
- billfruit 7y agoC has many rough spots too, especially in organising large and complex programs. There is always scope for innovation and improvements.
- user5994461 7y ago>>> There is always scope for innovation and improvements. but not in C because C has no scope
- weberc2 7y agoCould you refer me to a good/standards-compliant library for typesafe generic lists, hashmaps, pattern matching, closures, etc?
- huhtenberg 7y agoYou are missing the main strength of C - the transparency and predictability of what machine code gets generated from the source code. When you write "a + b", you won't end up with kilobytes of machine code just because someone in some header overloaded the + operator. Ditto for template-style generics and overloaded functions. If you call a function and it doesn't exist, it won't get auto-generated for you on the fly. You get an error. You want a function, you define that function. That's not the flaw of the language. That's its strength. Ditto for switch-case constructs. Ditto for closures. All of these constructs, should they be added to the language, will result in a compiler generating heaps of code from a simple code snippet. But this will no longer be C, because in C what you see is what you get.
- Jataman606 7y agoIf you call function and it doesnt exist you get a warning "implicit declaration of function". Unless you use additional compiler flags.
- huhtenberg 7y agoNot since C99. But even regardless of that you still get a linking error.
- weberc2 7y agoI'm not missing anything, I'm responding to a specific claim--that libraries allow C to compensate for missing language features. This is patently false irrespective of the merits of the features in question. That said, I think your entire criteria for determining whether a language or feature is good boils down to its intuitiveness to experienced C programmers, which seems like a particularly poor, subjective criteria and it probably doesn't actually even hold for C considering all of the security issues and undefined behaviors that are introduced by and continue to surprise experienced C programmers. For my money, closures, pattern matching, and templates (not any implementation in particular) are easy enough to reason about and much better than the corresponding bugs they address, but to each his own.
- hayez1 7y ago>For my money, closures, pattern matching, and templates (not any implementation in particular) are easy enough to reason about and much better than the corresponding bugs they address Then write C++ only using closures, pattern matching and templates outside of the C feature set.
- weberc2 7y agoOh no, did my previous comments read as an exhaustive list of issues with C?
- reggieband 7y ago
- jupp0r 7y agoNo, you write macros (duck and hide).
- doboyy 7y agoTypesafe generics via a better void* would make me super happy. There are definitely other quality of life improvements that could be added or reworked that wouldn't affect the simplicity too much.
- sdegutis 7y agoI'd say Rust is the improvements to C that I've always been wanting: better type safety, real generics, first-class closures, and OOP without inheritance, only using structs to structure data, leaving code execution to just functions. It's what I hoped Go would become. (Take with grain of salt, I'm just starting to learn Rust.)
- doboyy 7y agoI really don't like the monomorphization approach to generics (I think that's the concept?), where the function/struct essentially gets duplicated for each type. It seems to mess with linkage, increase binary sizes, and increase compile times. Other than that, Rust does seem to be an improvement and less... stressful to program in.
- tick_tock_tick 7y agoYou can always role dynamics dispatch yourself
- twic 7y agoDynamic dispatch is in the language too. use core::fmt::Display; fn show_monomorphic<T: Display>(first: T, second: T) { println!("{} then {}", first, second); } fn show_polymorphic(first: &dyn Display, second: &dyn Display) { println!("{} then {}", first, second); } pub fn main() { show_monomorphic(17, 23); show_monomorphic("fnord", "slack"); show_polymorphic(&42, &"quirkafleeg"); // mixed types! } There are things you can do with each that you can't do with the other, but they are often both viable choices.
- 7y ago
- vmchale 7y ago> If only C had the same kind of pressure. ATS :p
- fluffything 7y agoWho is using ATS in production? When I learned it I wondered why would somebody use it instead of Rust or Idris.