6 ms·
I see a lot of discussion around C++ becoming modern. I would like to know which features are actually modern? Is it lambdas? been around for literally decades
by Guthur 12y ago
I see a lot of discussion around C++ becoming modern. I would like to know which features are actually modern?
Is it lambdas? been around for literally decades.
Is it type deduction? again been around for quite some time, far better type inference has been available in the likes of Haskell for quite some time.
Is it addition of a particular threading model to the standard? this has always been available via some form of library, it just know means the language is truly obsolete if the model changes.
Allow GC'd implementations? again decades.
What is modern about any of features that have been added?
- pjmlp 12y agoThe way all those languages are used together. Not writing modern C++ means: - writing C++ as if it was plain C - doing OO programming with big object graphs - manual memory management - not using the standard containers and algorithms - writing functor objects
- tomp 12y agoHow can you not use manual memory management in C++? Say you're writing a compiler, which uses a quite complex, possibly circular, graph structure of objects for its AST representation. You can't use SharedPtrs (cycles), can't use UniquePtrs (sharing of graph nodes), can't use RAII (unpredictable lifetime). I see no better solution than a GC.
- pjmlp 12y agoWhy can't you use them? Lots of compilers written in C++ use them. Ever heard of weak_ptr?
- maxlybbert 12y agoEven Stroustrup says that there are times garbage collection is the right solution. But, some people are surprised that there are times it isn't needed, and that garbage collection always brings the burden on unordered finalization (e.g., it's possible for an object's members to be finalized before the object, so finalizes must be written in a way that assumes very little about what is valid regarding data members).
- pjmlp 12y agoWhen Java appeared, there GC enabled system programming languages like Modula-3 and Oberon, with stack allocation. Modula-3 generics are good enough to even implement reference counting data structures. The going VM craziness of the last two decades pushed such languages away from the mainstream and thus younger generations get surprised by such approaches.
- claudius 12y ago> What is modern about any of features that have been added? Nothing. On the other hand, which features of a “modern” language are missing in C++ by now? Type deduction is still a bit less powerful than in Haskell, yes, but apart from that I can’t really think of anything that may or may not be missing. This in turn implies that C++ allows essentially any style of coding you may wish for at the moment while at the same time staying some orders of magnitude faster than essentially the entire competition.
- Guthur 12y agoC++ is no faster than any other language, it's the code that is written which is measurable. The real wins in performance for real world applications are in terms of algorithmic complexity. A poorly implemented solution in C++ will still be slow, the language does not make it fast. Any micro optimization you can make with C++ will be an order magnitude less significant than O(log n) vs O(n). The likes of Janestreet will likely need high performance software yet have great success with Ocaml for example, which incidentally can be very fast. Just saying C++ is fast does not make programs written in C++ actually fast.
- claudius 12y ago> The real wins in performance for real world applications are in terms of algorithmic complexity. A poorly implemented solution in C++ will still be slow, the language does not make it fast. Yet a well written implementation in C++ will still be faster than an equally well-written implementation in, say, Python or Haskell or whatever. Not in an asymptotic sense, but easily by a factor ranging between two and 200. For me, this can be the difference between waiting a couple of weeks or half a year for some computation to complete :) > Just saying C++ is fast does not make programs written in C++ actually fast. Of course not, but C++ makes it possible for programs written in C++ to be fast.
- pkolaczk 12y agoComparing to Python or Haskell, maybe you're right, but not to CLR-based or JVM-based statically typed languages. Very often the differences between Java/C# and C++ are the same order of magnitude as differences between various C++ compilers. The mythological C++ performance is often overstated (there are some performance advantages in C++ but they are rarely big enough to justify language choice).
- mmaldacker 12y agoC++ is 35 years old and predates Haskell and many other "modern" languages like Java, C#, Python, ... So yes, compared to what C++ was originally, it has become modern.
- Guthur 12y agoMy point is that none of the features are modern. Comparing a later version of language to an earlier one to measure modernism seems rather pointless.
- pkolaczk 12y agoI think we should start using the term "modern Java" for writing Java with lambdas, or "modern PHP" to write PHP with OOP and exceptions. :D
- ksk 12y ago>Comparing a later version of language to an earlier one to measure modernism seems rather pointless. C++ is a production ready systems language, not a theoretical CS research paper. How do you propose we define modern in this context then? As I'm sure you're aware, it takes years to vet design features, debate whether they can be implemented, whether they affect performance, whether they have unintended side-effects, whether they break existing code, etc. 'Modern' concepts are already old by then. Also, sometimes features can't be added to a language because of practical real-world issues that have nothing to do with the language itself. (e.g. longer compile times). I don't see anything particularly wrong with calling a language modern as it adopts features. Certainly, I would agree that one should not then claim the language to be modern in the sense of cutting edge research.
- Guthur 12y agoIt implies that the features are somehow new and ground breaking. Lambdas have been understood for many many years, the same goes for GC. The were not only in the domain of academia. Common Lisp has many of these features and more, being a multi-paradigm programming language. And has been used in industry for many many years. Yet people say CL is antiquated while it has so called 'modern' features.
- stinos 12y agoI would like to know which features are actually modern? Close to none of course, but that isn't the point AFAIK. The point is all of them have now been added, hence the 'modern' connotation, and another part of the point is that C++ now even more is a language rather flawlessly combining all those paradigms.