Hacker Newsnew | past | comments | ask | show | jobs | submit | mrlonglong's commentslogin

How do I know if any of the books I already have are DRM free? And how to get the epub or PDF?

Shitty chess, lmao. I like it.

These people are sick in the head. I hope at midterms the Americans will oust enough Republicans to stall things until the next election and remove the current administration.

Why would they? They elected this administration by a fairly wide margin, and everything it has done is in keeping with its campaign promises. It's been more effective at that than any administration I can think of.

Sure, it's horrifying to the people who voted against it. But I see nothing here to change the minds of people who voted for it.

There will probably be some midterm losses, because the same persistent economic problems are still troubling us, but I don't expect to hear much of "I didn't realize that they were bloodthirsty monsters". I expect more of "Yeah, they're bloodthirsty monsters, which I like, but I won't vote for them anyway because the economy is bad."


Interesting that French electricity is massively cheaper than the UK's despite their reliance on nuclear energy.


The Cybertruck is banned in the UK.Thankfully.


Destabilising south America like this will only entrench the cartels and bring the war right into the United States.


The cartels are already entrenched. Organized drug gangs already dominate over a quarter of the south american continent. People openly speculate about how they control judges and politicians, and I don't doubt it for a second.

If the US manages to deal a crippling blow to these drug gangs, he will have done south america a huge favor and I will be forever indebted to him.


What do you make of Trump pardoning a convicted drug kingpin who was once a President then?


I'm not even going to try to justify that.

I understand that Trump's war on drugs is probably just a pretext to increase their dominion over south america. They probably want Venezuela's oil too.

None of that matters as far as I'm concerned. Here in south america things are way too fucked up to care about that stuff. South america has plenty of violent narcostates headed by literal communist dictators. Venezuela is just one of them, and my own country is rapidly following in its footsteps.

It's gotten to the point the USA nuking them all into submission would be a huge improvement to the status quo. Being a US vassal state is preferable to living under a barbarous narcostate shithole. The reasons they use to rationalize the attack are irrelevant to me. I'll be happy so long as they get rid of all these narcocommunists.


In theory they get Maduro to

>leave Venezuela immediately to allow the restoration of democratic rule

and then sunshine and unicorns ensue.


That will be a problem for South Americans and to a lesser extent you and me, not the ones pulling Trump's strings.


> to a lesser extent you and me

If this regime were capable of seeing past its own shoelaces, one could imagine a conspiracy to prompt a migrant crisis so the GOP has an issue its trusted by voters on.


Going to give this to a cat to play with, see if he enjoys it


The C++ example given in the article is not correct.

In C++ a mutex can wrap the object being protected.


Although there are owning mutexes for C++ the C++ standard library does not provide such a thing. So the std::mutex used in the example is not an owning mutex and that example works and does what was described.

One reason not to provide the owning mutex in C++ is that it isn't able to deliver similar guarantees to Rust because its type system isn't strong enough. Rust won't let you accidentally keep a reference to the protected object after unlocking, C++ will for example.


    #include <iostream>
    #include <mutex>
    #include <thread>

    class SharedResource {
    private:
        int value;
        std::mutex mtx;

    public:
        SharedResource() : value(0) {}

        void setValue(int newValue) {
            std::lock_guard<std::mutex> guard(mtx);
            value = newValue;
        }

        int getValue() {
             std::lock_guard<std::mutex> guard(mtx);
             return value;
       }
   };

   void threadFunction(SharedResource& resource) {
       resource.setValue(42);
      std::cout << "Value: " << resource.getValue() <<   std::endl;
    }

    int main() {
        SharedResource resource;
        std::thread t1(threadFunction, std::ref(resource));
        std::thread t2(threadFunction, std::ref(resource));

        t1.join();
        t2.join();

       return 0;
   }


This prevents access to the variable being protected by the mutex.


I am not very familiar with C++'s API, but I believe that you are right that the C++ example in the article is incorrect, though for a different reason, namely that RAII is supported also in C++.

