this post was submitted on 26 Feb 2024
148 points (100.0% liked)

Programming

423 readers
6 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

On the one side I really like c and c++ because they’re fun and have great performance; they don’t feel like your fighting the language and let me feel sort of creative in the way I do things(compared with something like Rust or Swift).

On the other hand, when weighing one’s feelings against the common good, I guess it’s not really a contest. Plus I suspect a lot of my annoyance with languages like rust stems from not being as familiar with the paradigm. What do you all think?

top 33 comments
sorted by: hot top controversial new old
[–] mox@lemmy.sdf.org 33 points 9 months ago (2 children)

I'm just glad to see the White House listening to people who understand technology for a change.

[–] jkrtn@lemmy.ml 13 points 9 months ago (1 children)

We need legislators who aren't all literally older than cryptography. If they weren't bought and paid for by billionaires that would be nice too.

[–] parens@programming.dev 7 points 9 months ago (2 children)

That requires a population willing to vote for such legislators.

[–] demesisx@infosec.pub 14 points 9 months ago* (last edited 9 months ago) (1 children)

Don’t blame the victims for a sham of a democracy. First-past-the-post (FPTP) is there to prevent anything outside of a two party system where primaries are filled with (fully allowed) election fraud and cheating.

“we could have voluntarily decided that, Look, we’re gonna go into back rooms like they used to and smoke cigars and pick the candidate that way. That’s not the way it was done. But they could have. And that would have also been their right.” - DNC Lawyer

[–] parens@programming.dev 5 points 9 months ago (2 children)

FPTP does destroy a lot, I'll give you that, but municipal and regional elections have miserable turn-outs too and they have much more potential for perceptible change than state or national change.

In the USA things have to get way worse than they are now before they get better. A very very large percentage of voters would have to be fed up with FPTP to force change in that area. Also, they would have to be educated enough to understand that FPTP is a problem.

[–] demesisx@infosec.pub 8 points 9 months ago* (last edited 9 months ago) (1 children)

For one, FPTP doesn’t get enough credit for just how nefarious it is. And let me be clear: I am speaking of the presidential election specifically, though I’m sure this applies to many aspects of this “democracy” including state elections, etc that you mentioned.

Instead, the overarching establishment narrative likes to point the finger at the electoral college (which also quite heavily biases the power of votes toward voters in less populous areas and states).

Since the established oligarchs (who own the news outlets) tend to control information delivery in this country, how would you break through that wall? Would you engage in peaceful protest (or self immolation)? Well, they’ve got a playbook for that too. They will discredit you and make you seem unhinged. For proof of that, look at the way they’re delegitimizing the brave, selfless active duty Air Force member who engaged in peaceful protest by self immolation outside of the Israeli embassy against the Gaza war for just how easy it is. Most news watching voters probably already think he was crazy. It didn’t quite have the power that that act had during, say, the Vietnam war.


Since you’re here, I’m guessing you’re a software engineer. Do me a favor: Model the real world dynamics of a US presidential election using domain driven design, making sure to accurately represent the two objectively unfair stages:

Rule #1: All candidates must pass stage 1 to be eligible for stage 2.

In stage 1, feel free to cheat, commit fraud, and engage in any strategy you need to prevent anyone but the owners of the party’s preferred candidates from winning. After all, your party is a private organization that can engage in whatever unfair tactic they deem necessary.

In stage 2, (if you’re paying attention, you ALREADY have irreparably biased the possible outcomes by cheating in stage 1) because of FPTP, you can now simply choose between only two of the MANY, MANY parties.

If you designed a system like that as a software engineer, your colleagues would be at your throat about how flawed that design was. However, here in the US, that’s just the design of our dEMoCrACy oF tHa gReATeSt cOuNTry iN tHa wErLD! 🥴

Edit: That “much worse” statement seems to come from a place of privilege. Don’t forget that. RIGHT NOW, more people are homeless and destitute than any other time in MY LIFE (I was born in the late 70’s). And most people literally have no say in whether or not their tax money is being used to genocide Muslims overseas to make room for a puppet government. Remember: You’re an anti-Semite if you oppose genocide.

[–] parens@programming.dev 2 points 9 months ago

Remember: You’re an anti-Semite if you oppose genocide.

Clearly. Good people can't do bad things.

[–] griD@feddit.de 2 points 9 months ago* (last edited 9 months ago)

