What if anything have we learned from C++? [video]
11–20 of 56 posts
Re: What if anything have we learned from C++? [video]
#12After twenty years of using it? That I was wrong, that plain-old C really is better.
What I've learnt is that if you start writing C++ as a plan-old C, you quickly find yourself reaching for this and that feature from C++ that makes your job easier and your code more readable. Knowing where to stop is the tricky part.
Re: What if anything have we learned from C++? [video]
#13Something like TypeScript is to JavaScript, or like Kotlin is to Java. Would make the experience much nicer without having to wait on the slow C++ standardization process or deal with all the backwards compatibility baggage from the past (to a degree).
Re: What if anything have we learned from C++? [video]
#14Re: What if anything have we learned from C++? [video]
#15Re: What if anything have we learned from C++? [video]
#16Re: What if anything have we learned from C++? [video]
#17After twenty years of using it? That I was wrong, that plain-old C really is better.
What I've learnt is that if you start writing C++ as a plan-old C, you quickly find yourself reaching for this and that feature from C++ that makes your job easier and your code more readable. Knowing where to stop is the tricky part.
The "object-orientedness" of C++ really boils down to implicitly passing the this pointer to member functions, inheritance + virtual functions, and namespaces. All of these can be emulated in what I would call "C with discipline". Just be consistent in your naming conventions, always use a common prefix for globally visible functions and types, and use structs of function pointers whenever you really need virtual functions.
Re: What if anything have we learned from C++? [video]
#18Earlier quoted context omitted.
What I've learnt is that if you start writing C++ as a plan-old C, you quickly find yourself reaching for this and that feature from C++ that makes your job easier and your code more readable. Knowing where to stop is the tricky part.
Coding in plain C99 with some discipline can actually get you most of the benefits of C++, without any of its quirks. The "object-orientedness" of C++ really boils down to implicitly passing the this pointer to member functions, inheritance + virtual functions, and namespaces. All of these can be emulated in what I would call "C with discipline". Just be consistent in your naming conventions, always use a common pref…
And, before you mention it, use clang to avoid getting the page long templates related errors.
Re: What if anything have we learned from C++? [video]
#19"most researchers prefer an inefficient language because it's easier to get a paper to improve an inefficient language... I've seen dozens of papers on getting lisp almost as fast as C++, on getting Java almost as fast as C++. You can't do that with C++". A paper from the man himself on getting a type switch in C++ almost as fast as what you get in OCaml. http://www.stroustrup.com/OOPSLA-typeswitch-draft.pdf Lot's of…
"Our library-only implementation (...) For many uses, it equals or outperforms equivalent code in languages with built-in type-switching constructs, such as OCaml and Haskell"
In my opinion major weakness of C++ is just that the linker features more or less remained out of the language design. Turbo Pascal already shown eons ago the advantages of having modules instead of obj files. The slowness of compilation is still the major problem of C++ compared to the languages like Turbo Pascal and more recently Go.
Re: What if anything have we learned from C++? [video]
#20I really wish there was a "syntactic-sugar-on-top-of-C++" language that would compile down to C++ and have 100% compatibility with the existing C++ ecosystem (so that you can just directly use a class from any C++ library). Something like TypeScript is to JavaScript, or like Kotlin is to Java. Would make the experience much nicer without having to wait on the slow C++ standardization process or deal with all the back…
In terms of playing nice Rust is doing great (no GC, and can create static libraries linkable by C/C++ compilers), but unfortunately requires going through plain C interface.