5 ms·
It's nice to see more and more C++ articles. Some additions: - The least you allocate on the heap, the better. Move semantics really help in that aspect; - S
by shin_lao 14y ago
It's nice to see more and more C++ articles.
Some additions:
- The least you allocate on the heap, the better. Move semantics really help in that aspect;
- Smart pointers are not magic. Although I really think using unique_ptr whenever possible is a good idea, shared_ptr comes with a performance cost (especially in multithreaded environments), can introduce vicious memory leaks and is often used as an excuse to not think your lifetime cycle through.
- pjmlp 14y agoI also like it. C++ suffered for a long time due to lack of quality libraries. This now seems to be finally changing, at least until another language is a good enough replacement for it. I am keeping an eye how D and Rust evolve, additionally Ada seems to be getting some users, at least here in Europe.
- mhd 14y agoAda in Europe? Interesting, where did you encounter that? As for quality libraries, I'd almost say that we had too much of them. For every platform and every different C++ methodology/subset (from "C with Classes, ocassionally Structs" to "Post-Modern Template Abuse") had its own set of supporting libraries. Often good enough, but most of the time not the ideal source for your particular project, and very hard to integrate, if every code paragraph follows a different paradigm, depending on what library your calling. Still don't see a good solution to that. Quite likely that your GUI library won't quite mesh with your collections, data parsing or network support.
- pjmlp 14y ago> Ada in Europe? Interesting, where did you encounter that? I heard it at this year FOSDEM. Since GNAT availability many universities seem to be making use of it. As for the industry I guess it still constrained to the usual types of systems where Human life is very important. As for the libraries you're doomed to have that for all libraries that are not part of the standard library. Even the "comes with batteries" languages suffer from this when you need to integrate external libraries. If Java and .NET didn't happen, maybe there would already be an InteliJ for C++. I am looking forward for the tooling progresses made possible by using the compiler as plugins, as clang shows.
- mhd 14y agoWell, if you've got a pretty big standard library, you've got more on which to base external libraries on, regarding the style of the code. The STL alone didn't really provide a big enough template. Sometimes it even went the opposite way, so when you read something in lower-case letters with underscores, you knew that you were using the "core C++ language", putting things like "vector" and "reverse" closer to keywords than library APIs. Especially if the rest of the code base was the usual OO class forest. I knew of Ada use in teaching, it seems to be quite popular for some advanced "software engineering" courses. Then again, I've seen a pretty great amount of Algol-family languages there, out of proportion to the actual practical use. Oberon was quite popular for a while, as it was a very small language to teach and the barriers to running your first programs were basically non-existant (as you can easily call your module function directly, compared to the rather perplexing "public static void main" of introductory Java courses).
- snogglethorpe 14y agoEh? C++ has always had a pretty good selection of libraries, way better than most languages (and of course, a bazillion times better than D/Rust/Ada...). Many library authors will choose to make a C interface instead, as that basically makes the library usable by almost any language, but C++ seems near the top when it comes to language-specific library support.
- pjmlp 14y agoIn what planet have you been leaving? What are the C++ libraries for - Networking - XML - Reflection - ORM - Database access - UI - Asynchronous programming - Make use of std::string and STL, instead of providing their own types. - Web Services - ... Don't forget that your list should provide libraries that work across multiple OS (UNIX and Windows are not enough) and multiple compilers (besides gcc, clang, msvc). The libraries also need to be compatible with the possibility that the developers compile with exceptions, RTTI enabled/disabled. Did you know that STL was actually developed in Ada and later on adopted to C++?
- bostonpete 14y agoQt provides most or all of the things in your list -- just to name one.
- pjmlp 14y agoYou forgot my requirement, in addition to the list: > Don't forget that your list should provide libraries that work across multiple OS (UNIX and Windows are not enough) and multiple compilers (besides gcc, clang, msvc). EDIT: typo
- bostonpete 14y agoI didn't forget it, I ignored it b/c it seemed unrelated to your original complaint about a lack of quality libraries. Linux/Windows/Mac support is plenty for many people. Out of curiosity, what platforms do you need to use which are unsupported by Qt but work well with other languages...?
- zem 14y agoyeah, and this was a very well-written one. rust is doing some very interesting things with lifecycle management too; it will be interesting to see how d and rust influence the evolution of c++