6 ms·
In that regards, I also think C++ programmers should be more open to C programmers that just needs a few new language constructs. It is not an all or nothing a
by noselasd 10y ago
In that regards, I also think C++ programmers should be more open to C programmers that just needs a few new language constructs.
It is not an all or nothing approach. It's fine to write code that looks and feels mostly like C, but still takes advantage of a few nice C++ features.
- tines 10y agoI agree, which is why I mentioned that you can do what this article suggests without using anything except functions and structs. No classes or class features required.
- blub 10y agoThere are perfectly legitimate use-cases for such a "C+" style. The disadvantage is that it won't be considered "good C++ style" and would limit the attractiveness of the project to C++ programmers that enjoy modern C++. If one would include vector, string, array, smart pointers and maybe simple template code in C+ it would already have a big safety advantage over plain C.
- semi-extrinsic 10y ago> would limit the attractiveness of the project to C++ programmers that enjoy modern C++ As Linus wrote when someone told him on the mailing lists that Git should've be done in C++ """ Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C. """
- pjmlp 10y agoYet he had to move to Qt for Substrate due to issues with Gtk.
- inDigiNeous 10y agoWell, Linus is a great C -programmer, so that's something he knows well and likes to protect and embrace.
- JoeAltmaier 10y agoSounds like a bitter old fossil. My first look at Linux, there were 200 sound-card drivers in the source base. Mostly identical except for the layout of bits in the control register. Any change to the api or conventions, 200 files had to be edited. An ideal place to refactor as a 'sound card' base class and derive classes to handle the (miniscule) differences. "Keeping new ideas away" is a good working definition of an old coot.
- st3fan 10y agoYou don't necessarily need C++ to implement a good driver design with base classes and minimal code duplication. It is perfectly possible in C.
- deleted 10y ago[deleted]
- Vindicis 10y agoThat's pretty much how I use C++. Granted, my knowledge of it is very minimal. I was forced into C++ because of my Broker's api so... One of my largest gripes making the switch, is the OO paradigm. I get it, I understand it, and I really want to love it. But the theory of it vs. the implementations that I've seen, ugh. And the number of ways you can initialize variables etc... just makes no sense to me. It's like they just keep adding new ways to do things, for no other reason than because they can. What's wrong with only have one way to do simple things like that? I don't know, maybe it's just me but I strive to keep my code as simple, concise as I possibly can. I have enough complexity to deal with solving problems than having to wrestle with my language on top of it. Just to note, I'm strictly talking about having to use other people's code merged with my own. If it was solely me writing, I'd just use C++ for some of the nice things built in and toss classes and all that into the fire. YMMV.
- jjawssd 10y agoWe need a book with modern best practices like what happened in the Javascript world with "JavaScript: The Good Parts" from which we can glean a clean effective dialect, leading to a new C++ uptake and renaissance similar to what happened in the Javascript world in 2008
- swift 10y agoThey're not really equivalent, but Scott Meyers' series of books on C++ are some of my favorite technical writing ever, and his most recent book "Effective Modern C++" should be on the shelf of every working C++ programmer.
- 72deluxe 10y agoI agree with this - I finished reading this just before last year and I cannot recommend this book enough. It really is excellent (including topics like reference collapsing, type deduction in different scenarios, idiosyncrasies of async tasks). A great book and essential.
- kgabis 10y ago
- pjmlp 10y agoThe thing is, we get dispointed when the code just looks like "C compiled with C++ compiler", with all security exploits that entails. A good example is how Turbo Vision, Object Windows Library, Visual Components Library, Qt look like and the concessions Microsoft had to make to Afx so that it got rebranded into MFC and appealed to the Windows C developers.
- beojan 10y agoThe idiosyncrasies in Qt etc. are because they were first designed when C++ was very young, and many compilers had poor support for the STL.
- pjmlp 10y agoYou misunderstood me. I was first talking about the set of frameworks that dared to embrace the then C++ best practices. All of them are older than C++98, or even before STL was being considered. Then I mentioned the fact that when Microsoft presented their Afx framework to their beta testers, mostly Windows C developers, it was considered too high level and it was rebuilt as MFC.
- 1wd 10y agoThe term "C with classes" is almost used as an insult in some circles. I wonder if "C++ without classes" would be a better idea.
- CyberDildonics 10y agoC++ without polymorphism or inheritance is how the people that I think are worth listening to seem to do things.
- 72deluxe 10y agoHow would that be a good idea? I don't understand how I could write effective software without polymorphism or inheritance, other than in tiny tiny applications.
- psyc 10y agoInheritance is syntactic sugar for composition. But, I think of it as reverse-SS, because I find composition much more readable.
- sidlls 10y agoI've written entire components for networked and multiplayer modes for games, and an algorithmic trading system that uses ML in C++ using just structs, unions, templates, functions and composition (no polymorphism or inheritance).
- CyberDildonics 10y agoThink about this: what does it give you besides generic execution and data when the size of the data varies? Templates already let you build generic data structures and algorithms when the size of the data on doesn't vary.
- gpderetta 10y agowithout runtime polymorphism. /pedantic++
- CyberDildonics 10y agoIt's always just one or two more features and before you know it - C++
- WalterBright 10y agoThe thing is, everyone has a different idea of what those one or two features should be! Even me, https://digitalmars.com/articles/b44.html https://digitalmars.com/articles/b44.html