3 ms·
In my opinion, what C is lacking isn’t primarily language features - it’s: 1) a common, readable style standard that people can agree on 2) modern agreed-upon i
by msaltz 9y ago
In my opinion, what C is lacking isn’t primarily language features - it’s:
1) a common, readable style standard that people can agree on
2) modern agreed-upon idiomatic ways to write readable and safe code. There are certainly common C idioms but many exist for historical reasons and not because they’re necessarily the best things to do, and
3) a standard library that exemplifies the above two things, provides common functionality needed between projects, and fosters a sense of community
Efforts like those of the poster don’t really address these things.
When I tell people I like C, the response differs depending on experience level. Less experienced people who haven’t spent time in C++ either will say “Gross, pointers”. People used to C++ will say “what about templates and constructors/destructors”, and “are you going to write your own library for vectors and maps every time?” And people who are experienced (more experienced than me) and like C have generally said that the main things they miss from C++ are constructors and destructors (and mostly destructors), and templates (but only for container types), but that they can live without them.
C is a small language that can be relatively easy to write (once you pick/write a suitable stl-equivalent), and extremely easy to read (and to the extent that you can look at a line and know exactly what’s going on under the hood). IMO it should stay that way.
Take a look at zproject [0] for what I think is a good effort to standardize C style and project structure. Even if you disagree with the particular design choices, the spirit of it is what I think is needed to keep people from just assuming C is for dinosaurs.
[0] https://github.com/zeromq/zproject/ https://github.com/zeromq/zproject/
- sanbor 9y agoI have little experience with C but my feeling is that it's a waste of time to have to deal with memory in my program. I don't just have to worry about the problem that I'm trying to solve but also about handling the memory properly. Of course there are scenarios where writing a fast and lightweight app is part of the problem but for many projects that's not the case. I'm fine with pointer arithmetic and all that but I'm not fine with the constant fear that I did some oversight and my app is going to crash and I'll have to spend time debugging what's going on.
- Retra 9y agoMost programming problems are pretty trivial to solve if you're willing to ignore performance. It behooves us to realize that the main difference between mathematics and computer science is that computer scientists have to account for the several orders of magnitude difference between the runtime costs of different operations. If that weren't an obstacle, we'd basically only need one programming language, and it would like pretty much like standard mathematics. So I interpret your comment as something like "I don't want to program, I just want to assemble mathematical statements", which is a fine and perfectly legitimate thing to do, but it also seems a bit lazy, impractical, and probably irrelevant, given the subject.
- sanbor 9y agoMy point was about why invest time in C dealing with memory with the risk of segfaults when there many other languages like JS, Java, Go that would take care of that task for you. Also I'm talking about projects (e.g. building a word processor), not programming problemns (e.g. invert this binary tree). In my experience projects are complex systems with many moving parts interacting and most bugs comes from the complexity of the system/problem. With C, I don't just have to think about the problem that I'm solving but if I did something wrong when dealing with memory allocation/releasing. I don't have much experience in C except from the basics so I hope to hear from people that loves C why they choose it or if its just a constraint inherent to the problem they're dealing with.
- jacknews 9y agoI agree. The proposal adds a bunch of ugly and unnecessary syntax without addressing any of the real issues with C