C++ and Rust At The Same Time | Prime Reacts

Ғылым және технология

Recorded live on twitch, GET IN
/ theprimeagen
Reviewed article: www.kdab.com/mixing-c-and-rus...
By: Loren Burkholder
MY MAIN YT CHANNEL: Has well edited engineering videos
/ theprimeagen
Discord
/ discord
Have something for me to read or react to?: / theprimeagenreact
Kinesis Advantage 360: 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))
turso.tech/deeznuts

Пікірлер: 170

  • @wahidislamlinad
    @wahidislamlinad5 ай бұрын

    the editor deserves a raise 🤞

  • @cmelgarejo

    @cmelgarejo

    5 ай бұрын

    Flip is the best

  • @NibbleMeTwice
    @NibbleMeTwice5 ай бұрын

    When the camera stopped working, and Prime had to become the Pictureagen, was the mouth animated using input from the Microphone as a scalar? If so, bravo. If you edited this by hand, Flip, also bravo.

  • @WillEhrendreich

    @WillEhrendreich

    5 ай бұрын

    Yeah, both things are impressive in their various ways, lol.

  • @UQuark0

    @UQuark0

    5 ай бұрын

    My thoughts exactly

  • @karasick4214

    @karasick4214

    5 ай бұрын

    He has a Vtuber tag tho

  • @theseangle

    @theseangle

    5 ай бұрын

    C'mon this is a programming channel, you think the editor hasn't learned enough in his spare time to automate this task? 😆

  • @LorenDB
    @LorenDB5 ай бұрын

    Hi, author of the blog post here! Very exciting to see that my crazy ideas are well received:)

  • @KDABtv
    @KDABtv5 ай бұрын

    Hey, great you liked Loren's blog. Thanks for commenting on it on your channel!

  • @Spirrwell
    @Spirrwell5 ай бұрын

    D can literally import C code too. The feature is literally called importC! Having used D for over a year, it's a great language. You should give it a try for a few days. There will be things you start to like. I guarantee it. If not, well dangit I'm sad. EDIT: And somebody mentioned this in literally the last 30 seconds.

  • @GeorgijTovarsen
    @GeorgijTovarsen5 ай бұрын

    D glue? Nobody wants to touch that

  • @ThePrimeTimeagen

    @ThePrimeTimeagen

    5 ай бұрын

    Ain't no way

  • @bsdooby

    @bsdooby

    5 ай бұрын

    Why not?

  • @thedeemon
    @thedeemon5 ай бұрын

    who needs C++ and Rust when you can program in D!

  • @Bliss467
    @Bliss4675 ай бұрын

    Prime is so great at reading aloud and internalizing simultaneously.

  • @atiedebee1020
    @atiedebee10205 ай бұрын

    The order of fields in C structs is absolutely guaranteed

  • @omri9325

    @omri9325

    5 ай бұрын

    Sounds crazy to hint it's not

  • @Ellefsen97
    @Ellefsen975 ай бұрын

    I honestly think this has a lot of potential. If there are tooling in the future that can create the D file automatically, it might be possible to seamlessly use Rust in a C++ codebase. Maybe if you have a C++ application and there’s a feature that would be easier to manage with Rust. It could also potentially make it easier to gradually move a project from C++ to Rust one function at a time, without needing to use gRPC or other microservices shenanigans

  • @feynman_QED

    @feynman_QED

    5 ай бұрын

    Why should i move from C++? Why don't you keep on working with Rust and stop suggesting ways of removing a language like C++ that many others like to use?

  • 5 ай бұрын

    Completely agree. Keep in mind that most of the people complaining about C++ have no clue about C++, or they don't use anything after C++11@@feynman_QED

  • @chainingsolid

    @chainingsolid

    5 ай бұрын

    I wonder how viable it would be to use D as a build system in this case. Just have a D program generate the bindings then kick off the compilers for all 3 langs then execute the program. Cool thing there is getting D + its package manger/build system Dub + some libraries to use only takes < 10 minutes, starting from having non if it installed. Even better given some of D's other features many D programmers are use to writing code to generate code.

  • @Ellefsen97

    @Ellefsen97

    5 ай бұрын

    @@feynman_QED Why are you so defensive? I’m not telling anyone to move away from C++, you can code in whatever language you like. However, there are people that would like to take a legacy codebase and migrate over to Rust and the article showed a very promising way to possibly accomplish it.

  • @feynman_QED

    @feynman_QED

    5 ай бұрын

    @@Ellefsen97 First of all, i am not defensive. With one of your level? Come on. Second, you wrote that "It could also potentially make it easier to gradually move a project from C++ to Rust". It's not consistent with what you've just said. This sentence says another story. Why should i move a project from C++ to Rust? Explain that to all of C++ programmers why. They are really interested.

  • @varjotin
    @varjotin5 ай бұрын

    The lip sync is anazing😮

  • @re_detach

    @re_detach

    5 ай бұрын

    I hope Prime looks the same for next stream lowkey

  • @petyabubkin2800

    @petyabubkin2800

    5 ай бұрын

    It works on audio input. Easy task for streaming or editing software.

  • @michaelreese401
    @michaelreese4015 ай бұрын

    D seems to be good at combining other languages. It can also be used to automatically generate python bindings for C-libraries.

  • @TJackson736

    @TJackson736

    5 ай бұрын

    That's sweet and I will have to keep that in mind for my company.

  • @michaelreese401

    @michaelreese401

    5 ай бұрын

    @@TJackson736 details are in an article "calling c from python" in the blog "atila on code"

  • @The1RandomFool
    @The1RandomFool5 ай бұрын

    I used the GMP C library in Zig recently and it wasn't that bad to figure out and use. I used it to calculate some constant I created to arbitrary precision based on a Michael Penn video. It was an order of magnitude faster than Boost for C++.

  • @pbentesio
    @pbentesio5 ай бұрын

    The creator of sokol wrote an article a while ago about how he uses the AST json dump from clang to auto generate bindings. It would be awesome if a wrapper could be built on top of VCPKG for instance that would autogenerate bindings for a given language.

  • @krtirtho
    @krtirtho5 ай бұрын

    D does a really good job at glueing stuff together hehe

  • @dexterman6361
    @dexterman63615 ай бұрын

    The camera could be an overheating or buffering issue. Also amazing editor * chefs kiss * perfect cut/edit deserves a raise!

  • @alexpyattaev
    @alexpyattaev5 ай бұрын

    Rust will pack struct for optimal performance with minimal padding. c and c++ will add padding bytes until types are aligned, and have deterministic (albeit inefficient) layout.

  • @pxolqopt3597

    @pxolqopt3597

    5 ай бұрын

    Its not that it's inefficient its just that the responsibility of creating an efficient layout is on the programmer

  • @alexpyattaev

    @alexpyattaev

    5 ай бұрын

    @@pxolqopt3597 Yes, indeed, and you end up with structs where field order has nothing to do with code readability, which is "fun" for larger structs. Enjoy!

  • @indiesigi7807

    @indiesigi7807

    5 ай бұрын

    Optimal performance is why the padding is used. If you pack you lose performance but gain efficiency in size. Rust picks the least performant but safest way every time.

  • @indiesigi7807

    @indiesigi7807

    5 ай бұрын

    I always make sure to properly align the struct if i need it packed so it's not up to the compiler.

  • @indiesigi7807

    @indiesigi7807

    5 ай бұрын

    @@anon_y_mousse Yeah of course. I'm thinking small structs going over the wire personally. I'm just countering the ops assumption that packing means performance gain which it does not when accessing the members, the contrary in fact. Every dive i take into rust just proves the wildly inefficient choices they made.

  • @abc123evoturbobonker
    @abc123evoturbobonker5 ай бұрын

    Prime looks unusually good in this new video 😄

  • @skilz8098
    @skilz80985 ай бұрын

    This is a pretty cool idea and proof of concept. It has a lot of potential to become a very powerful and versatile tool. I'd like to see where this kind of project will end up being in say 3-5 years... Hmm, maybe do an update video on this say in 2005 or 2007 to see if there's been any progress with it.

  • @psybertao
    @psybertao5 ай бұрын

    Makes me wonder, why not just use D? I had my experience using the Digital Mars C++ compiler many, many years ago and revisited it on occasion. I've always been impressed with the quality of their product, which can only be produced by the developers talent that has always been and is still above my full comprehension. I remember the excitement and passion they had for D when it came out but was resistant to adopt yet another emerging language at the time. It's clearly matured and is striving toward what other languages specialise in and C++ struggles to keep up with.

  • @AndreSomers

    @AndreSomers

    5 ай бұрын

    Probably because there is a lot of exciting C++ code out there…

  • @floppa9415

    @floppa9415

    5 ай бұрын

    D's tools libraries in general suck the big one at least last time I checked (about 1.5 years ago). The VS Code extension for example still is the state where the compiler says one thing and the extension something else.

  • @psybertao

    @psybertao

    5 ай бұрын

    @@floppa9415 Thanks for the feedback. That doesn't surprise me. The reason I didn't continue using the DM C++ compiler was because of the linker's limited support to OMF, requiring you to convert MS-COFF libraries to VS6 MS-COFF to then use their COFF2OMF tool, or I guess use another linker...it was limitations like that which put me off using it. Fantastic product with a lot of passion behind it, but impossible to use when you step outside the eco-system. Reading the GCC page, David Friedman is no longer the developer with the D project having been revived in 2009 by Iain Buclaw and other contributors. I wish them well but it seems D never reached the critical mass it needs to thrive.

  • @dhay3982
    @dhay39825 ай бұрын

    The next step would be cutting the "middle D" and implement the Extern(C++) functionality directly into the rust compiler.

  • @ZILtoid1991

    @ZILtoid1991

    5 ай бұрын

    Well, that's not something a lot of languages will even attempt to do, and in D, multiple inheritance from C++ classes won't really work, and from what I've heard your only option there is to dupe the D compiler that the class doesn't have multiple inheritance and the compiler won't have a problem during name mangling. However, multiple inheritance is usually not a good thing.

  • @dekrain

    @dekrain

    4 ай бұрын

    It already exists as a macro crate called "cxx". You put in some declarations about the C++ side & the Rust side and it handles all the mangling for you. AFAIR it also goes both ways between C++ Rust

  • @lukegary4482
    @lukegary44825 ай бұрын

    Coincidentally, I've been playing a lot with SystemC and creating my own meta language that can expand upon the zig and nim compile time semantics to allow for managing firmware, RTL, mixed signal simulation, and application code in a single source file(s). Wouldnt it be great to describe a memory mapped peripheral, the actual rtl/hdl, as well as a digital/analog simulation in a single namespace? Thats my dreamworld.

  • @Qaos2
    @Qaos25 ай бұрын

    I don’t code and idk what you’re talking about most of the time but I enjoy your channel and humor. Might learn to code as a new hobby

  • @VivekYadav-ds8oz

    @VivekYadav-ds8oz

    5 ай бұрын

    Wow how did you find the channel then?

  • @VivekYadav-ds8oz

    @VivekYadav-ds8oz

    5 ай бұрын

    Oh and please don't start your coding journey with any of the languages mentioned in this video XD Maybe C++ as a flavour of C if you wanna start knowing from the very basics, but if you're not already curious about computer fundamentals, this will be harder than starting with Python/JS.

  • @Qaos2

    @Qaos2

    5 ай бұрын

    @@VivekYadav-ds8oz I googled how to code for video games. I went down the rabbit hole and ended up here. A lot of people say don’t learn c++ first but primetime can’t stress enough how important the fundamentals are so I believe I’ve made my choice. Now where to begin lol. I definitely hope to spell cast in vim one day too!

  • @ivanjermakov
    @ivanjermakov5 ай бұрын

    Did the editor manually set keyframes for Prime's mouth, or automated it based on mic audio amplitude?

  • @marcs9451

    @marcs9451

    5 ай бұрын

    automated (hopefully)

  • @JohnneyleeRollins
    @JohnneyleeRollins5 ай бұрын

    Throw wren in there and you got yourself a CD-RW

  • @kuhluhOG
    @kuhluhOG5 ай бұрын

    15:25 Since "and" is in German "und", "C++, Rust und D" actually makes even more sense, lol.

  • @floppa9415
    @floppa94155 ай бұрын

    Gives me "trying to use every JVM Language in a project vibes".

  • @dekrain
    @dekrain4 ай бұрын

    I just wanted to say that Rust *does* indeed allow you to set the mangled name of a function/static via. #[export_name = "..."] attribute 🙂

  • @GreatWalker
    @GreatWalker5 ай бұрын

    ThePrimeagen might be my favourite PNGtuber

  • @georgehelyar
    @georgehelyar5 ай бұрын

    I had to do something similar the other day where a C++ library that I could not change exposed a C ABI with function pointers but no user defined context argument, and I needed to call it from a capturing closure. What a nightmare.

  • @robinpage2730

    @robinpage2730

    5 ай бұрын

    All this programming language nonsense is boring. Just code everything in assembly language. Then you only need a cross-assembler to compile for different CPU architectures, which can cross-assemble itself to run on those architectures.

  • @shrootskyi815

    @shrootskyi815

    5 ай бұрын

    @robinpage2730 A few things about assembly languages and assemblers you might find informative: - Assembly language is not a single language, but a rather a type of language. There are multiple different, system-specific assembly languages. - A cross-assembler is a program that runs one type of system, but generates machine code for a target system of a different type. - Programs which take code written in one assembly language and translate that code into a different assembly language don't really exist, because there are fundamental incompatibilities between systems. To make that work, you'd have to translate the assembly code into some kind of higher-level representation - or in other words, decompile the assembly language into a programming language. There a few exceptions to this: for example, translating linux 32-bit risc-v assembly to linux 64-bit risc-v is generally quite possible, depending on the risc-v extensions supported by the target cpus.

  • @SimGunther
    @SimGunther5 ай бұрын

    As the prodigal Dlang son, my ts-rust-zig-deez implementation may be not as organized or thoroughly tested, or turned into a proper compiler not reliant on GC. But I can at least say that I wrote a pretty dang good incremental compilation model for a Monkeyscript REPL through the power of Haskell Maths!

  • @markdanielesplanaperilla
    @markdanielesplanaperilla5 ай бұрын

    Watching Prime at that state gave me nightmares.

  • @pxolqopt3597
    @pxolqopt35975 ай бұрын

    It would be so cool if there was some mega standard that allowed you to connect any language together just flawlessly, it would be very complicated and never happen but its interesting

  • @user-qr4jf4tv2x
    @user-qr4jf4tv2x5 ай бұрын

    i like the new prime he looks so calm

  • @user-tb5re6zs2r
    @user-tb5re6zs2r5 ай бұрын

    That's my main gripe with Zig, it's very young and Kelley seems a bit aloof and not very concerned with it. However, this is a negative, Rust started as private project and has grown to be a mature systems programming language. When Zig hits that point i would see it as viable but in its current state, it's a no go.

  • @notuxnobux

    @notuxnobux

    5 ай бұрын

    When rust was as old as zig is now it was also in alpha stage, despite having many people working on it full time with large corporate backing and zig is trying to cover a larger range of programming than simply a programming language and compiler. It's good that it takes it slow before zig is version 1.0 where backward compatiblity breaking changes cant be made. I remember when rust was in alpha and it also made breaking changes every month.

  • @josefaguilar2955
    @josefaguilar29555 ай бұрын

    That's a little CRustD

  • @blenderpanzi
    @blenderpanzi5 ай бұрын

    Can this handle anything using more advanced features than simple non-generic function with only primitive types as parameters and return values?

  • @pierrehebert9743

    @pierrehebert9743

    5 ай бұрын

    You'd have to instantiate the templates/macros in all 3 languages. It's doable, but hard as you have to know in advance which instances you need.

  • @gavintantleff

    @gavintantleff

    5 ай бұрын

    Member functions

  • @annoorange123
    @annoorange1235 ай бұрын

    Dee Snuts (creator of D lang) would be proud of this guy

  • @JosephOzielComposer
    @JosephOzielComposer9 күн бұрын

    Finally dlang mention

  • @Chaunton
    @Chaunton5 ай бұрын

    We need a v lang wrapper for the d code.

  • @mikkisauza
    @mikkisauza5 ай бұрын

    i wonder if the jaw moves were coded

  • @Kane0123
    @Kane01235 ай бұрын

    Does adding D to C++ equals C#

  • @replikvltyoutube3727
    @replikvltyoutube37275 ай бұрын

    Add a bit of pascal in the stack

  • @electrolyteorb
    @electrolyteorb5 ай бұрын

    Flip'in awesome

  • @VivBrodock
    @VivBrodock2 ай бұрын

    funfact: Julia can use python, C, Java, and R libraries. so.... a natural next addition to Polyglot? >:3

  • @vicca4671
    @vicca46715 ай бұрын

    This guy really sold us on the massive D glue.

  • @diegolikescode
    @diegolikescode5 ай бұрын

    This edit 👌👌👌👌👌👌

  • @skeleton_craftGaming
    @skeleton_craftGaming5 ай бұрын

    [c++] feature compatibility is not that much of a meme... CL implement a good 80% of C++ 20, [including importing modules ] and I'm good like 30% of C++ 23 There is no reason any new projects written in C++, on Windows at least, and should not be using C++ 20 features..

  • @jenwans3055
    @jenwans30555 ай бұрын

    C++ + Rust + Deezznut?

  • @orobiodecastro
    @orobiodecastro5 ай бұрын

    You should have a look at Swift’s C and C++ interop, which is done by making the Swift compiler cooperate with Clang. This makes using multiple languages in a project very easy and enables things like inlining functions from one language in another. The following video gives a nice overview: kzread.info/dash/bejne/jIWXm4-slbiTZc4.htmlsi=q9uyDBmzYp9JwVrA

  • @MattDog_222
    @MattDog_2225 ай бұрын

    the real C-RUSTacean

  • @julstr6303
    @julstr63035 ай бұрын

    Complains about the "crazy toolchain" but works on projects in some javascript framework that adds its own syntay on top of typescript and "compiles" to javascript in order to run on a browsers vm to show some catpictures to your grandma 😂

  • @triplebog
    @triplebog5 ай бұрын

    Did he ever read part 2 or did he adhd past that at the end and forget

  • @paherbst524
    @paherbst5245 ай бұрын

    I mix c,c++,and ada all the time.

  • @progste
    @progste5 ай бұрын

    Of course, the solution was D all along!

  • @bsdooby
    @bsdooby5 ай бұрын

    What's not to like about D? Does @ThePrimeTime hate D? For what reason?

  • @user-qr4jf4tv2x
    @user-qr4jf4tv2x5 ай бұрын

    damn i just did extern

  • @TacticalPew
    @TacticalPew5 ай бұрын

    I like this VTuber arc 4:36

  • @JC-wj5ks
    @JC-wj5ks5 ай бұрын

    Missing HTMX there

  • @Iswimandrun
    @Iswimandrun5 ай бұрын

    lua and c interop. C# and JavaScript interop in blazor webassembly PWA.

  • @elieobeid77
    @elieobeid775 ай бұрын

    I was focusing on the lip sync and not on the content of the video.

  • @redcrafterlppa303
    @redcrafterlppa3035 ай бұрын

    I don't think we need to abuse d for that. Based on this idea, it should be possible to write a "object file aligner" that unifies all differently mangled labels to 1 uniform style. Unifying equal signatures from different languages.

  • @user-py9cy1sy9u

    @user-py9cy1sy9u

    5 ай бұрын

    oh we definitely need to abuse d.

  • @robinpage2730

    @robinpage2730

    5 ай бұрын

    The compiler could implement a library to do that unification, aligning everything to whatever the convention is for the language in which the main() function is written: if it's in C++, then that convention is used, but if it's in Rust, then Rust's convention is used.

  • @pup4301
    @pup43015 ай бұрын

    I made rust oob. You just have to use traits in illegal ways. All safe though.

  • @rupen42
    @rupen425 ай бұрын

    Add U and you got a modern webapp.

  • @xTriplexS
    @xTriplexS5 ай бұрын

    That made my C++ hard

  • @erictrinque6513
    @erictrinque65135 ай бұрын

    polyglot shoulda been SEMentD

  • @71GA
    @71GA5 ай бұрын

    Damn, why doesn't D become part of Linux kernel...

  • @ContagiousIP
    @ContagiousIP5 ай бұрын

    I’m new here, why is everyone mentioning lipsync and his editor? I noticed some lag but other than that, am I missing the joke?

  • @user-py9cy1sy9u

    @user-py9cy1sy9u

    5 ай бұрын

    good one

  • @SeRoShadow

    @SeRoShadow

    5 ай бұрын

    Prime talking about his camera 3:47. Foreshadowing 4:20.

  • @SRG-Learn-Code
    @SRG-Learn-Code5 ай бұрын

    Oh, so he is canadian.

  • @electroflame6188
    @electroflame61885 ай бұрын

    crust

  • @shapelessed
    @shapelessed5 ай бұрын

    You know what I did for fun? I wrote a filesystem. In JavaScript. With native AES/XTS encryption support. And surprisingly enough, about 20Gb/s sequential write speeds. Why? Because now I can brag and poison the minds of anti-javascript evangelists with my heresy.

  • @bigfishoutofwater3135
    @bigfishoutofwater31355 ай бұрын

    Could you just target WASM with each language?

  • @guillaumepiolat8578
    @guillaumepiolat85785 ай бұрын

    RIID

  • @adamodimattia
    @adamodimattia5 ай бұрын

    The longer I program in C++ the more I am convinced it is one of the ugliest languages I've come across and with the most inconsistent syntax. And Rust is among the most beautiful.

  • @robinpage2730

    @robinpage2730

    5 ай бұрын

    Ban all programming languages. Everything should be coded in assembly for minimum compile time, file size, and maximum running program speed and programmer torment.

  • @pif5023
    @pif50235 ай бұрын

    Otagle

  • @Aaron31056
    @Aaron310565 ай бұрын

    Deez

  • @jamesc2810
    @jamesc28105 ай бұрын

    That prime key framed mouth is distracting

  • @sciencedude22
    @sciencedude225 ай бұрын

    D propaganda

  • @AloisMahdal
    @AloisMahdal5 ай бұрын

    THIRD

  • @semyaza555

    @semyaza555

    5 ай бұрын

    F O U R T H

  • @kibels894
    @kibels8945 ай бұрын

    Why would you want to interop with C++? Rust is just a better C++. That's why they didn't bother with interop with anything except C.

  • @vercolit

    @vercolit

    5 ай бұрын

    Because C++ is one of the most used languages in the world. Rust is better in many ways, but thinking it will replace C++ is delusional

  • @redcrafterlppa303

    @redcrafterlppa303

    5 ай бұрын

    ​@@vercolit we will see how that statement ages. However I agree that there is a lot of code written in c++ today and that code won't vanish overnight. Meaning that there is a need to interact with this code even in case rust replaces c++. The current status quo that everything interops over c is not ideal as shown in the article.

  • @Prinsdam

    @Prinsdam

    5 ай бұрын

    We have something like 50 years' worth of extant C++ code that's still useful. And if you're a plugin developer for any graphics app (Adobe, Autodesk, Rhino, everything), the SDKs are all C++ and won't ever be rewritten. This interop is DESPERATELY needed.

  • @isodoubIet

    @isodoubIet

    5 ай бұрын

    Rust can't be a "better C++" until it adds inheritance, proper generics (including variadics), function overloading, default parameters, and exceptions, to name only a few.

  • @isodoubIet

    @isodoubIet

    5 ай бұрын

    @@redcrafterlppa303 " The current status quo that everything interops over c is not ideal as shown in the article." The status quo is that for a very good reason: the semantic ideas the various different languages add on top of C are generally incompatible. Doesn't Rust, for instance, feel free to move memory around unless you explicitly pin it? Trying to interop between two disparate languages without making sure they talk in the absolute lowest possible denominator is a recipe for disaster.