6 ms·
While perfectly fine, this comment unironically reinforces the GP's assertion of "how [C++] as a whole the language is basically a gigantic ball of special cas
by jjawssd 9y ago
While perfectly fine, this comment unironically reinforces the GP's assertion of "how [C++] as a whole the language is basically a gigantic ball of special cases"
- kobeya 9y agoWhat specifically annoys me about C++ and is demonstrated by this example is that the simplest possible expression of an algorithm is almost certainly not the most efficient or desirable way to do what you are trying to accomplish. In a language designed for humans, the simplest expression of a loop (e.g. `for (auto paths : m) {}`) would use references not value copying. You'd have to go out of your way to do the it the dumb way, which you would only do when you have a specific reason to do so. C++, on the other hand, is only really an effective language in the hands of people who have either fully internalized the 1,000 page specification, or wasted a depressing number of synaptic connections on memorizing minute trivia about what constructs to use under what circumstances. I say this as someone who works with C++ on a daily basis :(
- llukas 9y ago> C++, on the other hand, is only really an effective language in the hands of people who have either fully internalized the 1,000 page specification, or wasted a depressing number of synaptic connections on memorizing minute trivia about what constructs to use under what circumstances. No. You use profiling tools and optimize hotspots. Pareto principle applies here so you look at 20% of program tops. Rest is irrelevant and can be executed as inefficiently as you please as long as you got your big O complexity right.
- kobeya 9y agoOr the language and compiler can just save you the trouble and get it right from the beginning.
- llukas 9y agoWhat you see as trouble other people see as desired behavior. Pick the right language.
- klipt 9y agoIsn't C++ still pretty much the fastest language out there, except Fortran for some numerical applications? I thought that's the main reason to use it over Python/Java/etc.
- dima55 9y agoC. Use C.
- jsolson 9y agoHaving recently done some C development after a few years of exclusively C++, no, no thank you. I'll take my RAII and destructors, thank you very much.
- pjmlp 9y agoHence why already back in 1993, when faced with the option of Turbo C 2.0 vs Turbo C++ 1.0, I could not understand why bother with C at all, still don't.
- josefx 9y agoThose language creators and their names, "C","C++", "Objective-C","HolyC", "C#". I almost thought "C." was a new language.
- CyberDildonics 9y agoC doesn't have destructors or move semantics.
- kobeya 9y agoWho said anything about Python or Java? In any case Java and C++ are roughly similar. The next tier of languages such as Rust or Haskell are within a small constant factor in the usual benchmarks. But quoting such benchmarks is questionable because the C and C++ implementations require much more man-hours of hyper optimization to get into that top-tier position. The real important takeaway is that the first or second attempt in C++, by someone who is not a language lawyer, is nowhere near the maximum achievable speed. Whereas the first or second attempt by a similar layman in a reasonable language like Haskell is not only faster than the initial C++ version, but has fewer bugs as well.
- Retra 9y agoI used to despise C++... but now I work on it every day, and while I don't think it's great, it is not so bad. Turns out my hatred was entirely for the std library. At my work, we simply don't use it. And thus `auto` hardly saves anything, so we don't use that either, and I don't miss any of it.
- gpderetta 9y ago> In a language designed for humans, the simplest expression of a loop (e.g. `for (auto paths : m) {}`) would use references not value copying. In C++ values are first class, making 'auto x' an implicit reference would be surprising for anybody with experience with the language model. It is also consistent[1] with the template deduction rules. I strongly believe that not not having first class values in a language with mutation is a design mistake [2]. [1] IIRC the ill designed initialization_list has special rules for auto. [2] C++ references are not first class which is also a mistake.
- claudius 9y ago> In a language designed for humans, the simplest expression of a loop (e.g. `for (auto paths : m) {}`) would use references not value copying. You'd have to go out of your way to do the it the dumb way, which you would only do when you have a specific reason to do so. But I would expect auto x = y; to create a new variable by copying with type-deduction from y, not a reference (or even const reference) to y. If I want a reference anywhere in the language I always have to say so explicitly. As such, I find it perfectly normal that for(auto x : y) create a copy of the elements of y while for(auto& x : y) creates a reference to the elements of y. Reversing this just within for-loops would only add to the confusion. Defaulting to references over values just for auto where everywhere else values are the default and references need to be specified would also only add to the confusion. Of course you may now say that one should have done it right from the start, but this is then an argument about the initial decisions in the late 80s, not about the use of auto in C++11. Regarding the specification, I am incredibly happy that there is a specification I can trust and nowadays a series of different compilers which largely implement this specification instead of some "model-implementation" which implicitly defines the language and may look entirely different next week.
- kobeya 9y ago> But I would expect "auto x = y;" to create a new variable by copying Why would you expect that? There are plenty of examples of other referentially transparent languages where "x = y" means x and y refer to the same thing, not different things (one newly created) initialized to the same value. Maybe you expect it to work the way it does because that more closely resembles how C++ has worked for you in the past, which is a bit of a circular argument. > Of course you may now say that one should have done it right from the start, but this is then an argument about the initial decisions in the late 80s, not about the use of auto in C++11. Yes, that's exactly the point I am making.
- exprA 9y agoAre you sure you're making a point – because I can't see one. Seems more about unnecessary bitching about C++ being different from [some-different-language]. If they could do anything more stupid as introducing a galling difference and a special case to variable initialisation with auto, it would be to do exactly that, but because “some other languages work more like that”.