- 16
- 264 622
ABMedia
United Kingdom
Приєднався 15 кві 2018
Welcome to ABMedia! The home of many programming-related tutorials, ABCo updates, and various other content.
Every video is scripted, recorded and edited with carefully crafted explanations, visual animations and graphics, and some good programming fun.
Some videos cover low-level topics that are covered almost nowhere else on UA-cam, some videos cover high-level topics, and some videos are just about ABCo and new program updates.
I make these videos because it's fun, and I hope you have fun watching and learning from them too.
Every video is scripted, recorded and edited with carefully crafted explanations, visual animations and graphics, and some good programming fun.
Some videos cover low-level topics that are covered almost nowhere else on UA-cam, some videos cover high-level topics, and some videos are just about ABCo and new program updates.
I make these videos because it's fun, and I hope you have fun watching and learning from them too.
Inside C#: Stack & Heap, Value Types, Boxing, stackalloc + More
C#, as a language, is all about flexibility. Sure, the ability to rapidly prototype and deliver on code quickly, without worrying about safe memory management or performance, is one of its greatest strengths. But when the moment comes that you need ultra-efficient, C++-comparable code for a task, the tools are all there for you to pull out and leverage, and this video is the first step in doing just that!
I feel there's a bit of a gap in those who understand the memory layout and implications of their C# code and those who don't, and wanted to try to fill that gap a little.
SUMMARY:
The video starts by looking at the stack and the heap, the two core regions of memory in .NET. It glosses over the LoaderAllocator and Native Heaps too as options.
For the stack, the characteristics are first explained; the fact that you can push and pop to it like a regular stack, but get/set middle items. Then I go through how this actually maps to methods and locals, with calling and returning from functions. I cover some of the special features of the stack, such as being used for return addresses and parameters (I probably should've mentioned the rbx register here, but you live and learn). For the heap, I explain how closely the heap's implementation is tied to the GC (Garbage Collector), the reason and function of the garbage collector, and how classes and other reference types go onto there. I use GCHeap::Alloc as an example of the GC being tied to the heap, which you can find in this file: github.com/dotnet/runtime/blob/main/src/coreclr/gc/gc.cpp
Now I move onto value types and reference types, the very tools that allow you to select your memory layout. I start by explaining reference types' function, as they're the most common and strangest one of the two, and putting value types after allows me to contrast the difference between the two greater. With reference types, the behaviour of placing 4-8 byte reference at the position they're passed and allocating contents to new locations on the heap is brought up, as well as the noticeable impacts this whole reference ideas has on code. After this, I talk about the object headers that come on reference types and their impact. With value types, the behaviour of storing inline and not containing a header is my main focus, as well as the lack of inheritance on them.
Next up is an analysis of the performance impact value types can hold compared to reference types. I discuss the importance of using BenchmarkDotNet for benchmarks, then proceed to do so for an array of a million struct and class items. After showing this, I explain the impact of allocations, garbage collection, dereferencing (and the indirections thereof), and object headers/method tables.
Once showing the massive performance flaws reference types have, I explain why reference types are used at all. This is done by highlighting the flaws in doing everything with value types. Some flaws I highlight are the constant data copying at every pass from variable to variable, the lack of heap access with value types alone, as well as the complete lack of support for inheritance or threading on value types.
Along the way, I also get a chance to talk about null. The fact that reference types support null because the meaning of the value is a reference of 0, and the fact that value types can be opted into null using Nullable T (to attach a boolean to the struct to allow the state to be represented). I also take the chance to mention not to worry about nullable reference types for memory changes, and only see them as a cosmetic feature.
Finally, the video is closed out with an explanation of boxing (to explain the ability to place structs into interface, object or ValueType types of variables) and the stackalloc keyword to create arrays on the stack.
CHAPTERS:
00:00 Memory Regions
03:00 The Stack
08:15 The Heap
10:25 Data Types
12:00 Reference Types
18:10 Value Types
19:55 Inheritance In Memory
21:05 Performance
27:52 Why Reference Types?
33:05 Nullability In Memory
34:30 Common Uses for Value Types
36:50 Boxing
39:55 stackalloc
CREDITS:
Script, Recording & Editing: Alex Burrows
Desktop Background: @ndumiphotos (Instagram)
GC Internals Images: Pulled from dotnetos goodies.dotnetos.org/
MORE INFO:
Thanks for watching my video, before are some general ABMedia links if you are interested:
Website ► abco.live/
Discord ► abco.live/discord
A huge thank you goes to @ndumiphotos (on Instagram) for the graphics used in the intro.
#csharp #dotnet #span
I feel there's a bit of a gap in those who understand the memory layout and implications of their C# code and those who don't, and wanted to try to fill that gap a little.
SUMMARY:
The video starts by looking at the stack and the heap, the two core regions of memory in .NET. It glosses over the LoaderAllocator and Native Heaps too as options.
For the stack, the characteristics are first explained; the fact that you can push and pop to it like a regular stack, but get/set middle items. Then I go through how this actually maps to methods and locals, with calling and returning from functions. I cover some of the special features of the stack, such as being used for return addresses and parameters (I probably should've mentioned the rbx register here, but you live and learn). For the heap, I explain how closely the heap's implementation is tied to the GC (Garbage Collector), the reason and function of the garbage collector, and how classes and other reference types go onto there. I use GCHeap::Alloc as an example of the GC being tied to the heap, which you can find in this file: github.com/dotnet/runtime/blob/main/src/coreclr/gc/gc.cpp
Now I move onto value types and reference types, the very tools that allow you to select your memory layout. I start by explaining reference types' function, as they're the most common and strangest one of the two, and putting value types after allows me to contrast the difference between the two greater. With reference types, the behaviour of placing 4-8 byte reference at the position they're passed and allocating contents to new locations on the heap is brought up, as well as the noticeable impacts this whole reference ideas has on code. After this, I talk about the object headers that come on reference types and their impact. With value types, the behaviour of storing inline and not containing a header is my main focus, as well as the lack of inheritance on them.
Next up is an analysis of the performance impact value types can hold compared to reference types. I discuss the importance of using BenchmarkDotNet for benchmarks, then proceed to do so for an array of a million struct and class items. After showing this, I explain the impact of allocations, garbage collection, dereferencing (and the indirections thereof), and object headers/method tables.
Once showing the massive performance flaws reference types have, I explain why reference types are used at all. This is done by highlighting the flaws in doing everything with value types. Some flaws I highlight are the constant data copying at every pass from variable to variable, the lack of heap access with value types alone, as well as the complete lack of support for inheritance or threading on value types.
Along the way, I also get a chance to talk about null. The fact that reference types support null because the meaning of the value is a reference of 0, and the fact that value types can be opted into null using Nullable T (to attach a boolean to the struct to allow the state to be represented). I also take the chance to mention not to worry about nullable reference types for memory changes, and only see them as a cosmetic feature.
Finally, the video is closed out with an explanation of boxing (to explain the ability to place structs into interface, object or ValueType types of variables) and the stackalloc keyword to create arrays on the stack.
CHAPTERS:
00:00 Memory Regions
03:00 The Stack
08:15 The Heap
10:25 Data Types
12:00 Reference Types
18:10 Value Types
19:55 Inheritance In Memory
21:05 Performance
27:52 Why Reference Types?
33:05 Nullability In Memory
34:30 Common Uses for Value Types
36:50 Boxing
39:55 stackalloc
CREDITS:
Script, Recording & Editing: Alex Burrows
Desktop Background: @ndumiphotos (Instagram)
GC Internals Images: Pulled from dotnetos goodies.dotnetos.org/
MORE INFO:
Thanks for watching my video, before are some general ABMedia links if you are interested:
Website ► abco.live/
Discord ► abco.live/discord
A huge thank you goes to @ndumiphotos (on Instagram) for the graphics used in the intro.
#csharp #dotnet #span
Переглядів: 1 181
Відео
Learn PowerShell: Episode 11 FINALE, Parametered Scripts + Scoping + Modules
Переглядів 3,7 тис.Рік тому
After 2 years of making PowerShell videos, we have finally come to the very last episode! In this episode, I cover the final topics I wanted to get through in the series *and* follow that with where to go in the future of this series. PowerShell Discord server (for questions) ► discord.gg/powershell Official PowerShell Documentation ► learn.microsoft.com/en-us/powershell/scripting/overview PSKo...
Learn PowerShell: Episode 10, Counting + Loop Control + Functions
Переглядів 4 тис.2 роки тому
Welcome to the tenth episode of the PowerShell tutorial series! This is the series' second-to-last episode, and it's been a long time coming, but here we are! In this episode, I cover how to count from one number to another with loops, the special keywords PowerShell provides to let you control loops from within them, and functions! There are many ways of counting from one number to another, al...
Learn PowerShell: Episode 9, Debugging + Select + Looping
Переглядів 7 тис.3 роки тому
In this 40-minute long episode, we're going to continue our exploration through PowerShell. This episode has a lot more practical stuff in it, getting the experience of putting together scripts for PowerShell! And we also pray to our lord and saviour, "johm" ;) This episode starts with debugging, as well as some recap on "if" statements from the last episode, which is quite a new tool we haven'...
Learn PowerShell: Episode 8, Operators + If Statements + Scripting Tips
Переглядів 7 тис.3 роки тому
Welcome to the eighth episode in the long-running PowerShell video series. This is nearing the very last episode now, and the bonus episode where we're going to make an entire graphical app. All Operators ► docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.1 All Wildcards ► docs.microsoft.com/en-us/powershell/module/microsoft.powershell...
Learn PowerShell: Episode 7, Scripting + HashTables + Static
Переглядів 9 тис.3 роки тому
This is the seventh episode in the PowerShell video series, where at the end we make an entire graphical app! This episode focuses on two things: Firstly, filling in quite a few gaps we've left throughout the series, and secondly, we're finally going to make our first PowerShell script! Scripting is an extremely important part of PowerShell, and perhaps one of the most useful tools for any comm...
Learn PowerShell: Episode 6, Primitives + Important Types + new
Переглядів 9 тис.3 роки тому
We're nearing the end of the PowerShell video series now! In this episode, we're going to take a look at some very important types, as well as very fundamental and special types known as "primitives". The primitives are types treated specially by the "CLR" (Core Language Runtime), as explored in the video, and are the fundamental building blocks every other object is then made out from. There a...
Learn PowerShell: Episode 5, Parameters + C# Descriptions + Overloads
Переглядів 11 тис.3 роки тому
We're getting to the final episode of the series where we make an entire graphical app with buttons and everything right from PowerShell! This video is essentially part 2 of the last one and we’re getting closer and closer to having really mastered the whole object system in PowerShell. Extra Task: I lied, there is no extra task! All the "physical stuff" of creating tools has been moved to the ...
Learn PowerShell: Episode 4, Types + Methods + Casting
Переглядів 17 тис.3 роки тому
As we know very well by now, objects are the most central part of PowerShell, everything is built around them, and as such, there's quite a bit to them! In this video we're going to take a deeper look at objects than we have before, digging into some more of the smaller parts (members) they're made up of and much more! Please note that I was a little sick while recording this so things definite...
Learn PowerShell: Episode 3, Variables + NoteProperties + CSV Files
Переглядів 23 тис.3 роки тому
In this video we take our knowledge of PowerShell even further, using "NoteProperty" to make custom properties, using "variables" to hold onto objects and read/writing to CSV files, and much more! All coming up, in this new episode of the beginners' PowerShell tutorial series. The CSV file I used ►abco.live/download/2021/students.csv The video starts with variables, a critical tool we can use t...
Learn PowerShell: Episode 2, Going Further
Переглядів 28 тис.3 роки тому
In this video, we're going to dig deeper into PowerShell and how to continue to take advantage of its capabilities. This video seamlessly flows on from the last to continue to enhance your knowledge in PowerShell and allow you to take advantage of it more. This video starts by explaining the unique file capabilities PowerShell has and the "PSDrive" system it uses to provide access to all files....
Learn PowerShell: Episode 1, The Basics
Переглядів 102 тис.3 роки тому
FUN FACT: By the end of this series, you'll be able to make your own graphical interface right from PowerShell! Download PowerShell ►github.com/powershell/powershell This is the start of a video series that will teach you everything you could need to know about PowerShell. This video will introduce the basics of PowerShell and the fundamental ideas it is built upon, as well as some important co...
ABMedia 2020 BLOOPERS
Переглядів 5874 роки тому
The second instalment of... Me messing up! There are two videos planned for 2021 Q1, hopefully, those will be done in that time. This video was a little more rushed than the previous bloopers video because I've been so busy lately and just don't have the time to dedicate to making videos. There are two videos planned for 2021 Q1 however. Website ► abco.live/ Discord ► abco.live/discord
Java for C# Developers
Переглядів 19 тис.4 роки тому
Java for C# Developers In this video, we're going to cover the differences between C# and Java. There aren't MANY differences between the two languages - in fact, one of the biggest differences is the installation process! However, there are certainly some differences. These differences include packages, types, enums, exceptions, inheritance and various other things. First, we'll cover how to i...
C++ for C# and Java Developers
Переглядів 24 тис.4 роки тому
This video will cover all of the difficult topics and differences between C and a managed language such as C# or Java. Things such as Pointers, Heap and Stack, Header Files and so much more! I made this video because as I got into C (coming from a C# background) a lot of these topics were really confusing to me and there weren't many great videos on the subject. I've designed this video to be e...