but municipal and regional elections have miserable turn-outs too

Don't mind me, just reposting a FPTP video I just saw in another thread on lemmy.
It also heavily discourages voters from participating because they've never felt represented, as the two party system is ultimatively a minority rule. So why should they care for local elections held within the same system?

Edit: a word.

[–] jkrtn@lemmy.ml 6 points 9 months ago (1 children)

It requires score voting so that, even if heavily gerrymandered, one can still meaningfully express a preference without throwing one's ballot in the garbage.

[–] Hacksaw@lemmy.ca 3 points 9 months ago

It's never throwing your ballot in the garbage though. I used to think the same way, but every vote on the left, even if for the lesser evil, even if they lose, moves the conversation to the left. When we all stay home you get maga nutjobs stealing the show running unchecked.

Last thing is that gerrymandered states are the EASIEST to upset by increasing voter turnout. To gerrymander effectively you have to put your opponent in dense areas they'll win by a large margin, then spread your side so that you barely win the rest of the districts. That means that a 5% increase in votes on the left can take you from a loss to a nearly complete victory in a gerrymandered state.

Vote splitting on the other hand is a trickier beast, but in the end if all the left votes go to a moderate then that gives the left a lot of leverage because if the moderate candidate doesn't bend to the left then they'll lose the next election.

Always vote.

[–] otl@lemmy.sdf.org 4 points 9 months ago

I feel this is a bit of a moot point from the White House. Memory-safe languages have been around for decades. I feel like the amount of C/C++ out there isn't so much that people think having dangerous stuff around is good, but more that nobody really wants to pay to change it.

[–] onlinepersona@programming.dev 27 points 9 months ago* (last edited 9 months ago)

Leaders in Industry Support White House Call to Address Root Cause of Many of the Worst Cyber Attacks

And it's called C/C++. It's gotten so bad that even the friggin' white house has to make a press release about it. Think about it, the place where that majority barely even understand the difference between a file browser and a web browser is telling you to stop using C/C++. Hell, even the creator and maintainers of the language don't know how to make it memory safe. If that isn't a wake up call, then nothing ever will be.

And this isn't the first call! The IEEE also says more clearly: GTFO C/C++.

If you want memory-safe, don't write C/C++. Trying to get that shit memory-safe is a hassle and a half. You're better off learning a language that isn't full of foot-guns, gotchas, and undefined behavior.

CC BY-NC-SA 4.0

[–] technom@programming.dev 23 points 9 months ago (1 children)

they don’t feel like your fighting the language

I really understand what you mean wrt Rust. I really do - I was there once. But it's a phase you grow out of. Not just that - the parts you fight now will eventually become your ally.

and let me feel sort of creative in the way I do things

I had the same experience with C/C++. But as the design grows, you start hitting memory-safety bugs that are difficult to avoid while coding - even after you learn how those bugs arise in the first place. Just a lapse of concentration is enough to introduce such a bug (leaks, use-after-free, deadlocks, races, etc). I've heard that C++ got a bit better after the introduction of smart pointers and other safety features. But, it comes nowhere near the peace of mind you get with garbage collected languages.

That's where Rust's borrow checker and other safety measures kick in. The friction disappears when you acquire system knowledge - concepts of stack, heap, data segment, aliasing, ownership, mutation, etc. These knowledge are essential for C/C++ too. But the difference here is that Rust will actually tell you if you made a mistake. You don't get that with C/C++. The ultimate result is that when a Rust program compiles successfully, it almost always works as you expect it to (barring logical errors). You spend significantly less time debugging or worrying about your program misbehaving at runtime.

The 'friction' in Rust also helps in another way. Sometimes, you genuinely need to find a way out when the compiler complains. That happens when the language is too restrictive and incapable of doing what you need. You use things like unsafe, Rc and Refcell for that. However, most of the time, you can work around the problem that the compiler is indicating. In my experience, such 'workarounds' are actually redesigns or refactors that improve the structure of your code. I find myself designing the code best when I'm using Rust.

[–] crimsonpoodle@pawb.social 1 points 9 months ago (1 children)

I do really like the error system in rust for its descriptions. I guess the difficulty for me, which maybe will go away after writing more rust, is that my intuition for what is efficient and what isn’t totally breaks down.

I find myself passing copies of values around and things like that, it might be that the compiler just takes care of that, or that I just don’t know how to do it well but that’s often the point of friction for me.

