3 ms·
The problem with this idea is C is an advanced language requiring one to be very careful with memory (referencing, allocation, deallocation, etc). If we are to
by jasonjei 10y ago
The problem with this idea is C is an advanced language requiring one to be very careful with memory (referencing, allocation, deallocation, etc). If we are to keep C in its essence with well-defined behavior, managing memory still seems to be part of the job description.
I think what you are describing is Rust, Go, C++11 RAII with reference counting, Objective-C with ARC. I like to think of C as an abstraction of assembly. Of course, the above languages often use libraries or OS APIs implemented with C function calls (as well as having resource handles); these library functions may not always have a nice wrapper around them.
C is a very concise, barebones and syntactically simple language. I think some of the problem is that there is a lot of behavior that is not well-defined resulting in different interpretations in different compilers. I think there are proposals to make C more standardized.
I think C++11 has made great moves to being consistent across all compilers. Having a thread library that is cross-platform, for example, is a very good move.
- jjnoakes 10y agoNope. I'm specifically describing only the rough edges of C. Things like defining a NULL pointer to convert from any zero value. Nothing as ambitious as a nrw language, like I said above. I want a modern version of exaxtly what C is, without some of these undefined or implementation defined legacy warts. And I understand that defining some things may make the program barely measurably slower. Someone can opt in to raw C if they care. It could even be in the same file... Think scoped "pragma overflow" directives that last for the lexical scope to get raw speed by opting out of defined semantics.
- stephen82 10y agoI guess what you really want is what Microsoft is trying to resolve with Checked C in order to bridge the C gap with C++. Here's the link if you are interested: https://github.com/Microsoft/CheckedC https://github.com/Microsoft/CheckedC
- jjnoakes 10y agoI don't think so; Checked C looks to be focusing on array bounds checking and adds new syntax, new pointer types, etc. I want to focus on cleaning up C as it is. I don't want a new syntax or new semantics outside of defining some/most of what is undefined today.
- stephen82 10y agoI would be more than interested to see a demo code using pseudo-language to explain exactly the concept you have in mind. That would be more than interesting for lots of us and you never know; we might get something out of it and why not implement it as a FOSS project?
- jjnoakes 10y agoThe friendly C and boring C proposals are quite close to what I'm thinking of. I was sad to see friendly C abandoned. I hope to find the time shortly to take a stab at something along those lines.