In C++, a class like std::lock_guard also provides "Automatic unlock". AFAICT, the article argues that only Rust's API provides that.

    {
        const std::lock_guard<std::mutex> lock(mtx);
        account.balance -= amount;
        account.transaction_count++;
    } // Automatically unlocked.


> In C++, a class like std::lock_guard also provides "Automatic unlock". AFAICT, the article argues that only Rust's API provides that.

The issue isn't automatic unlocking. From the article:

> The problem? Nothing stops you from accessing account without locking the mutex first. The compiler won’t catch this bug.

i.e., a C++ compiler will happily compile code that modifies `account` without taking the lock first. Your lock_guard example suffers from this same issue.

Nothing in the C++ stdlib provides an API that makes it impossible to access `account` without first taking the lock, and while you can write C++ classes that approximate the Rust API you can't quite reach the same level of robustness without external help.


That is a different topic from what I wrote about.

The article wrote:

> Automatic unlock: When you lock, you receive a guard. When the guard goes out of scope, it automatically unlocks. No manual cleanup needed.

And presented Rust as being different from C++ regarding that, and the C++ example was not idiomatic, since it did not use something like std::lock_guard.

I have not addressed the rest of your comment, since it is a different topic, sorry.


Fair point with respect to the separate topic. My apologies.

As for the automatic cleanup bit, perhaps the article is trying to focus purely on the mutex types themselves? Or maybe they included the "when you lock" bit to emphasize that you can't forget to unlock the mutex (i.e., no reliance on unenforced idioms). Hard to say given the brevity/nature of the section, and in the end I think it's not that much of a problem given the general topic of the blogpost.


When comparing languages, posting unidiomatic code, and then making claims based on that unidiomatic code, is generally not fair nor correct.


That's true if the claims hinge on said unidiomatic code. As I said, it's not clear to me that that is the case here.


It seems completely clear. He first gives unidiomatic C++ code, then next gives idiomatic Rust code, and differentiates the two based on the code snippets. It is a mistake on his part, and I do not see how it could reasonably be viewed otherwise. It is not a huge mistake, but it is still a clear mistake.


Perhaps it might help to clarify precisely what claim(s) you think are being made?

From my reading, the section (and the article in general, really) is specifically focusing on mutexes, so the observations the article makes are indeed accurate in that respect (i.e., C++'s std::mutex indeed does not have automatic unlocking; you need to use an external construct for that functionality). Now, if the article were talking about locking patterns more generally, I think your criticism would hold more weight, but I think the article is more narrowly focused than that.

For a bit of a more speculative read, I think it's not unreasonable to take the C++ code as a general demonstration of the mutex API "languages other than Rust" use rather than trying to be a more specific comparison of locking patterns in Rust and C++. Consider the preceding paragraph:

> In languages other than Rust, you typically declare a mutex separately from your data, then manually lock it before entering the critical section and unlock it afterward. Here’s how it looks in C++:

I don't think it's unreasonable to read the "it" in the final sentence as "that pattern"; i.e., "Here's what that pattern looks like when written in C++". The example code would be perfectly correct in that case - it shows a mutex declared separately from the data, and it shows that mutex being manually locked before entering the critical section and unlocked after.


I am very sorry, but your arguments here are clearly terrible.


Please stop registering accounts to post guidelines-breaking comments like this in Rust-related threads. Other community members are noticing. It's an abuse of HN to do this and we have to ban accounts that keep doing it.


I am not breaking any rules, instead my comments are on point and show better debate culture than other comments, including better than yours and the previous comment. Please do better. You are at fault 100%, and you are well aware of it.

Edit: Downvoting comments that you know are good, is even further against good debate practice. You are doing worse and worse, and you are well aware of it. Have some shame.


The guidelines apply to everyone. If you continue breaking them with this account or other old or new accounts, they’ll be banned. No further warnings.


Good article, spoiled by the frequent misspelling of chrono as 'chorno'. What's a chorno anyway?


There's a character in Babylon-5, the sci-fi TV series of the 90s, also named Garibaldi. Professional hater of authority.


Let's hope the reboot, who changes between canceled and "soon" every few months, happens with a good casting for him, again!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: