3 ms·
The problem with C is they left too many things completely on the wild. Strings and memory management are all laissez-faire and everybody does whatever they thi
by alecco 18y ago
The problem with C is they left too many things completely on the wild. Strings and memory management are all laissez-faire and everybody does whatever they think is right.
A typical performance issue is calling malloc/free all the time, it can be avoided but there are no standard ways.
I hope some great features of C++ get some day backported to C. But don't bet money on that :(
- liuliu 18y agoC believes that programmer doesn't make mistakes. About memory management, I don't think it should be a language feature because there are some good implemented libraries out there.
- alecco 18y agoLike? (No sarcasm.) I tend to see all major projects end up doing things their way: OpenSSL, Apache HTTPd, GCC, Linux, BSD, for example.
- scott_s 18y agoI used to do research with multithreaded memory allocators. The best of class is, I think, TCMalloc, which is a part of Google's perftools: http://code.google.com/p/google-perftools/ http://code.google.com/p/google-perftools/. Hoard is also suitable for use in real applications: http://www.hoard.org/ http://www.hoard.org/ Then there's my work, which is frankly not suitable for using in a real application since it's tested as heavily as the other two I mentioned: http://people.cs.vt.edu/~scschnei/streamflow/ http://people.cs.vt.edu/~scschnei/streamflow/
- alecco 18y agoCool! I didn't know Google did a plain C one (thought those were C++) and yours looks interesting. But my original point was there is no stantard way. It should be part of CXX, libc, or POSIX, IMHO. C is just too atomized.
- scott_s 18y agoThere's a standard interface, but there's no standard implementation - which is how standards generally work. Also, I can't edit my post, but that should say "it's not tested as heavily."
- alecco 18y agoI was thinking more along the lines of automatic memory in my original grandparent post. [yeah, I guessed you meant that from the sentence structure]
- scott_s 18y agoThen C is not what you're looking for. I'm not arguing against garbage collected languages, but for the necessity of non-GC languages to exist.
- alecco 18y agoHmmm, not so fast... This is not cool: In particular, at startup TCMalloc allocates approximately 6 MB of memory.
- scott_s 18y agoDepends on your needs. TCMalloc trades space for speed.
- holygoat 18y agoThe later C standards add additional features. However, I'd argue that there is no such thing as a "great feature" in C++: almost everything in the language is a mistake, either intrinsically or in combination with other 'feature's. It's a blind pig with fifteen legs, trying to put on its own lipstick while riding a unicycle.
- orib 18y agoSpoken like someone who truly doesn't understand C. You even managed to confuse it with C++ (you might as well have said "Java" in the place of C++, it's about as close to C as C++ is) Well done. edit: Ignore this post. I misread. I'm an idiot. Sorry about that
- alecco 18y agoThe language is quite overcomplicated, yes. But there are many mitigations making the whole thing quite appealing. C++ template libraries are cleaner, easier to improve and adapt, and often faster than the C counterparts (when there are counterparts!) A good example was how OpenMP was added to the basic types in the STL (on GNU/gcc/libc++) by a quite small group of people last year. Another example are the regular expression libraries. I'm not an Stroustroup/C++ apologist but this language is the absolute best in several traits. I like to code in Python the most but C and C++ are still fun and make sense in their own way. I hate languages that make programming hard just because they follow an overcomplicated paradigm and don't give you anything useful back from that (like Java, IMNSHO.) In particular all languages with multi-million dollar advertisement campaign just piss me off (the language, not the tools.)
- scott_s 18y agoC is, as the author points out, a portable assembly language. If a portable assembly language is not what you need - for example, you want better string support and memory management - then don't use C.
- alecco 18y agoThen why the authors did a standard library from the beginning? (including strings) The problem is it's quite dated (30 years). There isn't anything wrong with the language itself and most languages evolve with time.
- scott_s 18y agoBecause back when C first was designed and implemented, the alternative was to do string manipulation in assembly. C has evolved over time, but it has not left its niche: a systems programming language which is a thin abstraction of hardware. If you want a higher abstraction of the hardware, then C is not your best choice.