226
submitted 2 months ago by mnmalst@lemmy.zip to c/linux@lemmy.ml

Exiting news for the lady bird browser. https://ladybird.org/

you are viewing a single comment's thread
view the rest of the comments
[-] jqubed@lemmy.world 12 points 2 months ago

As someone who has done no programming since taking C++ in high school more than 20 years ago, what do you mean by safer language?

[-] brenticus@lemmy.world 38 points 2 months ago

C and C++ require more manual management of memory, and their compilers are unable to let you know about a lot of cases where you're managing memory improperly. This often causes bugs, memory leaks, and security issues.

Safer languages manage the memory for you, or at least are able to track memory usage to ensure you don't run into problems. Rust is the poster boy for this lately; if you're writing code that has potential issues with memory management, the compiler will consider that an error unless you specifically mark that section of code as unsafe.

[-] Kajika@lemmy.ml 8 points 2 months ago

I'm not sure why people keep pushing that myth on C++. It's been a decade we have smart pointers. There's no memory management to be done ever.

Using the old 'new' is like typing 'unsafe' in rust. Even arrays/vectors have safe accessor.

Am I missing something?

[-] brenticus@lemmy.world 7 points 2 months ago

It's been almost a decade since I used C++ and had to verify, but after some quick searching around it looks like it hasn't changed a ton since I last looked at it.

You can use smart pointers, and certainly you should, but it's a whole extra thing tacked on to the language and the compiler doesn't consider it an issue if you don't use them. Using new in C++ isn't like using unsafe in rust; in rust your code is almost certainly safe unless marked otherwise, whereas in C++ it may or may not be managed properly unless you explicitly mark a pointer as smart.

For your own code in new codebases this is probably fine. You can just always make your pointers smart. When you're relying on code from other people, some of which has been around for many years and has been written by people you've never heard of, it becomes harder to be sure everything is being done properly at every point, and that's where many of these issues come into play.

load more comments (1 replies)
load more comments (2 replies)
load more comments (7 replies)
this post was submitted on 01 Jul 2024
226 points (93.8% liked)

Linux

47324 readers
1222 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS