Earlier quoted context omitted.
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…
C99 is nice, but C still lacks generic. I am not talking about C++ template nonsense, but not having to write max element search for every primitive type. I am working in DSP project which was started with typical C++ OO BS, finally with ended up with C compiled as C++ + some simple templates for cases as above.
What if anything have we learned from C++? [video]
31–40 of 56 posts
Re: What if anything have we learned from C++? [video]
#32After twenty years of using it? That I was wrong, that plain-old C really is better.
Re: What if anything have we learned from C++? [video]
#33That introducing kids to programming using C++ will ensure they never want to try again.
I was introduced to C and then C++ when I was 10 years old. I found the book on C by Arthur Chapman very confusing, particularly pointers. I then started reading a book on Pascal in the same series and that was confusing too. But I stuck with it and have found that learning C++ has meant that I think in C++, and transfer this to other languages when I have to write them. Additionally, the second thing I found was tha…
Though I was keen on getting into coding, I was like many other students put off by this approach and only went back to programming many years later with visual basic.
I appreciate that one gets a better understanding of computer science by going really low level (assembler, etc) but I question whether this is the right approach if one wants coding to be more mainstream.
I think coding should be taught in high school like latin or physics, not because kids will all become programmers, or historians or scientists, but because having a basic understanding and culture will help in everyone's life and it gives kids a taste for what a career in that field may look like. And I don't think C++ is the right tool for that.
Re: What if anything have we learned from C++? [video]
#34I started programming in C++ in the late 90's and I used to be confused about what features to use and found it easy to make a mess. But I am happy I stuck with it as it opened up opportunities to work in a lot of different and interesting domains like games, mobile apps, interactive art installations, trading systems and video and film processing apps. Also, most of my code is platform independent and very efficient…
This is also something that I like. In my opinion, the programming languages environment is ridiculously fragmented, and one has to learn new tools constantly in order to keep up, without gaining any real benefits. I would prefer it if we had several strong, open langauges that are complements to eachother and which would own the market so developers could focus on solving problems, not learning syntaxes and APIs. In…
I'd rather see greater interoperability to enable parts of a project to be written in different languages. The C# ecosystem (F# etc) is closest to this, although see also Scala.
Re: What if anything have we learned from C++? [video]
#35I 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…
Re: What if anything have we learned from C++? [video]
#36Earlier quoted context omitted.
C99 is nice, but C still lacks generic. I am not talking about C++ template nonsense, but not having to write max element search for every primitive type. I am working in DSP project which was started with typical C++ OO BS, finally with ended up with C compiled as C++ + some simple templates for cases as above.
Using statement expressions and the typeof extension, you are able to write function-like, type-generic, scope-insensitive macros like this one: #define MAX(a,b) ({ \ typeof (a) _a = (a); \ typeof (b) _b = (b); \ _a > _b ? _a : _b; \ }) The inability to write template functions can be compensated by designing your function so that it takes a function pointer where the type-specific action occurs.
Re: What if anything have we learned from C++? [video]
#37I 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…
Compiling to C would be better. Using C++ libraries from anything outside C++ compiled by the same exact compiler and same exact version of it as the library was is a royal pain. On the other hand using C libraries is super easy from any language and something compiled 10 years ago still works today.
Re: What if anything have we learned from C++? [video]
#38Earlier quoted context omitted.
C99 is nice, but C still lacks generic. I am not talking about C++ template nonsense, but not having to write max element search for every primitive type. I am working in DSP project which was started with typical C++ OO BS, finally with ended up with C compiled as C++ + some simple templates for cases as above.
I am not talking about C++ template nonsense, but not having to write max element search for every primitive type How is it template 'nonsense', when those templates do exactly that?
Re: What if anything have we learned from C++? [video]
#39I 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…
Compiling to C would be better. Using C++ libraries from anything outside C++ compiled by the same exact compiler and same exact version of it as the library was is a royal pain. On the other hand using C libraries is super easy from any language and something compiled 10 years ago still works today.
C++98 code out of GCC has been ABI stable for over 10 years now btw, and we also have some pretty great tools for detecting ABI breakage now, like abi-compliance-checker[1]
[0] https://techbase.kde.org/Policies/Binary_Compatibility_Issue... [1] http://ispras.linuxbase.org/index.php/ABI_compliance_checker
Re: What if anything have we learned from C++? [video]
#40Earlier quoted context omitted.
What about templates? For some reason, C programmers only seem to comment about the OO parts of C++ and never talk about templates. When you bring variadic templates into the mix, it's just more awesomeness. And, before you mention it, use clang to avoid getting the page long templates related errors.
I haven't seen much template wizardry in the C++ codebases I've worked on. It can generally be seen in the standard headers. Type-generic data containers can still be implemented with void pointers and very little runtime overhead, for example: http://lxr.nginx.org/source/src/core/ngx_array.h