I agree that const is overall a good thing; however, it is tricky even in what you might think are simple cases. Take this for example:
include <iostream>
void foo(const int& a, int& b)
{
std::cout << "a: " << a << std::endl;
std::cout << "b: " << b << std::endl;
++b;
std::cout << "a: " << a << std::endl;
std::cout << "b: " << b << std::endl;
}
int main() {
int a = 1;
foo(a, a);
}
Here the value of a changes in the middle of the function even though it's a const reference, because of aliasing. Here const doesn't mean the value won't change--only that you can't change it through that particular reference. Yes, const is useful, but if you don't know what it actually does it will bite you in the ass, just like most of C++.
This does not seem like a strong argument. Yes, table salt is useful, but if you don't know what it actually does and you put it in your eyes, it will burn them, just like most, well, everything...
A const reference guarantees to the caller that the callee won't modify the object, not to the callee that the object won't be modified.
A function may not reliably cast a pointer-to-const-T to a pointer-to-T because T may actually be immutable, in which case modifying it would be UB. Like all casts, const_cast exists as an escape hatch in the type system for when you know that what you are doing is safe, even if the compiler can't prove it.
You misunderstand reference-to-const, it does not imply that what "a" points to is immutable, it is a contract to the caller that foo will not use "a" in any non-const way.
That's exactly what I said; however, when you introduce people to C++ that seems rather counter-intuitive and can lead to a lot of mistakes. Yes, you can tell people "Well, you don't understand what the standard says!" but there's still something to be said for language features that don't take several pages to explain what they really do.
I just gave an explanation of reference-to-const in 1 sentence, not several pages. Also, my objection to your comment was your focus on what const means to foo() when the value is in what it means to main().
Isn't this inferable from the code itself, though? I was expecting some subtle gotcha, so I had to read your comment three times to realise there was none!
It's to be expect that we can change a-through-&b, but not a-through-&a in foo.
I think the objection is that b may get passed throughout the program such that it's no longer local to a. Then you have 'const Foo& a' that you expect will never change, but your function reading from that calls something that mutates a 'Foo* b' that aliases the object (probably through a member variable), and suddenly you have some very hard to track down bugs. If you're multi-threaded, you have a data race.
You either need to be very strict about creating non-const references to objects, or you need to enforce immutability at the class level. Unfortunately the latter has all sorts of other practical problems, often including efficiency trade-offs or awkward APIs.
> you have 'const Foo& a' that you expect will never change, but your function reading from that calls something that mutates a 'Foo* b' that aliases the object
And this is exactly why const means pretty close to nothing. Compilers can't enforce it in so many situations that it is almost like the "auto" keyword in pre-C++11 times.
It still documents intended behavior, though. C++ is basically a giant clusterfuck if you want the compiler to actually enforce anything - because of pointer arithmetic, there's no guarantee not only that const Foo& a is immutable, but even that it points to a valid Foo or that accessing it won't crash your computer. It's trivially easy to trigger undefined behavior that may do anything up to pwning your computer, whether you make your classes immutable or not. The point of const, access control modifiers, references, static typing, RAII, and all of the other restrictions on C++ programming is to put up giant signposts that say "Don't do that! Here be dragons!" rather than actually prevent you from doing it.
If you want the compiler to actually enforce safety properties of the language, use a language like Haskell or Rust.
This seems to me a lot of trouble for "documented" behavior. It is much better to design your classes in a reasonable way and stop worrying about const issues. If you rely on const to write good code, I guarantee you that sooner or later you will be in a lot of trouble.
More like the way they think Linus acts. Yes, sometimes Linus has outbursts, and I think it's fair to criticize him for that. But 99% of the time he's listening to ideas from all sides and deferring to other people on the things he doesn't know. I think a big reason for Linux's success is Linus' skill as a mediator, and that's something these imitators don't seem to grasp.
Right - it's like all modern news reporting - it's incredibly distorted in favour of the dramatic and attention grabbing parts which are usually exaggerated beyond belief. The other 95-99% just doesn't get any attention because it's not news-worthy.
I don't know how it is on Macs (probably worse), but on my Lenovo Y50 I've had a lot of issues getting my nVidia card to work properly. First I tried Arch Linux, which I had been using on my previous machine for about 2 years now, and no matter what I did I couldn't get my nVidia card to work properly, even with the nvidia-beta package from the AUR.
So then I tried Ubuntu, thinking that would be the "easy" distro. It installed alright, but the nVidia card was still giving me trouble and the official Ubuntu nVidia packages weren't new enough (it's a GTX 860M). So I added a PPA with a newer version of the driver and that seemed to get it working at least, but I still had massive screen tearing issues, and for some reason the nVidia settings app had far fewer settings than the Windows version I have on the other partition, and it didn't even have an option to enable vsync, which should resolve the tearing. After trawling through mountains of nVidia documentation and forum posts, including, no joke, the EBNF for their config file, I still can't get the damn thing to work.
I'd like to have a real shell and be able to play games without rebooting, but the polish on desktop Linux still isn't quite there yet. And yes, I know this particular problem isn't the fault of Linux or any of the other software in Ubuntu, but it's a problem with the ecosystem and it's one that's preventing me from using Linux as much as I'd like to right now.
Apparently I had tried messing with some other environment variables earlier, but this one didn't do it either. It shouldn't be this hard to tell a GPU to slow down when it draws things.
That was one of the things I tried and somehow it still didn't do it. Setting it in the individual games' settings didn't to it either. I'll try one more time though.
One of Linus's key strengths is that he's good at listening to people and honestly evaluating new ideas based on their merits. Good code goes in, bad code stays out. He's not an ideologue like Jobs or Lucas. He's a pragmatist, and that's what makes him a good BDFL.
You can always opt out though. There's literally a check box you can change if you don't want it anymore. You don't uncheck that box without a lot of communication and deliberation generally, but it's there.
I'll admit that mods aren't always perfect, but they're (for the most part) regular users who are making communities the way they want to. I've very rarely seen people remove posts or ban users just to promote a particular agenda, and the ones that did were hated by their fellow mods. And I'd really like to see some good examples of admin censorship. The more common complaint I hear about the admins is that they're not active enough.
>government manipulation
I'd really like to see any sort of evidence whatsoever supporting this.
>corporate advertising/shilling
Again, I'd like to see some evidence. There have been a few high-profile cases like the Quickmeme guy, but I've never heard of large corporations wasting money on reddit. That's what Twitter and Facebook are for.
>The admin team has shown again and again that they're willing to tolerate anything until there's bad PR.
If you're talking about content, agreed. If you're talking about spammers and shilling, absolutely not. I think reddit is just about the best site of its kind around, in terms of software, users, and mods/admins when it comes to fighting spam.
>One of the founders (Alexis) has a PR firm, Antique Jetpack, which is on record [1] as cooperating with Stratfor of wikileaks fame. I can't quite see how the two are unconnected.
He released all of the emails he exchanged with them and it was never anything sinister.[1]
>A couple of years ago, one of the admins there tacitly admitted that he was under a National Security letter complete with gag order to give up user information.
Source? I don't remember this at all.
>A few months ago, reddit changed its voting system in order to completely obfuscate user detection of large scale vote manipulation. The community was unanimously against this change, and has been overruled.
No, the vote counts before, especially on popular posts, were almost completely wrong (intentionally). In exchange for taking away the individual vote counts, which were mostly bogus anyway, they made the "percent liked" statistic much more accurate. I dislike that they took away that ability completely from comments except for the "controversial" dagger, but I saw absolutely no sinister intent in what they were trying to do there.
Your whole comment reads like you've been taking what /r/conspiracy and /r/undelete tell you at face value and have never actually dealt with the mods or admins on reddit, or even taken the time to understand how it really works.
The problem with modding, or really leadership roles in general, is that everyone says they want to do it, but very few of the people who say that will actually put in the necessary time, and even if they do, a large percentage of them will suck at it. You want to know why there's so much mod overlap in the large subreddits? That's why. The people in charge of adding more mods would much rather have someone they know is dependable than risk trusting their community with an unknown. I agree that diversity in moderators, especially between subreddits, is a good thing, but it's much easier said than done. Finding, vetting, and training new mods is hard work.