Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror

Comment Re:Do it yourself (Score 1) 82

Cppcheck apparently knows "hundreds of other rules covering a multitude of language aspects" so you don't "have to mentally apply against every single line of code you write."

Cppcheck doesn't flag anything in Waffle Iron's example.

It also doesn't find anything wrong with:

std::vector<int> vec = {1, 2, 3, 4, 5};
auto it = vec.begin();
vec.push_back(6);
std::cout << *it << std::endl;

Which is another common example of how you can write memory errors without using C++ pointers.

Comment Re:There is already a safe subset of C++ (Score 1) 82

In the sort of places where MISRA and similar coding guides apply, yes, never allocating memory is expected, because once dynamic allocation exists you can't guarantee that you won't die with an out-of-memory error and similarly can't guarantee any time bounds on how long an alloc and dealloc will take.

Sure, so C++ is safe as long as it's used in a way that makes it incredibly painful. Sounds good. Let's just require all C++ code everywhere to be written that way. Rust usage will skyrocket overnight.

Comment Re: Is there anyone here that voted for Trump (Score 1) 256

It is hard to have fair democracy with winners take it all.

For a really rigorous definition of "fair", it's impossible to have fair democracy at all. Arrow's Theorem demonstrates this to a large degree, although many have argued that some of his fairness axioms are excessive. More recent research has concluded that fairness is the wrong standard, because there's no way for an electorate's "will" to really be fairly represented by any electoral system, not in all cases. Some systems can do better most of the time (and "winner take all" is particularly bad), but all systems fail in some cases.

What we need to aim for instead of fairness is "legitimacy", which is more about building broad acceptance of the system than about fixing the system itself, though it's easier to build acceptance for better-designed systems.

Having the country's top politicians continually claiming the system is unfair and rigged is, of course, the worst possible thing to do if you want to build support for the legitimacy of the system.

Comment Re:Jokes on you (Score 1) 256

Precisely none of those books were ever banned.

I decided to check :-)

According to the Book Censorship Database from the Every Library Institute, both "Of Mice and Men" and "Adventures of Huckleberry Finn" have been challenged, but only "Of Mice and Men" was removed, though "restricted" is more accurate. The Birdville Independent School District in Texas removed the book from general access, allowing access only to the AP English class, and the Indian River County Schools in Florida restricted it to high school students.

No Doctor Suess books were banned, although Suess Enterprises voluntarily ceased publication of six books.

Comment Re:Do it yourself (Score 3, Interesting) 82

So don't use STL

Indeed, No True Scotsman would use STL with C++.

clang-tidy and Cppcheck and flaw finder and Sonarqube

The last job I had where I had to use C/C++, we automatically ran an expensive static analysis tool every time we checked in code. I'd estimate that it only found about half of the potential segfaults, and it made up for that by finding twice as many false positives.

Comment Re:Do it yourself (Score 3, Insightful) 82

The "rules" of mutable collections in STL state that collections may not be mutated while being iterated.

