3 ms·
I would like C to have a native String type, and the primitives could be function pointers, replaceable in those cases when custom handling is needed (e.g. insi
by epx 13y ago
I would like C to have a native String type, and the primitives could be function pointers, replaceable in those cases when custom handling is needed (e.g. inside kernel). Object Pascal is sort like that.
- eric_bullington 13y agoD has this. A lot of people assume that D is just C++ with some GC and some improvements, but it's really more like C with GC and some improvements -- including a native String type. There's also a string module in the standard library that includes a lot of convenience methods, including ones for interoperating with C and for working with Unicode[1]. For someone like me with a background in dynamic languages like Python and Lua, as well as some background in C, D was a great fit. Unlike when I started learning C++, D felt like a very natural extension of C to include GC and lots of modern language features. Lamentably, not many people are interested in D, and so aren't yet a lot of third-party libraries, and many of those that are abandoned. But the core language and standard library are great, and there's a nicely growing and incredibly fast web framework (vibe.d). And Facebook has started supporting the language. So hopefully it will start seeing some growth. 1. http://dlang.org/phobos/std_string.html http://dlang.org/phobos/std_string.html
- thinkpad20 13y agoI've gone down this route of thinking many times. Inevitably, as soon as I think of all of the features that I would want in C, I simply end up with a language that's not C any more... for precisely that reason. C isn't that kind of a language; it's a high-level assembly language and little more. Most of the things that C is lacking, it is by design, because of performance reasons and/or need for fine-grain control of the machine. As another respondent mentioned, there are other languages that fill that need (C++, D, Rust, Nimrod), basically all of the systems languages that are designed to do C's job easier and safer (but probably not faster).
- anon4 13y agoYou can always use something like bstring. It will always be compatible with other libraries that take a pointer and a length.