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

  Переглядів 53,954

ThePrimeTime

ThePrimeTime

5 місяців тому

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

КОМЕНТАРІ: 169
@wahidislamlinad
@wahidislamlinad 4 місяці тому
the editor deserves a raise 🤞
@cmelgarejo
@cmelgarejo 4 місяці тому
Flip is the best
@NibbleMeTwice
@NibbleMeTwice 4 місяці тому
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 4 місяці тому
Yeah, both things are impressive in their various ways, lol.
@UQuark0
@UQuark0 4 місяці тому
My thoughts exactly
@karasick4214
@karasick4214 4 місяці тому
He has a Vtuber tag tho
@theseangle
@theseangle 4 місяці тому
C'mon this is a programming channel, you think the editor hasn't learned enough in his spare time to automate this task? 😆
@Spirrwell
@Spirrwell 4 місяці тому
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.
@KDABtv
@KDABtv 4 місяці тому
Hey, great you liked Loren's blog. Thanks for commenting on it on your channel!
@Bliss467
@Bliss467 4 місяці тому
Prime is so great at reading aloud and internalizing simultaneously.
@LorenDB
@LorenDB 4 місяці тому
Hi, author of the blog post here! Very exciting to see that my crazy ideas are well received:)
@thedeemon
@thedeemon 4 місяці тому
who needs C++ and Rust when you can program in D!
@GeorgijTovarsen
@GeorgijTovarsen 4 місяці тому
D glue? Nobody wants to touch that
@ThePrimeTimeagen
@ThePrimeTimeagen 4 місяці тому
Ain't no way
@bsdooby
@bsdooby 4 місяці тому
Why not?
@atiedebee1020
@atiedebee1020 4 місяці тому
The order of fields in C structs is absolutely guaranteed
@omri9325
@omri9325 4 місяці тому
Sounds crazy to hint it's not
@Ellefsen97
@Ellefsen97 4 місяці тому
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 4 місяці тому
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?
4 місяці тому
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 4 місяці тому
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 4 місяці тому
@@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 4 місяці тому
@@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.
@krtirtho
@krtirtho 4 місяці тому
D does a really good job at glueing stuff together hehe
@pbentesio
@pbentesio 4 місяці тому
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.
@dexterman6361
@dexterman6361 4 місяці тому
The camera could be an overheating or buffering issue. Also amazing editor * chefs kiss * perfect cut/edit deserves a raise!
@abc123evoturbobonker
@abc123evoturbobonker 4 місяці тому
Prime looks unusually good in this new video 😄
@The1RandomFool
@The1RandomFool 4 місяці тому
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++.
@michaelreese401
@michaelreese401 4 місяці тому
D seems to be good at combining other languages. It can also be used to automatically generate python bindings for C-libraries.
@TJackson736
@TJackson736 4 місяці тому
That's sweet and I will have to keep that in mind for my company.
@michaelreese401
@michaelreese401 4 місяці тому
@@TJackson736 details are in an article "calling c from python" in the blog "atila on code"
@skilz8098
@skilz8098 4 місяці тому
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.
@varjotin
@varjotin 4 місяці тому
The lip sync is anazing😮
@re_detach
@re_detach 4 місяці тому
I hope Prime looks the same for next stream lowkey
@petyabubkin2800
@petyabubkin2800 4 місяці тому
It works on audio input. Easy task for streaming or editing software.
@lukegary4482
@lukegary4482 4 місяці тому
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.
@psybertao
@psybertao 4 місяці тому
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 4 місяці тому
Probably because there is a lot of exciting C++ code out there…
@floppa9415
@floppa9415 4 місяці тому
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 4 місяці тому
@@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.
@alexpyattaev
@alexpyattaev 4 місяці тому
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 4 місяці тому
Its not that it's inefficient its just that the responsibility of creating an efficient layout is on the programmer
@alexpyattaev
@alexpyattaev 4 місяці тому
@@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 4 місяці тому
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 4 місяці тому
I always make sure to properly align the struct if i need it packed so it's not up to the compiler.
@indiesigi7807
@indiesigi7807 4 місяці тому
@@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.
@dhay3982
@dhay3982 4 місяці тому
The next step would be cutting the "middle D" and implement the Extern(C++) functionality directly into the rust compiler.
@ZILtoid1991
@ZILtoid1991 4 місяці тому
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 3 місяці тому
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
@GreatWalker
@GreatWalker 4 місяці тому
ThePrimeagen might be my favourite PNGtuber
@georgehelyar
@georgehelyar 4 місяці тому
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 4 місяці тому
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 4 місяці тому
@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.
@JohnneyleeRollins
@JohnneyleeRollins 4 місяці тому
Throw wren in there and you got yourself a CD-RW
@Qaos2
@Qaos2 4 місяці тому
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 4 місяці тому
Wow how did you find the channel then?
@VivekYadav-ds8oz
@VivekYadav-ds8oz 4 місяці тому
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 4 місяці тому
@@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!
@markdanielesplanaperilla
@markdanielesplanaperilla 4 місяці тому
Watching Prime at that state gave me nightmares.
@dekrain
@dekrain 3 місяці тому
I just wanted to say that Rust *does* indeed allow you to set the mangled name of a function/static via. #[export_name = "..."] attribute 🙂
@ivanjermakov
@ivanjermakov 4 місяці тому
Did the editor manually set keyframes for Prime's mouth, or automated it based on mic audio amplitude?
@marcs9451
@marcs9451 4 місяці тому
automated (hopefully)
@floppa9415
@floppa9415 4 місяці тому
Gives me "trying to use every JVM Language in a project vibes".
@SimGunther
@SimGunther 4 місяці тому
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!
@kuhluhOG
@kuhluhOG 4 місяці тому
15:25 Since "and" is in German "und", "C++, Rust und D" actually makes even more sense, lol.
@pxolqopt3597
@pxolqopt3597 4 місяці тому
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
@blenderpanzi
@blenderpanzi 4 місяці тому
Can this handle anything using more advanced features than simple non-generic function with only primitive types as parameters and return values?
@pierrehebert9743
@pierrehebert9743 4 місяці тому
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 4 місяці тому
Member functions
@user-qr4jf4tv2x
@user-qr4jf4tv2x 4 місяці тому
i like the new prime he looks so calm
@mikkisauza
@mikkisauza 4 місяці тому
i wonder if the jaw moves were coded
@Kane0123
@Kane0123 4 місяці тому
Does adding D to C++ equals C#
@Chaunton
@Chaunton 4 місяці тому
We need a v lang wrapper for the d code.
@diegolikescode
@diegolikescode 4 місяці тому
This edit 👌👌👌👌👌👌
@replikvltyoutube3727
@replikvltyoutube3727 4 місяці тому
Add a bit of pascal in the stack
@annoorange123
@annoorange123 4 місяці тому
Dee Snuts (creator of D lang) would be proud of this guy
@electrolyteorb
@electrolyteorb 4 місяці тому
Flip'in awesome
@MattDog_222
@MattDog_222 4 місяці тому
the real C-RUSTacean
@user-tb5re6zs2r
@user-tb5re6zs2r 4 місяці тому
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 4 місяці тому
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
@josefaguilar2955 4 місяці тому
That's a little CRustD
@jenwans3055
@jenwans3055 4 місяці тому
C++ + Rust + Deezznut?
@vicca4671
@vicca4671 4 місяці тому
This guy really sold us on the massive D glue.
@orobiodecastro
@orobiodecastro 4 місяці тому
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: ukposts.info/have/v-deo/koGUbWOqnItelp8.htmlsi=q9uyDBmzYp9JwVrA
@bsdooby
@bsdooby 4 місяці тому
What's not to like about D? Does @ThePrimeTime hate D? For what reason?
@triplebog
@triplebog 4 місяці тому
Did he ever read part 2 or did he adhd past that at the end and forget
@VivBrodock
@VivBrodock Місяць тому
funfact: Julia can use python, C, Java, and R libraries. so.... a natural next addition to Polyglot? >:3
@julstr6303
@julstr6303 4 місяці тому
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 😂
@user-qr4jf4tv2x
@user-qr4jf4tv2x 4 місяці тому
damn i just did extern
@paherbst524
@paherbst524 4 місяці тому
I mix c,c++,and ada all the time.
@progste
@progste 4 місяці тому
Of course, the solution was D all along!
@skeleton_craftGaming
@skeleton_craftGaming 4 місяці тому
[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..
@JC-wj5ks
@JC-wj5ks 4 місяці тому
Missing HTMX there
@ContagiousIP
@ContagiousIP 4 місяці тому
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 4 місяці тому
good one
@SeRoShadow
@SeRoShadow 4 місяці тому
Prime talking about his camera 3:47. Foreshadowing 4:20.
@Iswimandrun
@Iswimandrun 4 місяці тому
lua and c interop. C# and JavaScript interop in blazor webassembly PWA.
@TacticalPew
@TacticalPew 4 місяці тому
I like this VTuber arc 4:36
@rupen42
@rupen42 4 місяці тому
Add U and you got a modern webapp.
@erictrinque6513
@erictrinque6513 4 місяці тому
polyglot shoulda been SEMentD
@71GA
@71GA 4 місяці тому
Damn, why doesn't D become part of Linux kernel...
@electroflame6188
@electroflame6188 4 місяці тому
crust
@elieobeid77
@elieobeid77 4 місяці тому
I was focusing on the lip sync and not on the content of the video.
@pup4301
@pup4301 4 місяці тому
I made rust oob. You just have to use traits in illegal ways. All safe though.
@redcrafterlppa303
@redcrafterlppa303 4 місяці тому
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 4 місяці тому
oh we definitely need to abuse d.
@robinpage2730
@robinpage2730 4 місяці тому
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.
@SRG-Learn-Code
@SRG-Learn-Code 4 місяці тому
Oh, so he is canadian.
@guillaumepiolat8578
@guillaumepiolat8578 4 місяці тому
RIID
@xTriplexS
@xTriplexS 4 місяці тому
That made my C++ hard
@bigfishoutofwater3135
@bigfishoutofwater3135 4 місяці тому
Could you just target WASM with each language?
@pif5023
@pif5023 4 місяці тому
Otagle
@shapelessed
@shapelessed 4 місяці тому
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.
@Aaron31056
@Aaron31056 5 місяців тому
Deez
@jamesc2810
@jamesc2810 4 місяці тому
That prime key framed mouth is distracting
@sciencedude22
@sciencedude22 4 місяці тому
D propaganda
@AloisMahdal
@AloisMahdal 5 місяців тому
THIRD
@semyaza555
@semyaza555 5 місяців тому
F O U R T H
@adamodimattia
@adamodimattia 4 місяці тому
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 4 місяці тому
Ban all programming languages. Everything should be coded in assembly for minimum compile time, file size, and maximum running program speed and programmer torment.
@kibels894
@kibels894 4 місяці тому
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 4 місяці тому
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 4 місяці тому
​@@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 4 місяці тому
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 4 місяці тому
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 4 місяці тому
@@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.
Async Rust Is A Bad Language | Prime Reacts
28:46
ThePrimeTime
Переглядів 82 тис.
The Most Amazing Software Ever Created
20:02
ThePrimeTime
Переглядів 269 тис.
How did CatNap end up in Luca cartoon?🙀
00:16
LOL
Переглядів 6 млн
Новая технология! РАССЫПНОЙ ПОДШИПНИК
00:35
ПЕЙ МОЛОКО КАК ФОКУСНИК
00:37
Masomka
Переглядів 2,9 млн
0 Days Since Rust Drama
26:03
ThePrimeTime
Переглядів 75 тис.
Programming War Crimes | Prime Reacts
10:36
ThePrimeTime
Переглядів 312 тис.
Prime React: Fast Inverse Square Root - A Quake III Algorithm
30:19
ThePrimeTime
Переглядів 135 тис.
XML Is The Future
18:39
ThePrimeTime
Переглядів 176 тис.
Why i think C++ is better than rust
32:48
ThePrimeTime
Переглядів 259 тис.
why do they do this every time?
33:33
ThePrimeTime
Переглядів 61 тис.
Stop Using Rust Use C++ | Prime Reacts
13:55
ThePrimeTime
Переглядів 256 тис.
Rust is Not C
16:24
ThePrimeTime
Переглядів 188 тис.
Python Sucks And I LOVE It | Prime Reacts
15:43
ThePrimeTime
Переглядів 236 тис.
Programming an entire game from scratch | Prime Reacts
15:31
ThePrimeTime
Переглядів 190 тис.
Як знімати з музикою на iPhone #apple #icoola #айфон #айкула #tradein #відновлений #iphone #ремонт
0:18
Распаковал Xiaomi SU7
0:59
Wylsacom
Переглядів 2,7 млн
Какой телефон лучше всего снимает? 🤯
0:42
Рекламная уловка Apple 😏
0:59
Яблык
Переглядів 799 тис.
The power button can never be pressed!!
0:57
Maker Y
Переглядів 39 млн
How much charging is in your phone right now? 📱➡️ 🔋VS 🪫
0:11