Nope. If I had used st::list instead of std::vector, it would have been perfectly fine and officially supported. (Assuming I changed "i+10" to "i+11" in order to make the algorithm actually terminate, although that change wouldn't affect the vector crash.).

The problem is that there are dozens of different rules you have to remember to apply to the different types of lists and iterators. And that's only talking about that one topic. There are hundreds of other rules covering a multitude of language aspects that you have to mentally apply against every single line of code you write, many of which can potentially cause memory corruption.

Comment Re:Do it yourself (Score 4, Interesting) 82

You don't need the language to enforce memory safety to program memory-safe. The most important thing is, for example, to never touch raw pointers. C++ makes it very easy to avoid this. Rust forces you to avoid it, but just because C++ gives you the loaded gun, it doesn't mean you have to use it. In particular not on your own foot.

That is a dangerous misconception. You don't need to use any pointers to get memory errors in C++:

#include <stdio.h>
#include <vector>
 
int main() {
    std::vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    for (auto i : v) {
        if (i % 2 == 0) {
            v.push_back(i + 10);
        }
        printf("%d\n", i);
    }
 
    return 0;
}
 
$ g++ -Wall -pedantic t.cpp
$ echo $?
0
$ ./a.out
 
1
2
-947527061
1600570778
5
6
7
8
9

Comment Re:There is already a safe subset of C++ (Score 4, Insightful) 82

languages like Rust exist to put ignorant programmers in straight jackets for their own good

Are you seriously trying to suggest that never allocating memory is not also a "straight jacket"?

You seem to be saying that a currently existing bowdlerized version C++ is safe for close-world problems. Possibly so, but that still leaves C++ unsuitable for open-world problems. That makes C++ only suitable for niche applications. Why learn it?

If you just use Rust or any other memory safe language, you won't have to worry about what kind of "world" you're writing for, or about choosing from a range of increasingly dangerous "profiles".

Comment Re:Can you imagine needing government permission (Score 1) 105

I dunno. China is a "market socialist" system -- which is a contradiction in terms. If China is socialist, then for practical purposes Norway and Sweden have to be even *more* socialist because they have a comprehensive public welfare system which China lacks. And those Nordic countries are rated quite high on global measures of political and personal freedom, and very low on corruption. In general they outperform the US on most of those measures, although the US is better on measures of business deregulation.

Comment Re: 200 million angry, single disaffected young m (Score 1) 105

It makes no sense to claim Chinese courts have a lot of power, although it may seem that way â" itâ(TM)s supposed to seem that way. One of the foundational principles of Chinese jurisprudence is party supremacy. Every judge is supervised by a PLC â" party legal committee â" which oversees budgets, discipline and assignments in the judiciary. They consult with the judges in sensitive trials to ensure a politically acceptable outcome.

So it would be more accurate to characterize the courts as an instrument of party power rather than an independent power center.

From time to time Chinese court decisions become politically inconvenient, either through the supervisors in the PLC missing something or through changing circumstances. In those cases there is no formal process for the party to make the courts revisit the decision. Instead the normal procedure is for the inconvenient decision to quietly disappear from the legal databases, as if it never happened. When there is party supremacy, the party can simply rewrite judicial history to its current needs.

An independent judiciary seems like such a minor point; and frankly it is often an impediment to common sense. But without an independent judiciary you canâ(TM)t have rule of law, just rule by law.

Comment Re: 200 million angry, single disaffected young me (Score 1) 105

Hereâ(TM)s the problem with that scenario: court rulings donâ(TM)t mean much in a state ruled by one party. China has plenty of progressive looking laws that donâ(TM)t get enforced if it is inconvenient to the party. There are emission standards for trucks and cars that should help with their pollution problems, but there are no enforcement mechanisms and officials have no interest in creating any if it would interfere with their economic targets or their private interests.

China is a country of strict rules and lax enforcement, which suits authoritarian rulers very well. It means laws are flouted routinely by virtually everyone, which gives the party leverage. Displease the party, and they have plenty of material to punish you, under color of enforcing laws. It sounds so benign, at least theyâ(TM)re enforcing the law part of the time, right? Wrong. Laws selectively enforced donâ(TM)t serve any public purpose; theyâ(TM)re just instruments of personal power.

Americans often donâ(TM)t seem to understand the difference between rule of law and rule *by* law. Itâ(TM)s ironic because the American Revolution and constitution were historically important in establishing the practicality of rule of law, in which political leaders were not only expected to obey the laws themselves, but had a duty to enforce the law impartially regardless of their personal opinions or interests.

Rule *by* law isnâ(TM)t a Chinese innovation, it was the operating principle for every government before 1789. A government that rules *by* law is only as good as the men wielding power, and since power corrupts, itâ(TM)s never very good for long.

Comment Re:Credit scores are not what you think they are (Score 1) 108

Credit scores don't reflect how well you are doing. Their purpose is to tell lenders how well they can milk you. It's an indicator of how exploitable you are and many people out there completely miss this fact.

My credit score is well over 800 and I don't see how I'm exploitable. I haven't paid any CC fees or interest in decades, and have no debt anywhere else. But maybe I'm missing something obvious. Can you explain a bit? (serious question).

Comment Re: Keep it plugged in (Score 1) 173

If they want it preconditioned? Yes, welcome to 2025, they can install the app on their phone. Or they use the 'remote climate start' option on the keyfob. Or they shoot you a quick text asking you to hit the button in your app.

You keep trying to paint these advancements in convenience and comfort as terrible burdens, and it's weird.

Slashdot Top Deals

Remember to say hello to your bank teller.

Working...