87
submitted 1 year ago by BearPear@lemmy.world to c/linux@lemmy.ml

Will there be performance and security improvements?

you are viewing a single comment's thread
view the rest of the comments
[-] Killercat103@infosec.pub 32 points 1 year ago

Performance? Not really no. I believe C is slightly faster with Rust and C++ competing for second place. The benefit is safer code as Rust is built with performance and safety in mind. It highlights what potential errors can be found where making human error way less common. Instead of potential null errors types are wrapped in an option enumerator which ensures you know there can be a lack of a value. Expections are also enumerators done similarly with a result object so you know which functions may fail. Instead of using memory and potentially forgetting to free it we have the ownership system.

[-] rikudou@lemmings.world 8 points 1 year ago

How is C faster than C++? Unless you use virtual functions, it's as performant as C. And you definitely wouldn't use virtual functions in a kernel.

[-] skullgiver@popplesburger.hilciferous.nl 25 points 1 year ago* (last edited 1 year ago)

[This comment has been deleted by an automated system]

[-] anti_antidote@lemmy.zip 23 points 1 year ago

C++ is only as fast as C if you use only the parts of C++ that are identical to C. In other words, C is faster than C++

[-] Haugerud@discuss.tchncs.de 11 points 1 year ago

You can use compile time polymorphism in C++ without any runtime performance cost.

[-] PuppyOSAndCoffee@lemmy.ml 0 points 1 year ago

Compile time has got to be part of the convo esp when it comes to the kernel. The Linux kernel is one of the few bits where end-users are actively encouraged to compile from source. It is a feature!

Adding C++ compilitis is pain for what gain, from a kernel pov.

I am not a big fan of c++ overall however that is because other languages have emerged that are sweeter than C that gate some of the people issues with C++.

Anyone who has ever had a thing that was like a thing but not exactly the thing, in C, knows C ain’t great at that.

[-] anti_antidote@lemmy.zip -5 points 1 year ago
[-] cmeerw@programming.dev 8 points 1 year ago

The description says:

In this video, we'll do a deep dive on what C++ Polymorphism is, what "virtual" does under the hood, and ultimately why it is SUCH a performance hit compared to languages like C and Rust.

This is not about compile-time polymorphism.

[-] PipedLinkBot@feddit.rocks -1 points 1 year ago

Here is an alternative Piped link(s): https://piped.video/watch?v=aq365yzrTVE

Piped is a privacy-respecting open-source alternative frontend to YouTube.

I'm open-source, check me out at GitHub.

[-] lloram239@feddit.de 6 points 1 year ago

That's just plainly false. A std::sort() for examples beats a qsort() easily. C just doesn't have the tools to handle that kind of thing without a lot of manual code duplication.

The reason for not using C++ is simply that it's a huge monster of a language, that makes it difficult to find common ground for a programming style. In C that is much easier as you have much less features to worry about. It is more verbose and error prone, but also more predictable and easier to review, as the code you see is what you get in the binary. In C++ can have a mountain of stuff hidden behind operator overloading, exceptions and other stuff, which makes it very difficult to reason about.

[-] Cpo@lemm.ee 2 points 1 year ago

Aside from that I think C is more performant than C++ (indeed when you use the bells and whistles that C++ offers), you are comparing the libraries with each other.

The fact that the implementation of one random std::Sort is faster than the implementation of qsort() is comparing libraries, not the languages. You are comparing the algorithm of the Rust Sort with quicksort (which is obviously the qsort you are referring to.

I am certain there are sort implementations in C which outperform Rust.

Having said that, I immensely enjoy Rust because it forces me to think about the error handling and it does not give me the quirks of C/C++ (index out of bounds, memory corruption).

[-] lloram239@feddit.de 1 points 1 year ago

you are comparing the libraries with each other.

It's not the libraries that make the difference, but that C++ templates allow you to write generic code that is easy to use and easy to optimized for the compiler due to having all the real data types readily available, while C has to fiddle with void* and function pointer to get similar flexibility, which are much harder to optimize, as none of the type information is there.

[-] Cpo@lemm.ee 0 points 1 year ago

while C has to fiddle with void* and function pointer to get similar flexibility, which are much harder to optimize, as none of the type information is there.

I thought we were discussing speed, not ease of use?

[-] lloram239@feddit.de 0 points 1 year ago

If you manually hand optimize every line of code, C and C++ are identical. That's a worthless discussion to have. The point is that you can write in C++ high level code that would require substantial code duplication to match the speed in C, as C just doesn't offer the tools for that level of abstraction.

[-] Cpo@lemm.ee 0 points 1 year ago

...so now we are discussing not speed again but ease of use.

Not everything with an R in it is faster than C. Read up about it. Everyone says so.

I'm out.

[-] Zatujit@reddthat.com 2 points 1 year ago

Since C++ has Turing complete compiling, I guess technically it can go infinite compilation time

this post was submitted on 18 Aug 2023
87 points (97.8% liked)

Linux

48740 readers
1188 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