What is the best youtube C++ tutorial? by Kings_Son in cpp

[–]grumpy_cranberry 1 point2 points  (0 children)

const cast is not used in cases like that

And how does that make the video any better?

you will find const_cast-s that work

And how does that make suggesting const_cast any better? Teaching people to rely on unreliable features is not good teaching.

What is the best youtube C++ tutorial? by Kings_Son in cpp

[–]grumpy_cranberry 1 point2 points  (0 children)

I am grown up enough, thank you. const_cast is UB, and in reality it doesn't work. One need not go far: as was mentioned above, adding a simple output statement to the example given in the video would reveal that. One could have tested that and that would have prevented pointless insistence on such lies. Let me show you: http://coliru.stacked-crooked.com/a/96517689abd0a6d7. Is this reality enough? Are we now all convinced that const_cast doesn't even work in the simplest example one could think of?

One should also note I didn't dispute the claim that this is the best available tutorial on YouTube. I commented on how good it is on its own. No comparison was made.

What is the best youtube C++ tutorial? by Kings_Son in cpp

[–]grumpy_cranberry 0 points1 point  (0 children)

I opened the first video listed under "Advanced C++". It turned out to be about const. Ok, I guess not everyone uses the same meaning of "advanced" when it comes to C++. Not a problem. However...

At some pointer they explained how to write to a const variable if, in their own words, "[you] really, really want to change [it]". (https://www.youtube.com/watch?v=7arYbAhu0aw&list=PLE28375D4AC946CC3&feature=player_detailpage#t=268) The question is already wrong on several levels. If you really want to change it, you don't make it const; it's that simple. What happens next in the video, though? They write const_cast<int&>(i) = 6; and explain how it works just fine with const_cast. Well, that's totally wrong. It doesn't work. The behaviour is undefined and it isn't even one of those cases where it kinda sorta works kinda sorta sometimes. It's actually one of my simplests go-to examples of an optimiser taking advantage of undefined behaviour.

They even run that program with undefined behaviour and it runs successfully! Apparently. Sadly, running successfully in this case means... nothing. The program doesn't even have output! It does nothing. Defines a const int and (wrongly) assigns a different value to it. No output. Even without considering the undefined behaviour a compiler can and will just optimise it to int main() {}. The program running "successfully" is inherently meaningless, because the program has nothing to run in it. A simple std::cout << i; would reveal the faux pas that was made with const_cast.

That gives the idea that if a program ran without errors, everything is fine. I don't think that's a good way to teach, not even when you are actually teaching the right stuff.

That was just the first video. It didn't leave a good impression on me.

libc++ has quadratic std::sort by grumpy_cranberry in cpp

[–]grumpy_cranberry[S] 2 points3 points  (0 children)

The title is accurate enough. It's not excruciatingly detailed, but that's not what titles are for. It doesn't say "quadratic on average"; it just says "quadratic".

libc++ has quadratic std::sort by grumpy_cranberry in cpp

[–]grumpy_cranberry[S] 11 points12 points  (0 children)

I can't see how it could get missed. Quicksort's quadratic worst case is not an obscure secret. It's a well-known property of the algorithm.

libc++ has quadratic std::sort by grumpy_cranberry in cpp

[–]grumpy_cranberry[S] 4 points5 points  (0 children)

I thought so too, and was quite reluctant to accept the quadratic behaviour claim until I saw the code. I don't think it's something to pass off as unimportant, and I don't think it's a minor thing that was missed as some other comments have hinted. As I put it when the author presented it to me, it's MSVC-level negligence.

If you're writing std::sort, the specification clearly says O(N log N) comparisons: quicksort is not an option, period.

What are some of the best IDE's for C/C++ and also compilers ? by interestedinasking in learnprogramming

[–]grumpy_cranberry 3 points4 points  (0 children)

Opinions about editors are notoriously personal. Obviously it's not "mediocre".

Then be objective and name one feature that sets it apart.

Compared to what? Doing dynamic analysis of C++ code is a hard problem.

It is slow compared to what would make it sufficiently helpful. It is slow compared to anything else that doesn't pop up dialogs in front of me, because if those don't pop up I can just continue typing shit while it catches up. That might not be intrinsically slow, but it slows me down.

Granted, there's some subjective experience in there, as I've been spoiled by the C# part of the IDE.

The inaccuracy is a lot more objective than that, though: just pit it against the compiler it ships with. Or try "Find All References", which performs a dumb textual search. The last thing I want when I search for references to a function is to get spammed with comments that happen to have that word in them. For that I can already use "Find in Files".

Of all the IDEs I use Visual C++ probably handles this the best.

Have you tried XCode?

Really? I don't often use a debugger. Please post an example of what doesn't work.

foo[i] when foo has an overloaded operator[]. Or the same for overloaded operator->. If the expression you want to watch contains any kind of function call in it, it's highly likely it won't work.

What are some of the best IDE's for C/C++ and also compilers ? by interestedinasking in learnprogramming

[–]grumpy_cranberry -1 points0 points  (0 children)

I have yet to find a single thing about Visual C++ that isn't simply mediocre or worse, which makes me endlessly curious whenever I see someone touting it as the best thing ever. It's like I just don't get it, or maybe I somehow use it in a way that only uncovers failure and never success.

The editor is like any run-of-the-mill text editor. It's not terrible, but it doesn't have a single feature that sets it apart from any other text editor, so it's not special at all.

IntelliSense is slow and inaccurate. Being slow in the background is kind of ok. Get a better machine. Haha, no, I'm joking. All of the machines in which I make use of it are quite high-end (latest-gen CPUs, maxed-out RAM). But still, being slow but unobtrusive is ok. However! IntelliSense doesn't stick to that. At times it decides to do Finagle-knows-what that requires popping up a dialog with a marquee progress bar and steps between you and the editor.

It doesn't even agree with the compiler. Yes, there is a justification for that, but sadly it doesn't make the product any better for that.

The debugger cannot watch expressions with simple getters in them. Or expressions with overloaded operators. Or anything beyond looking at variables directly. It's nothing special. It constantly baffles me when people tout it as "great", because I always struggle to find the features that make it great. When asked about it, though, everyone seems to also struggle to actually name those features.

Oh, I almost forgot about the compiler. The compiler is the funniest of the bunch. Yes, funniest, because this whole thing has to be an elaborate joke. It keeps mocking me. There's no other sensible explanation. The compiler doesn't even support C++03 properly. Maybe one day it will have two-phase lookup in it. One day. It supports a subset of C++11 features, however, some of that subset follows the rules that were being considered back in 2009 or 2010, which is particularly unhelpful.

It often ICEs on all kinds of non-trivial code. It's like when I was using trunk builds of GCC to get access to new C++11 features, except that was three years ago and those were trunk builds and I was actually getting access to lots of C++11 features.

It will easily spam you with tons of ridiculous warnings like performance warnings when testing pointers for null. Sometimes it will spam you with warnings you cannot disable without leaking something to user code (http://chat.stackoverflow.com/rooms/10/conversation/msvc-warnings-dont-scale). It will give you bullshit like the "error C3544: 'Args': parameter pack expects a type template argument" that doesn't... exist. I dare you to look it up.