@dkf said in Which language is the least bad?:
@evo said in Which language is the least bad?:
I can't believe all the hate for C++, here.
There's a lot of C# weenies round here.
I have three reasons that I dislike C++:
- It's bloatedly complicated. Seriously, the language itself is big and subtle and that makes it both hard to learn and easy to conceal sins with.
- It remains thoroughly hostile to stable ABIs. It's not that you can't make your library have a stable ABI when using C++, but it is really difficult to do; the frequently changing core C++ semantics has really made this much harder than it should be, and the habit the language encourages of mixing the API between the ABI level and the symbols that get compiled into inline code in consuming code, well that's just a great way to not have a stable ABI at all. Users of C++ libraries had better have some love for the upgrade treadmill and recompilation.
- It's exceptions remain awful and expensive.
It is hard to learn, but the rewards for being able to code in it properly are huge, in my opinion. Not just because of efficiency, but also because the code is often actually more readable. Or at least, in C++ you can better encapsulate the difficult parts (as is often done by the standard library or boost).
The ABI I agree with, that is unfortunate.
About exceptions being awful and expensive - do you have a source for that? I have no idea why you would call them awful (assuming you use RAII). And are there any languages in which exceptions outperform those in C++?
@blakeyrat said in Which language is the least bad?:
@evo said in Which language is the least bad?:
You are given freedom in C++, and it's your choice to use it wisely.
The instant a second programmer joins the team, this goes from being a benefit to a giant albatross around your neck.
We all agree that the only sane way to use C++ is to pick a subset of the (myriad) features and use only those. The problem is: every developer picks a different subset, and C++ is far too large for any single developer to completely internalize in the way can they can simpler languages like C# (although C#'s getting large too) or JavaScript or Python.
I'm not interested in being able to write clever code, I'm interested in being able to write quality software. And C++ is one of the worst languages for achieving that goal. (Worse even than plain C, IMO.)
No, the instant a second programmer who doesn't know what they're doing, but is given too much responsibility in a code base, the codebase will grow terrible. If somebody doesn't know C++ properly, you shouldn't let them anywhere near the design of the software. This is true in all programming, but more in C++, simply because it gives you more tools and variety to do things properly.
You should definitely NOT pick a subset of C++ (except in some cases such as performance-critical cases), and I'm not sure why you would suggest this even. I've heard this, but it usually comes from people who only know that particular subset of the language. That is, using the subset is a limitation of the coder, not a feature to make the code better.
I don't think there are too many features I know, but never used. Recently, I've used virtual inheritance for the first time in my life, because I needed it. This makes that code (~ 60 lines) a bit harder to understand, but allows the writing of code that is easier to understand and maintain. In a way you could never do in C# or Java.
@evo said in Which language is the least bad?:
I expected people here to be decent programmers, allowing those features to be used properly.
Decent programmers understand their own limitations.
So you're saying you can't learn C++? Learning about those features in a limitation?
Most people didn't learn it, but can learn it, solving those limitations. I do agree that C++ has a steep learning curve, but as I keep saying, it does give more flexibility, allowing good C++ developers to write better code.
@evo said in Which language is the least bad?:
Sure, you don't want to work on C++ projects of co-workers that suck. I'm there right now; it's a pain.
So, you do understand why C++ is bad, but just... refuse to believe it? Are in denial? I don't get it.
No, I understand that C++ is difficult, and can go bad if nobody actually knows the language. You need at the very least a leader and designer who knows the language thoroughly, that is capable of delegating tasks, possibly to people less experienced.
In the case of the projects at work it was that: nobody did know C++ well enough to know which features to use when. And also, because people preferred inheritance over composition everywhere.
The same holds for any other language: would you want an idiot who can't design code to use inheritance everywhere it could possibly be used?
C++ is harder, so there are a lot more people who don't know it well enough to design code properly.
I guess it's about the same as Windows vs Linux; Linux gives you more freedom, but more rope to hang yourself. Linux has a more steep learning curve, and I wouldn't want an idiot touching my Linux servers because they could easily fuck it up.
Though maybe that's not the best thing to say to you, is it ;-).
@evo said in Which language is the least bad?:
But well written C++ software (which is, admittedly, rare) I will claim is better than software written properly in C# or Java.
"Better" by what metric? Less buggy? Took less developer hours to create? Has a better UX (which Java's always going to lose, BTW)?
It's hard to imagine C++ doing better on any of the quality metrics I actually care about than C#.
Most importantly: easier to read and maintain and understand. And, to me less important: more efficient.
There will be parts that are more difficult to understand, but they are encapsulated and shouldn't be touched by people who don't know what they're doing. Those are only tiny parts, however, and using it is easy. So in the end, it will become easier, even for less experienced C++ developers.
@evo said in Which language is the least bad?:
Don't be afraid because something can be used incorrectly. A knife can be used to cut off your finger, does that mean you hate the knife?
The problem is the second guy you hired to help you chop vegetables for your restaurant will cut you with the knife. Then your restaurant will go out of business because you were in the ER taking care of it and there weren't enough vegetables.
Yes, and that doesn't happen in a restaurant because you don't give a knife to an idiot who doesn't know not to wave it in your direction. He was taught to use a knife. He is delegated to be in a position that can cause no harm to you. He is delegated to do the cutting tasks he is capable of doing, and not of some complicated fancy shape-cutting that he hasn't yet mastered.
It's exactly the same, just that cutting is significantly easier than writing good, maintainable code.