this post was submitted on 26 Feb 2024
169 points (97.2% liked)

Programming

17492 readers
53 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 1 year 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 50 comments
sorted by: hot top controversial new old
[–] fidodo@lemmy.world 46 points 9 months ago (2 children)

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

🚩

load more comments (2 replies)
[–] mox@lemmy.sdf.org 44 points 9 months ago (9 children)

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

[–] jkrtn@lemmy.ml 21 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 8 points 9 months ago (1 children)

That requires a population willing to vote for such legislators.

[–] jkrtn@lemmy.ml 7 points 9 months ago (4 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.

load more comments (4 replies)
load more comments (8 replies)
[–] mipadaitu@lemmy.world 37 points 9 months ago (1 children)

Depends on if you're coding for critical infrastructure (i.e. - electrical grid), or writing a high performance video game that can run on older hardware.

We should absolutely have specific licenses like Civil Engineers do for computer infrastructure that is required for any software written for specific purposes. It would be a nightmare to implement, but at some point, it's going to be needed.

[–] SorteKanin@feddit.dk 18 points 9 months ago (17 children)

writing a high performance video game that can run on older hardware

Unless it's some really exotic platform, I'd honestly still say no. Rust has shown that memory safety and performance doesn't have to be a tradeoff. You can have both.

But sure, if whatever you're targeting doesn't have a Rust compiler, then of course you have no choice. But those are extremely rare cases these days I'd say.

[–] themusicman@lemmy.world 13 points 9 months ago (1 children)

There's always a trade-off. In rust's case, it's slow compile times and comparatively slower prototyping. I still make games in rust, but pretending there's no trade-off involved is wishful thinking

[–] Lmaydev@programming.dev 24 points 9 months ago (1 children)

They mean a trade off in the resulting application. Compile times mean nothing to the end user.

[–] dgriffith@aussie.zone 10 points 9 months ago (1 children)

That may be true but if the language is tough to develop with, then those users won't get a product made with that language, they'll get a product made with whatever language is easier / more expedient for the developer. Developer time is money, after all.

load more comments (1 replies)
load more comments (16 replies)
[–] technom@programming.dev 31 points 9 months ago (2 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.

load more comments (2 replies)
[–] onlinepersona@programming.dev 18 points 9 months ago* (last edited 9 months ago) (2 children)

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

[–] Feathercrown@lemmy.world 10 points 9 months ago

You’re better off learning a language that isn’t full of foot-guns, gotchas, and undefined behavior.

As a JS developer, seeing this quote about C/C++ for a change gives me unbelievable levels of schadenfreude

[–] abhibeckert@lemmy.world 8 points 9 months ago (2 children)

~~If you want memory-safe,~~ don’t write C/C++.

Fixed that for you. There's no situation where you want buffer overruns.

[–] cm0002@lemmy.world 15 points 9 months ago

There's no situation where you want buffer overruns.

I want buffer overruns in my game consoles for jailbreaking purposes lmfaoooooo

load more comments (1 replies)
[–] Faresh@lemmy.ml 10 points 9 months ago (13 children)

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

[–] mox@lemmy.sdf.org 9 points 9 months ago (2 children)
[–] arendjr@programming.dev 12 points 9 months ago

Zig is better than C, but still a far stretch from the memory safety of Rust: https://www.scattered-thoughts.net/writing/how-safe-is-zig/

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

Also Swift!

load more comments (12 replies)
[–] PhlubbaDubba@lemm.ee 9 points 9 months ago

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

[–] Simulation6@sopuli.xyz 8 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.

load more comments
view more: next ›