Totally agree on the refactor though, most of the time it doesn’t even take that much time since you know the skeleton of what you want at that point!

[–] technom@programming.dev 5 points 9 months ago* (last edited 9 months ago)

I find myself passing copies of values around and things like that, it might be that the compiler just takes care of that,

Rust prefers explicitness over magic. So it does what you tell it and doesn't just take care of that.

If you're copying a lot of values around (I.e cloning. Not moving or borrowing), then you're definitely doing it inefficiently. But you don't have to worry too much about that. If there are too many difficulties in borrowing, it may be because those borrows are problematic with respect to memory safety. In such cases, sacrificing performance through cloning may be an acceptable compromise to preserve memory safety. In the end, you end up with the right balance of performance (through borrowing) and safety (through cloning). That balance is hard to achieve in C/C++ (lacking in safety) or in GC languages (lacking in performance).

If that's the friction you're facing in Rust, then I would say that you're already in a good position and you're just trying too hard.

[–] Faresh@lemmy.ml 12 points 9 months ago (4 children)

What memory-safe systems programming languages are out there, besides Rust?

[–] Traister101@lemmy.today 6 points 9 months ago (1 children)
[–] Faresh@lemmy.ml 12 points 9 months ago (2 children)

I appreciate your answer, but I mentioned systems programming, because I was more interested in languages that do not rely on a garbage collector.

[–] BatmanAoD@programming.dev 21 points 9 months ago (1 children)

To play devil's advocate, most systems programming can be done even with a garbage collector. Midori was a project to build an operating system on a variant of C#, and although the garbage collector did impose technical difficulties, it wasn't a dealbreaker. Go isn't usable everywhere Rust is, but it can in fact be used for many things that previously would have been considered "systems" niches (which is part of why there was a somewhat prevalent misconception in the early days of Rust that they were similar languages). Prominent D developers have defended D's garbage collector (even though it's technically optional). Bjarne Stroustrup, the creator of C++, used to express great confidence that C++ would one day have a garbage collector.

...but you're right, Rust and its rise in popularity (and, conversely, the C++ community's resistance to adopt anything with garbage collection) have definitely narrowed the common definition of "systems programming" to exclude anything with a "thick" runtime.

[–] andyburke@fedia.io 3 points 9 months ago

I enjoyed the facts spit above.

[–] Traister101@lemmy.today 4 points 9 months ago

Huh, I totally missed that my bad

[–] psudo 3 points 9 months ago (3 children)

Wasn't Go designed to be a memory safe systems programming language? I haven't really used it enough to see if it holds true, though.

load more comments (3 replies)
[–] navigatron 1 points 9 months ago

I’m very flaky here, as rust is the big one, but I think zig and/or nim might be

[–] Adanisi@lemmy.zip 8 points 9 months ago* (last edited 9 months ago) (3 children)

I'm going to advocate for C here: the sheer simplicity, fast compile times, and power it gives you means it's not a bad language, even after all these years. Couple that with the fact that everything supports it.

Rust, while I don't actually know how to write it, seems much more difficult to learn, slower to compile, and if you want to do anything with memory, you have to fight the compiler.

And memory bugs are only a subset of bugs that can be exploited in a program. Pretending Rust means no more exploitation is stupid.

[–] lolcatnip@reddthat.com 6 points 9 months ago

I've written quite a bit of Rust and a lot of C and C++ code. I'll take Rust over C or C++ for any task, including ones where memory safety isn't a concern. Yes, there's a learning curve, but overall it's just more pleasant to use. Now that I'm used to it, writing C++ code feels just as much like fighting the compiler as Rust ever did.

[–] arisunz@lemmy.blahaj.zone 3 points 9 months ago

Bait used to be believable 🚬

[–] crimsonpoodle@pawb.social 2 points 9 months ago

Maybe it’s just because I haven’t had to deal with the scenario yet but does compile time really matter? I mean for small programs it seems it’s almost instant on modern machines and for large programs I would assume, if it exists, that you would be using the equivalent of make so you would only be recompiling the small changes made.

[–] Simulation6@sopuli.xyz 6 points 9 months ago

The interpreter or compiler could also introduce memory issues into the code. Much less likely to happen, but it is not unknown.

[–] PhlubbaDubba@lemm.ee 5 points 9 months ago

So that's why I've been hearing non-stop crab rave music!