I love the pros and cons. Now I know that if I might want to reduce executer size I might turn inline functions back to regular ones.
@MikeShah9 ай бұрын
Cheers! Generally inlining is good for performance with the right functions, but always with tradeoffs 🙂
@mytech677925 күн бұрын
I can see inline being a performance loss in some corner cases due to the effect on the L1i cache if a function is called several times in close proximity and after branching (in both branches) a function could stay in cache while many inlined copies would be constantly loaded and evicted. This would certainly be very dependent on the specific code with specific hardware and need testing due to all of the unknowns.
@MikeShah25 күн бұрын
Indeed, inlining can make code size large and potentially blowup the instruction cache. That said, inlining may enable other optimizations -- very much depends on code, but usually a win.
@mytech677924 күн бұрын
@@MikeShah On some further research "cache thrashing" seems to be the term that describes what I was trying to get at. And thrashing can also be an issue on the data side with certain access patterns.
@MikeShah24 күн бұрын
@mytech6779 yup absolutely!
@sachinjain6429 Жыл бұрын
sir , i think you are underrated , and the quality of your content his highly professional and to the point , thank you for such nice explanations
@MikeShah Жыл бұрын
Cheers, thank you for the kind words! Feel free to spread the word :)
@CPP_malloc Жыл бұрын
inline in C++ works differently to C language inline specifier in C means to the compiler "inline this function when it is possible to do that". but in inline in C++ language means to the compiler "don't complain about two declarations of a function "or variable in C++17" in two different translation units, and only choose one address of one function to be exposed in the external in linkage table". and the meaning of "C inline" in C++ is only left to the optimization of the compiler, if you used -O3 optimization level you will get it inlined. Or by using some attributes to force the compiler to inline it, but it isn't C++ standard it is only a feature in gcc, as __forceinline is an attribute in MSVC for the same purpose.
@MikeShah Жыл бұрын
I'm going to cover inline variables (I believe introduced in c++17) shortly which covers some of the linkage issues you discussed :)
@CPP_malloc Жыл бұрын
@@MikeShah exactly, your videos are awesome and prepared to be simple to the viewer I like watching them in case there is something I don't know. Btw in your next video you can cover two topics "template variables in C++14" and "inline variables in C++17" Because it isn't much to put them both in the same video length. I wish you good luck and all the best Mike Shah.
@MikeShah Жыл бұрын
@@CPP_malloc Cheers, thank you for the kind words! Will consider your suggestion!
@mdatab Жыл бұрын
I very much appreciate your videos about C++. Thank you very much for providing such helpful content. Perhaps you could occasionally make another video (or even a series) about your vim setup that includes tips on configuring vim for C++?
@MikeShah Жыл бұрын
Cheeres, thank you Martin! I use a relatively vanilla VIM, but I'll add that to the video wishlist :)
@MartinCordova Жыл бұрын
A clear explanation, and again, having the chance to view the things happening in assembly language is a big plus, great content all of yours. I now use constexpr for all my functions with GCC-13 and -std=c++23, even for lambdas, it does the inlining plus the compile-time (if possible). Mike, are you available (I mean consulting services) for code reviews? I would like to have a quotation for a specific case in one of my open-source projects
@MikeShah Жыл бұрын
Cheers! Feel free to send me an e-mail regarding opportunities -- on occassion I have time for consulting work.
@mister-ace10 ай бұрын
Hi, what resources I can read to understand that assembly code on the right? Thank you.
@MikeShah10 ай бұрын
I have a few assembly videos, otherwise some combination of courses, and writing very small programs can help understand assembly (e.g. start with an assignment statement, a loop, etc.)
@saifsuleiman1171 Жыл бұрын
Hi Mike, thanks for this great c++ series, looking forward for more content. In the mean time I will start watching your other series, currently I am interested in "C++ Software Design and Design Patterns", "Modern C++ (cpp) Concurrency", "Introduction to OpenGL", "SDL2 Simple Directmedia Layer" and "SFML - Simple Fast Media Library"
@MikeShah Жыл бұрын
Cheers, thank you for the kind words! More C++ coming, a few more design patterns videos first :)
@monty6393 Жыл бұрын
Wooohooo... Compiler Explorer always makes me feel good .. I already knew about inline function `hint` to the compiler but what was the key takeaway for me was the attribute always inline that was something new... Thanks for the video... What's your plan for this year in this channel? Have you given a thought on Doing something in Rust?
@MikeShah Жыл бұрын
Cheers! Yes, very cool! As for the channel, I have a backlog of at least 100 videos to film. :) At some point I need to learn some more Rust, perhaps a longer form introduction would be something I put together. That said, tons of DLang, C, C++, SDL2, and OpenGL videos queued up and ready to be produced :)
@monty6393 Жыл бұрын
@@MikeShah okay Professor .. Btw these days I am thinking of doing some good project in c/ c++ would you suggest me something ?
@MikeShah Жыл бұрын
@@monty6393 I like doing small games (breakout, tetris, etc.) or text editors. I think Austin Henley has a good blog on projects, and at some point I'll do a video on this topic :)
@monty6393 Жыл бұрын
@@MikeShah Thanks for the suggestion professor
@dogdog5994 Жыл бұрын
I suggest a video in the C language series about C11 threads, the POSIX pthread library and c11 threads vs POSIX pthread.
@MikeShah Жыл бұрын
Good idea :) At the least I will cover pthreads and locks a bit in the C series
@CorpoWolf7 ай бұрын
Isn't this what the pre-compiler and macro's are for? I feel pain for knowing what inline is now.
@MikeShah7 ай бұрын
Similar idea to a macro -- macros are merely textual replacements. The 'inline' keywords still performs various type checking prior to code optimization. Also, it's not necessarily guaranteed an inline function will be inline -- it's just a request.
@VoidloniXaarii Жыл бұрын
So love all your cpp vidz
@MikeShah10 ай бұрын
Cheers!
@VoidloniXaarii10 ай бұрын
@@MikeShah干杯
@_w62_ Жыл бұрын
Would you consdier making a series on something say, "the internal workings of C++ with the compiler explorer/objdump"? Explaining to us the internal workings of the C++ langauge? If basic asm is needed, I can learn that.
@MikeShah Жыл бұрын
Thanks for the suggestion -- I may give a talk on compiling/linking in the future on this. Will keep this as a note for the future.
@mirzakadic9174 Жыл бұрын
This video earned you a subscriber :)
@MikeShah Жыл бұрын
Cheers! Welcome!
@abhishek_karki Жыл бұрын
Do you also have Linux system programming using C++ in your pipeline for this year?
@Southpaw101 Жыл бұрын
That will be tremendously useful if MikeS can accommodate that.
@MikeShah Жыл бұрын
@@Southpaw101 Will note this as a suggestion in the C++ playlist.