Linux serverlinux web serverNETWORK ADMINISTRATIONS

Why i think C++ is better than rust

Recorded live on twitch, GET IN

https://twitch.tv/ThePrimeagen

### Links
Article: https://lucisqr.substack.com/p/why-i-think-c-is-still-a-very-attractive
Author: https://substack.com/@hbucher

MY MAIN YT CHANNEL: Has well edited engineering videos
https://youtube.com/ThePrimeagen

Discord
https://discord.gg/ThePrimeagen

Have something for me to read or react to?: https://www.reddit.com/r/ThePrimeagenReact/

Kinesis Advantage 360: https://bit.ly/Prime-Kinesis

Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
https://turso.tech/deeznuts

source

by ThePrimeTime

linux web server

34 thoughts on “Why i think C++ is better than rust

  • Define "better". In some ways it may be better and in others is crap.

  • "you don't even get a build tool with C++"

    I'd just like to interject for a moment. What you're refering to as C++, is in fact, GCC/C++, or as I've recently taken to calling it, the GNU compiler collection plus C++. C++ is not a compiled language unto itself, but rather another free component of a fully functioning GCC system made useful by the C standard library, C++ standard template library and vital system components comprising a full OS as defined by POSIX/WIN32.

    Many computer users run a specific component of the GNU compiler collection every day, without realizing it. Through a peculiar turn of events, the portion of GCC which is widely used today is often called C++, and many of its users are not aware that it is basically the G++ compiler, developed by the GNU Project.

    There really is a C++, and these people are using it, but it is just a part of the compiled language they use. C++ is the language: the source text of the binary that allocates the machine's resources to the other programs that you run. The language is an essential part of an compiled language, but useless by itself; it can only function in the context of a complete compiler. C++ is normally used in combination with the GNU Compiler Collection: the whole system is basically GCC with C++ added, or GCC/C++. All the so-called C++ versions are really versions of GCC/C++!

  • "In many years of coding C++, very rarely I experienced a stack overflow or segmentation fault". Haha. The author of this article must be some kind of a genius, if he's telling the truth. I get segfaults just from using std::vector and iterators.

  • As was said at the start with Rust, it is good for O/S and critical security applications. In that case, paying a lot of hassle to have defaults set to "safe" that need to be turned off for performance is worth it. Other cases, I agree, are debatable.

  • Just because a lot of people choose or want to use a language doesn't make it a good or the best choice. Look how many want to use python.

  • The game industry has a lot of range. If you were to look at the game engine developers not just the overall industry then you would be more to find the top end of the C++.

  • I never had an issue using ASM. In fact it was a requirement when I went to school ASM was required before C or C++. I also was required to learn it in the military. I tend to find most the programmers I know who had to learn ASM first are better programmers by far than the one's I know who didn't.

  • Frankly, I agree with the statement pointers are intuitive. They hold the memory address of where the data is stored. Or easier more most to understand they point to the memory location the data is stored. How is that difficult?

  • Just a reminder to all the edgy kids in the room that the C++ community has always been full of commies

  • My fast take on Rust vs C++.
    They are stairs that goes to thousand steps into the sky.
    Rust's staircase has firm and strong handrails and also provide you with a harness, whereas C++ it might have handrails, but you have no harness.

    How much can you trust yourself to not f- it up, and fall, and if you're in a team, everyone tied together, how much can you trust everyone from not falling?

  • Worth mentioning that in rust if you're using Iterators you mostly shouldn't have bound checks

  • I think the take away from this was an expert programmer without experience in security should not have been pretending to be an expert in security. Some real poor claims made particularly around the whole external/internal was poorly understood. To state that vulnerabilities on internal systems don’t matter, is big red flag. Then to base a lot of the argument on that fact; hol-up!

    Skill issue

  • OMG Prime, you’re meant to be a C++ developer (at Netflix BTW) and yet you’re mumbling nonsense about unique_ptr. 🤦🏻‍♂️

  • 16:00, pointers are easy to understand (it really is just an address), pointer syntax on the other hand, that needs some work……

  • unique_ptr's are almost free. There is a small cost in some situations. If you pass a unique_ptr to a function, unless the compiler has visibility into the function, it can't know if the function takes ownership or not. And so it will have to check the unique_ptr for being null before freeing it.

    And that's basically it.

    Iterators in Rust sound very similar to ranges in C++20 and higher. And you can see the same optimization results.

  • The build tools are the things that annoy me the most about both Rust and Go. Who wants some tool that grabs random garbage from the Internet and stuffs it into your program? Dependencies should take a lot of time and effort to consider, and versioning them should be a conscious decision.

    Supply chain attacks are no joke.

  • C++ code can be safe… but only if it's written entirely by at most one C++ programmer.

  • 23:47, after Sanitizers, there's no much room for loosing too much time catching a memory bug. Plus, they allow us to be more productive, coding faster, getting seg faults often, fixing them right away.

  • Antecessor is a synonym to ancestry, or the grant grant parent in a inheritance relation scheme.

  • White risk supporting your project long-term with a language that doesn't have expert developers?

    Application rate? Pretty garbage metric.

  • Regarding the compiled examples Rust has different save variants for simple operators:
    * Is unchecked multiplication that is, as the article states, not checked in release mode
    But there existist: .checked_mul(rhs) .saturating_mul(rhs) .wrapping_mul(rhs) which all have different begaviour regarding the overflow
    With that convidered what the rust program means is that programmer wants the unchecked mul and div and thats what the compiler outputs while in c++ the compiler is following this hidden list of UB rules that you need to know to decode what the program would compile into.

    In my opinion Rust better reflects what the programmer expressed in the program than C++

  • You can get rust (nightly) to not even produce code for the function and inline it as identity (using unsafe). Calling it "the unsafe excuse" is IMO a misunderstanding of what unsafe does. Unsafe makes it sound like you're now free to do as you want, but unsafe allows you to do only three specific things you could not do before, not throw out the entire promise of rust.

  • C++ feels more natural for games, lower level networking (though I made a UDP server daemon in PHP once), tight latencies and control over timing off the HPET (side note: not in sync across cores), manually scheduling mem copies between concurrent threads and shared memory "mutex" signalling, etc. And you sort of need to be able to arbitrarily change techniques and profile+AB test on different hardware.
    Otherwise I'd rather use something higher level anyway which skips over Rust – where Go and thousands of other relatively simple languages fit nicely.

  • @28:00 "At every step you have to handle what could happen if there was an exception there."
    This is not true. Exceptions can bubble up to higher calling functions. You don't necessarily need to handle an exception where the error occurs. You only need to make sure your code is exception safe. An advantage of exceptions is that they cannot be ignored. Return codes can be ignored and the program may continue on to cause damage to data.

    "Errors as values typically lead to easier reasoning about your program."
    This is also not true. With return values you must intersperse error handling code with normal code path. But with exceptions you can focus on the normal code path and don't need to see the error handling if it can be relegated to a higher level. (Although Rust does have a way to make return code error handling look like exceptions.)

  • As an older guy, I found that understanding assembly was easier than pointers and not harder. I started programming assembly on a Commodore VIC-20 before I ever heard of pointers or C. If you understand the addressing modes in assembly then you just naturally understand pointers.

  • I have to say I love your videos! Despite all the humor you truly look over the bias fence while not being afraid to not know all the answers. That's refreshing and inspiring in a world so full of bulshit certainties.

  • That article must have been written by a drunk ChatGPT … it had me until it said beginners find C pointers easy. I found it easy, but I already understood memory addressing.

Comments are closed.