Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror

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

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) 78

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:There is already a safe subset of C++ (Score 1) 78

Ish.

I would not trust C++ for safety-critical work as MISRA can only limit features, it can't add support for contracts.

There have been other dialects of C++ - Aspect-Oriented C++ and Feature-Oriented C++ being the two that I monitored closely. You can't really do either by using subsetting, regardless of mechanism.

IMHO, it might be easier to reverse the problem. Instead of having specific subsets for specific tasks, where you drill down to the subset you want, have specific subsets for specific mechanisms where you build up to the feature set you need.

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

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) 78

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".

User Journal

Journal Journal: Antiques being melted down 3

A restoration expert in Egypt has been arrested for stealing a 3,000 year old bracelet and selling it purely for the gold content, with the bracelet then melted down with other jewellery. Obviously, this sort of artefact CANNOT be replaced. Ever. And any and all scientific value it may have held has now been lost forever. It is almost certain that this is not the first such artefact destroyed.

Comment Short Seasons (Score 3, Interesting) 72

It used to be 26 episodes per season, with each episode airing twice during the year. It was a nice, simple way of filling the broadcast schedule. That shifted to 24 episodes at some point. There was a bigger shift, I think in the early 2000s, where they started having separate shows for the summer, and seasons started getting much shorter, sometimes more like 13 episodes. Now streaming services will put out 6-7 episode seasons; only a quarter of what a season used to be.

The good part of this is that you no longer get filler episodes. I remember watching shows like Stargate SG-1, and there were inevitably a few junk episodes, like a clip show that has some excuse to edit together a bunch of clips of previous episodes, or some episode that really didn't do much because they clearly spent all their budget already. I don't miss those. But with only 6 episodes, it's down to the same run-time as a miniseries, and things sometimes feel rushed.

For shows that are telling a story over the course of a season, the shorter episodes sometimes work well, but for more episodic shows (like Doctor Who), it just feels like you're getting shorted (because you are).

For many shows, the driving force is the quality of the writing and acting. Would the studios do better to spend less on the production and get more episodes for the same money? Good stories outweigh good effects.

Comment Re:Transitions (Score 2) 243

Someone didn't live through the loss of the floppy drive, DB9 ports, and parallel ports.

In my day, to plug in a mouse: We took the box apart, installed a proprietary bus card, and then tried to figure out non-conflicting spots for the I/O and IRQ jumpers. Then we typed a bunch of gibberish into AUTOEXEC.BAT. And we liked it!

Comment Re:Need this at the airport... (Score 1) 18

Rides to and from airports are regulated, and there's a lot of money involved. That means the existing players are lobbying hard to keep the new competition out. If this is like everything else in history, they'll succeed only in delaying it. That delay will make the finances that much harder for new players, which may result in some failing, but eventually they'll get in. Considering that Tesla and Waymo have significant resources, they'll probably be the ones to break in to airport rides first. (Tesla just started trying to get the permits in California.)

Comment Re:A little more honesty please (Score 1) 22

At least Nixon had the class not to force his minions to take all of the credit for the Apollo missions in their press releases.

That's what Trump did here: Same as usual he took all of the credit for other peoples' work.

You wonder why he gets under peoples' skin? It's because essentially everything he does is some kind of asshole move like this.

Slashdot Top Deals

Bus error -- please leave by the rear door.

Working...