Wednesday, 23 October 2024

Building a modern campus

[MUSIC]

Building .NET MAUI Apps Faster with GitHub Copilot in Visual Studio 2022

as a.net Maui developer building mobile and desktop applications I'm often adding a lot of new features and at the same time I'm also diving into a lot of new code bases so I want to be able to iterate quickly on my applications but I also want to be able to jump into existing code bases and really understand what the code is doing and that's where GitHub co-pilot and GitHub copilot chat can be really exciting and awesome to use you can only add new features but also learn more about how the code works and then spice it up with some new functionality so let's take a look here I am inside of my application and I have a typical method here that says get monkeys async this is going to go off to the internet pull down the data and then deserialize it and return it into my list I can see here that it's not doing any checking at all to connect and look at the internet so let's maybe see if there's a way that GitHub co-pilot could help me create a method to check the internet uh before we make this call so I'm just going to write a little comment here that says method to check for internet connection and when I hit enter here it's going to give me a full completion recommendation that says connectivity.network access if it equals internet now this is really cool because GitHub copilot has the context of my code we can see that this is an eye connectivity instance a private uh property somewhere in my code let's take a look oh sure enough here it is this is being directly injected into my Constructor right here of icon activity so this is nice because like I said GitHub co-pilot knows about my code so it's using that automatically here well let's go ahead and actually use it so I can now come in and say Let's uh check for internet connection and display a pop-up alert uh if no internet exists in there now again GitHub uh copilot will check that brand new method that it calls that is connected property there and then it will go ahead and display an alert using shell because I'm using shell in my application insurance office says error no internet connection and returns automatically for me so that's really nice GitHub copilot not only knows the contacts but it's adding new methods it's helping me write better code and is using everything it knows about my application to make sure that code is really great now of course I can edit this add more contacts maybe add in some different translations as well if I have those in my application let's see what else GitHub copilot and GitHub copilot chat can do inside my application I'm going to take a look at the main page here and this is a fairly complex page it has a refreshed view it has a collection view it has different item templates and we can see here that there's a tap gesture recognizer inside of this Frame that will navigate to a new page now this is a pretty complex data binding there's a relative source with an ancestor type and has a path and if I'm brand new to xaml and mbvm this might look pretty complex to me especially if I'm coming into a project for the first time this is where GitHub co-pilot chat can really help me out here I'm just going to go ahead and say ask copilot I'm going to say uh what does this relative Source binding do and how does it work so again GitHub co-pilot chat is now going to kick in and this is really great it's giving me information not only on what a relative Source binding is but what the ancestor type is how it's going to go find the monkey's view model class and then in this case use the go to details command which is found in that view model so that's really nice and it asked me uh if I have any other follow-up questions here but I'm interested in this command parameter so let's continue the conversation so I'm going to say how does the command parameter work work here so again GitHub co-pilot chat is going to go off and analyze my code and this is really great it's going to say that this command parameter is bound to the dot which means it's going to pass in the current item context in this case a monkey inside of this tab gesture recognizer so that's really really great so if we take a look at the running application over here we can note that I have some monkeys in here we can see that that's how that data binding is working so that monkey in that class but we can see that um in this case the the labels are not necessarily aligned correctly so let's go ahead and tap on that and take a look here while we have this vertical stack layout and some labels in here and I might be wondering how could I maybe align that vertically in here again let me just go ahead and ask GitHub co-pilot how could I align the content of the vertical stack layout so they are centered all right again GitHub copilot chat over here is going to analyze this code and recommend some brand new code for me so it has the exact same code but it's it's adding this vertical Center and a line option so let's go ahead and just copy that so I could copy the whole thing I'm just going to add this in here there we go and now let's go ahead and see a look up and sure enough now our labels are vertically aligned so that's really great so it's giving me that context that understands it more so GitHub co-pilot not only giving me some great recommendations of learning about the code but also how to enhance the code well you know if I am coming in I'm adding new features to this app I might want to go ahead and create a new page to navigate to the details of those monkeys and again this is where GitHub co-pilot chat and GitHub copile can really help me out by creating and giving me some some sort of templates here for this type of page and even the code behind so let's go ahead and ask GitHub co-pilot chat I'll say how would I create a net Maui xaml page for the details of the monkey win selected all right so let's see what a GitHub co-pilot chat has to say here so again it's going to analyze uh the application and wow just like this it gives me a full reference here that is going to go ahead and give me context of my large labels my medium labels it's going to go ahead and bind here to the name image location automatically and even give me a go back command which is nice now I could take this I could copy this into a new page but I could also ask it what type of view model code could be generated for the code behind here so let's go ahead and ask it what would a view model code behind look like for this new page all right so now GitHub copilot is kind of using that reference there and here we go it is generated the monkey detail view model for me and it's passing in a monkey it has some information about getting that different detail information back for me and it's even generated a command a go back command to navigate backwards what I do like about this is that it's also implemented my base view model up here which is really really cool because it knows about the context of my code so if I look at this monkey's view model again the main one that I was working in we can also see that it has the base view model there too so that's really really nice now this is great because this is giving me some of that inside knowledge of what my code looks like and giving me a good starting place so I can take it put it into my code and then start from there to not only have a page but also the code behind for it as well well that's how easy it is to get started using GitHub copilot and GitHub copilot chat in your.net Maui applications today I hope that you really enjoyed this leave comments below if you have any questions at all thanks for watching

Build Unreal Engine Games In C++ Faster

ever wanted to write your own game and did you know that you could write it in visual studio with ease find out more on this episode of Visual Studio toolbox [Music] hello everyone and welcome to another episode of Visual Studio toolbox I'm your host Leslie Richardson and today I'm excited because we're gonna be talking about video games today so joining me is David Lee from the C plus team who's going to be sharing how we can all be more productive developing games in digital studio with C plus plus hey David hey Leslie how's it going I'm good how are you doing great I'm super excited to show everyone some of these Unreal Engine Integrations that we have been building in Visual Studio sweet so before we dive in would you care to tell us a little bit more about yourself and what you typically work on of course so um as you said before I am in the C plus plus team uh I am the game developer product manager in visual studio so everything from building games in Visual Studio to msvc compiler for all of you watching um just send me a tweet my my Twitter handle is there at the CBP PPM for any feedback so yeah awesome right so video games very popular Topic in the development world I know a lot of people initially started coding just because they wanted to write their own games and stuff so can you tell us a little bit more about um you know how developing video games can have its challenges and maybe what using visual studio and C plus can do to alleviate some of that yeah Leslie um I've chatted with quite a lot of game developers out there and really understand their needs so from in the developers to students to all of our first party game developers and you know as more I learned in our lessons a lot of pains have circuits from game development I think one of the biggest things that I've heard is the mental task switching a lot of developers out there when they work on a game whether it's using their proprietary engine or um or Unreal Engine sometimes they have to switch back and forth between visual studio and you know each time you open up the unreal editor switch back to visual studio and then close it that takes time and instead of having a smooth flowing um work then you're you give a lot of unnecessary mental energy by getting distracted and not be as productive so this is one of the few things that the team at C plus plus in Visual Studio has set out to tackle awesome yeah I I can relate I did write like one video game in college and specifically I was using a combo of unity and I think IntelliJ at the time and it's just having to jump between those back and forth neither were like seamlessly incorporated into the other was definitely time consuming especially when your game is a buggy mess and you're trying to deal with that you know yeah would you care to show us how Visual Studio can save the day in that sense and you talk about unreal which is going to be the focus for today right yes so today we're going to be focused on Unreal Engine specific features that we have built in visual studio um just to give everyone a brief overview we'll be going over how to see if blueprint references in visual studio um there we have added code analysis we have added Unreal Engine lock streaming so all those things you don't have to keep going to the Unreal Engine editor for um including adding a class there's a few templates out there um so quite a lot of features that we're introducing in Visual Studio 2022 17.5 with some of the features currently in preview in 17.6 preview 1. um yeah to get started um I definitely want to show everyone how to enable these features so one of the things that is absolutely needed for uh for you to see on blueprint references is the visual studio integration tool um it is an Unreal Engine plugin so here I'm going to show you two steps to get your sources so one is from GitHub we have open sources plug-in on GitHub so we welcome Community to contribute to this extension and you can if your project has a custom Unreal Engine or um if the marketplace installer doesn't work um this is the way to get um get your features working so the simplest way is there's a whole bunch of instructions so you're going to read me but basically you just clone this extension make sure the plugin is enabled in numero engine and you should be all set to go now for most of you out there um you might find installing it through the Unreal Engine Marketplace a little bit easier so in the Unreal Engine Marketplace the tool is called Visual Studio integration tool is published on Microsoft and all you gotta do is download and we support um a real 4.27 and the newest revenge of 5 versions so once you've downloaded this um you go to your unreal editor and make sure you enable this integration tool um for if you have any issues whatsoever we do have a troubleshooting page so it's on the GitHub there's this troubleshooting section and there are some common steps you can take to basically diagnose any potential issues you might run into so without further Ado let me switch over to visual studio so Leslie have you played with Unreal Engine before I have not I'm more of a Unity person or I've been more of a Unity person in the past yeah I I am by no means a game developer I know a little bit on my own time um but I think one of the things that we heard from our developers is um blueprints is a virtual scripting language you can use to build your game um with bigger production games eventually you want to migrate those blueprints to actual C plus plus code um for example you can prototype something really quick in Blueprints and when you find out the thing works um you ask your devs or yourself to refactor and remove the blueprint and previously the only way to see your blueprints was to open up the Unreal Engine editor um and go and search for your blueprints here we have added some koblin's hits so you can see right here class lyricame API by the way this is one of the unreal sample projects once you click on blueprint references you'll get a list of blueprints and their Associated asset packs that's awesome so before you just had to go back into the Unreal Engine and just double check um what group what blueprints in there correct area paths that you needed exactly yeah if you um you had to wait which you know it's not good to wait so if you see These Blueprints and they have Associated asset paths you can actually double click on them and see your asset information so here we have some properties uh with different categories um you know you can collapse them you can sort you can even filter out what you want to see so here's a list of all the things if this list gets too long um so this is a great way to reference um your blueprint usages without going to the armo editor that's awesome I love I'm loving the integration definitely not having to swap between two different pieces of software in this case yeah so before we um talk about another feature I want to show that if you might need to refresh your blueprints to do so is under the project menu and here rescan blue UD blueprint for your starting name all right so which is your your data and stuff I'm sorry does that just refresh your data like have you updated and um unreal while you have this blueprint yeah I'll refresh to if we do that um so another thing I wanted to show you is we added some code analysis into um into Visual Studio um this first round of code analysis leverages the unreal header tool which here it's basically a tool that is used one billion Unreal Engine game um let's say you make some mistakes and you don't even call this super important on real macro um once you hit save the color analysis are run the unreal header tool and give you some hints of why things are not working so here you can see purple Squid goes it says unreal header tool unknown specifier so there before you even compile you can see to save you some time that this is not the right thing right this super important macro for example it says expected and a generated body functioning at the start of the class that's because I commented out but you know typically you might make some mistakes that not catch until compile time analysis is designed to save your time so the next feature that I want to show you is also in this whole realm of oh let's not rely on the unreal editor I just want to stay in Visual Studio in this next um feature that I want to show you is the UE lock streaming so now you don't even have to go look inside your unaro editor for any logs um in this line 543 I've added a UE lock to capture every time we shoot the weapon um you have some log taxes so let's run this and boot up the game yeah so while that's building I mean it is really nice to just to see little things like just being able to check your logs in visual studio and all these other things you're just not constantly swapping back and forth right right going back to the um the assets page like when you double clicked on a blueprint it displayed all the data related to the blueprint can you or are there plans to if not already are there plans to be able to update your data via that window um they're not current plans um I think typically the you don't need to refresh that many times um but um if the community wants it we will build it awesome cool here's the unreal editor building up all right now we're in the game Let's Play and try to win this game oh no that was quick actually so let's go back to video studio um as you can see here um different now there's a new window called UE log preview here we can have two options for you um with all the logs that's generated throughout your entire game you can now filter it um remember we the log we added is log Lara ability system unselect everything select this and then look every time I shot it says PPP and of course if you want to see more of the logs you can also check this verbosity option to really display what whatever you need yeah that is really um this really Nifty definitely just to have your typical console logs and stuff all in one spot like you know you're already using a lot of vlogging to debug chances are so making sure it's all in one spot instead of having to add the extra time it takes to again go back to unreal and if you um if you for some reason close the window and you can find it um it's in view other windows and UE lock so if you click this then you can see the login excellent um so let's let's talk about another thing that I have learned with um when talking to um all the unreal developers is a real engine has a lot of complicated macros um I'm real engine there's unique macros everywhere but previously you can have a macro for example something like this a u-function you have to remember every um all the parameters you need to put in but now if you hover over this we have we have added macro expansion and when you say macros can you explain what you mean by that yeah these macros are um instead of typical functions um Unreal Engine uses um a bunch of heavy macros one by line um in order to achieve a lot of a lot of things more quickly than you know writing lines and lines of code awesome so this is an example of a pretty complicated macro that previously um you weren't able to see the entirety of it so now you can either expand online or copy so you can paste it to another um their editor window and so you don't have to remember all the things that it needs for example see your function we have some of the other maybe you property macro so these are the macro expansions that we have added um the last thing I want to show you is um how's it out of class and now we've been on Unreal Engine 5 for quite a while um let's switch over to a Unreal Engine 4 project so the classic action RPG you can see all of the um all the features here work you can see your blueprints you can see um your app get information but you can also add class once again we heard from developers it used to be that you have to open up the unreal editor add a specific C plus plus class and then open up visual studio again but now you can right click on your solution Explorer add UE class and we have provided four templates for you to choose from so for example if I add I want to want to add a new part let's just say my Pawn click add um you can see the path information once you click OK because studio will generate that template file for you um in both the C plus and the header files so file modification detected we click reload all and now if you see in the solution Explorer my pawn and cpp.mypawn.h awesome yeah so so dang you even had to create your classes via unreal first before uh playing around with them in BS yeah um a lot of the things I showed everyone today was only achievable in the unreal order but yeah unreal like once and that was just to play the the game so that's really exciting just to be able to stick to one spot right yeah so I think this is all the features that we have today um the team is working hard to build uh more and more of unreal integration into visual studio so if you have a great idea please let us know on developer Community or you can even trade at me well great so if people want to go learn more about how you can get started writing your own C plus games or using the Unreal Engine within Visual Studio you can get started with all the links that we're posting Below in the description so take a look at that and start making your own games yeah there is um a block that I've wrote I'm describing in more detail about holidays Integrations um that is now available in digital Studio good stuff well David thank you so much for being on the show I can't wait to see what comes next for game development and C plus plus and how it just integrates itself into Visual Studio that's really exciting and yeah thanks think again David thanks Leslie I'm happy to be here sweet and thanks for joining us audience and with that happy gaming and happy coding [Music] thank you foreign

Build triple A games with C++ in Visual Studio 2022

[MUSIC] >> Hi, folks. My name is David Li. I am the C++ Game Dev PM at Visual Studio. I'm here to talk to you about some new and exciting changes in Visual Studio 2022. Recently, our CEO, Satya Nadella, has said, as a company, Microsoft's all-in on gaming. At Visual Studio, we're all-in on gaming too. We have been creating new and exciting experiences for Visual Studio based on your feedback. Whether your Unreal developer, an indie game developer, whether you make your game on our proprietary engine or work on AAA game studio, let me show you why VS 2022 is the IDE for you. First, let me get started with the demo on Hot Reload. Now for game developers, this might sound familiar to you. Have you ever spend 30 minutes playing your game just to get to a specific state? Spend all those minutes and hours getting to that state just to find out your bug fix didn't work? Or if you're a technical artist. If you repeatedly have to restart a game just to see your [inaudible] iterations, Hot Reload is a feature for you. Let me show you how Hot Reload works. Imagine you're building an open source, cross-platform [inaudible] project like Bitfighter here. In Bitfighter, you have a ship that has a red round shield. You can activate the shield with a press of a button. Now what if you want to make the shield a little bit more exciting? Let's do that in Visual Studio. Here, instead of the color red, I'm going to make it cyan, and instead of a circle, I'm going to draw a star. Normally, without Hot Reload, you will have to close down the game, rebuild it, and click through the menus just to get to the same state. With Hot Reload, all you have to do is to press the "Hot Reload" button. It takes a few seconds for Hot Reload to run. Let's see here, a giant 10-point blue star. Isn't that crazy? Oh, okay. Maybe that's a little bit too exciting. Let's change it back to something a little bit more reasonable. Instead of the star, I'm going to go back to the circle. But this time, instead of red, I'm going to change the color to gold. Instead of pressing the "Hot Reload" button, you can also activate Hot Reload on File Save. To enable that, go to the dropdown next to the Hot Reload button. Click "Hot Reload on File Save". Once that is enabled, every time you save the game through Ctrl +S or the Save button, the change are automatically applied. Here, a gold round shield. Hot Reload supports any changes that are currently supported by Edit and Continue, and is not limited to only game developers. With Hot Reload, you no longer have to close your application, recompile it, get the application back to the same state, only to find out your fix doesn't work. Instead of spending minutes and hours getting to the same state when debugging, take those precious minutes back with Hot Reload for C++. Next, let me show you a demo with Intellicode for Unreal Engine. We build Intellicode for Unreal Engine by parsing many Unreal Engine databases and making an AI model. When enabled, Intellicode for Unreal Engine shows up in Unreal projects. For established developers, Intellicode saves time by suggesting the most common suggestions and sorting them to the top of the member list. For new developers, Intellicode suggests the right APIs in the right place. For Teams, you can train custom team models over your codebase, which makes the effects of Intellicode even more powerful, but providing suggestions on internal types as well as more specified suggestions based on your Team's coding patterns. This also makes it easier to onboard new developers as it help suggest things the Team is using elsewhere. Here, let me demonstrate how Intellicode works with member access. When you press a "Dot", Intellicode suggestions will show up with a star. The star denotes that this suggestion is from Intellicode. Similar down here, when you press the "Dot" operator, you'll get another Intellicode base suggestion. Down below, the Arrow operator also brings up a list of Intellicode suggested suggestions denoted by the stars. In this case, the top suggestion is GetController. With Intellicode for Unreal Engine, power up your experience of developing Unreal Engine games in Visual Studio. We have been working closely with Epic Games to make a great experience of developing Unreal Engine games in Visual Studio. Haven't tried the Unreal Engine? You can check it out under the game development with C++ workload in the Visual Studio Installer. One of the things that we have been working with Epic Games is increasing the responsiveness of IntelliSense. IntelliSense for UE projects is now significantly more responsive due to utilizing PCH when generating VS project files. Look for this new updates in a new version of Unreal Engine 4.27 coming soon. Similarly, Intellicode for Unreal Engine 5 is coming in an upcoming release. What do you want as an Unreal Engine developer in Visual Studio? We want to know. Connect with us on Twitter, and leave us your feedback. Aside from making Unreal Engine IntelliSense improvements, we have also been making core performance in C++ IntelliSense improvements in Visual Studio 2022. We have made a test based on Unreal Engine 4.27, a large project, and benchmarked it with VS2019 against the VS2022. The timings we're taking when VS opens a project for the first time and subsequent times average over three runs. Visual Studio 2022 feels faster when getting to code. You can get to code quicker in Visual Studio 2022 and open the file twice as fast. You can also wait less time for IntelliSense ready. Get the syntactic highlighting and code changes to appear in member list twice as fast. With the new improved IntelliSense performance in Visual Studio 2022, you can save seconds each time you open a file. We hear pain about IntelliSense performance with game developers. Now these are only few seconds each action. But imagine, how many times are you opening a file every day? How many times are you waiting for IntelliSense to open every time you open a new file? These are only a few seconds but add up over time. Especially for bigger projects, this will scale. These are small numbers, but they add up. We want more feedback because we aren't done making improvements. Install Visual Studio 2022 side-by-side with VS2019. We want to make it easy. VS2022 is binary compatible with previous C++ two sets in 2019 or older. If you are coming from VS2019, you may be familiar with our built throughput improvements. Let me briefly tell you what you'll gain from upgrading to the latest tools. Using the latest tools, the Gears 5 team at The Coalition saw a 2.6. seven times faster end-to-end build time and 2.8 faster link time compared to VS2017. Similarly, at Turn 10 Studios, they saw a five times improvement and link times for Forza Motorsports. For Forza Horizon 4, the link times are now 18 times faster than in Visual Studio 2017. The decrease in build time enabled Playground Games to switch from /DEBUG:FASTLINK to /DEBUG:FULL. You can enjoy all the benefits of the latest toolsets by upgrading VS2022. When you load your projects, you'll be prompted to upgrade, but you don't have to. You can still use the old compilers and the older toolsets and they will still work. You can enjoy the IDE experience of Visual Studio 2022 that way. Third-party libraries that will also work. Don't have a package manager? Try vcpkg. Download Visual Studio 2022 today, and try out all the new and exciting features we have in store for you.

Build Time Reflection with C++ in Year 2023 Pure Virtual C++ 2023

so next up Gabriel dostri is going to tell us about build time reflection with C plus plus in the year 2023 hey Gabby welcome thank you for coming once again have you have you been a talk every year so far I think you have yeah I'm I'm happy to uh to do it you know I'm passionate about it and uh and modules then you know anytime okay well I'll take it away okay so um you've you know as you know I've been talking about modules since uh 2015. and back then I've been busy telling everybody oh modules are great modules are truly an opportunity and uh and and that kind of stuff so today um I wanted to briefly uh tell you some of the awesome things that you can do with modules not just because your code looks better but what you can do with let's say left over of modules not real level but build artifact when you when you build your modules the compiler generates a bunch of satellite files information that it uses to process the rest of um of the program and and that build artifact is not just good for the compiler it can actually be good for you and one of the things you can do with it is to have your own reflection um I know that in the C plus plus Community we have been wanting to have a study reflection for for a while now and uh you know in my private take another couple of years or more before we get it but in between now and then what can you do so here I wanted to tell you you can do a lot of stuff um that don't actually need an upgraded compiler so so a reflection you know when a notion of reflection is just the ability of the program to uh examine query uh introspects and and not just that but also manipulates uh its own States and and structures and and behavior based on the questions that it asks itself and that's quite fairly General and some degree uh abstract but when you look at that definition you have the notion of you know introspection which is just really good query not modifying anything at all and and and indeed introspection is is just that part of uh reflection and some people say oh no you know introspection is not reflection but you know um it's usually is easier to implement uh you know we already have that in C plus plus and yeah of course you have it in other languages but in C plus for example you have um uh runtime tab information when you use tap ID on an expression or a type the compiler uh created data structure uh that it embeds in your program and then at the wrong time you can query the type and a bunch of other stuff um it's it it's something that's quite nice and you know allows um expression or something ideas that's quite easy to do as long as it is well supported when it's not well supported that's where you get a bunch of stuff so the general idea of of reflection introspection there are Notions that can be practiced at any stage of the uh development of of a program whether it is uh during pre-processing stage you know that you can use uh the string signification operator from the macro preprocessor to get the string of of a name right and and you can do concatenation so you can actually it builds more and more stuff and um you know in program you can use straight we've been using trades since uh C plus plus 11 you can query states of the of of a type or an expression an object decal type is one of those uh introspection uh operator same is no except wood and expression Ray is an exception for example so those are properties of a fixation and then of course you have runtime Behavior if you perform a dynamic cast for example that's during program execution and and the the compiler is required to generate data that embed your program in executable and and runtime it carries some operations try to find the right uh type that you cast into and and people will tell you well you know reflection is great but it doesn't it's not free it costs it costs stuff like compiler really has to embed something in your program and that can be a gigabytes so sometimes you will say Yeah in fraction is great but I'm not ready to pay the price for the additional uh you know object size increase that okay at runtime um I'm gonna Hannah cassette uh we have been waiting for uh some notion of static reflection for a very long time and some people are tired we have systems deployed that have their own meta protocol if you know the cute uh GUI system framework for example you know that it has the mooc compiler that nanometer objects compiler that look at your program and then generate supporting infrastructure to make sure that your slot and signals are connected and everything is is working uh properly that's just one one example um so if it has been taking that long to do how hard is it really I it's a type you know just associative value how how can that be the um the truth of the matter is that um if we just look at introspection for example runtime introspection um you know we have runtime RTI for example or any exceptions you can think of them as some kind of continuation uh the where you have program points State program point I want to jump back to uh later and then turn that to data that that you manipulate well what I'm doing here that is is it hinders optimizations right the compiler can't reason saying oh this thing exists there I know the structure and I can come back to it otherwise when I come back to it I can right away uh inline it or or move codes around and so forth so a cost and and furthermore uh you know one of the debates in the C plus plus Community is whether you should ever um enable exceptions or uh rcgi at all you know like type IG because well it you know it makes your program bigger yeah so we know we have uh evidence that a poor implementation of these facilities can actually be detrimental to actual adoption and it takes time and efforts to implement these things properly so it's it's non-trivial uh uh you know investment to make um now when we're talking about reflection so remember in introspection is just ability to query observing without changing the the state but reflection you not only doing query but you also want to modify the behavior of the program or generate new stuff based on what what's the well it's enough magnitude at least much more difficult uh you know in terms of deployment implementations and and so forth and once you have a you know reasonably good um reflection system in place it becomes much harder to evolve the um the language because well some of the construct that you knew when the program was compiled they were turn into Data embedded and if later you embedded in your executable if later somehow you you bring in component that was compile in the future or in the past and they do not agree on on on the protocol while you get into real trouble so once you have reflection in there and features or functionalities that are reflected become much harder to to evolve properly uh so that lead to people to say well we don't really want runtime reflection because you know we know it makes the executor much bigger and and it has much of her stuff well we just want static reflection which just means that during compilation um you know the we noticed that compiler already has those information as it's under this structure we just want to be able to um poke a little bit and then ask the compiler to generate a little bit more code but based on what is known at the time of compilation so the revolution problem is probably more reduced but you still have you know substantial work to do on a compiler so we know compiler writers C plus compiler writers we can fit them in a room and then we have millions of C plus programmers so if you can just get a couple of people suffer for they create a good of everybody else so be it so that that's good and having studying reflection you know mitigate you know many of the drawbacks that I mentioned earlier including performance and and space which is part of why uh the the standards committee and and the community as a whole have been pushing for for this for this notion um here to talk about real-time reflection and and and not static reflection and and some people are rightfully say why the hell is this thing that I'm talking about well it is not a new language feature it is not what it is is just um not making no just being you know very responsible with the resources that we have so the idea is that um as we're building the program you know during build time we we generate build artifacts and we would like to be able to augment the program the final program with uh information that we know during build time so we can generate new codes uh that gets compiled and linked with you know the the rest of the the object file that already exists to create the final program so um it's it's really involves real-time code generation and it moves the the burden from a compiler to the programmer so you know if you're interested in reflection one of questions that you should ask yourself is how much of the work that I'm asking compiler writers to do can I take on myself and how much of that can I get the community like you know help develop and and that is what you know this is about now what can you do based on what is known during build time and so the the way if you want to do build time reflection you you have to structure your your build program built uh in certain way you start with already known uh source code uh it could be you know human altered or you know machine generated and then you compile those things and then you let's say for example you have a module interface source file when you compile it you get what we call builds module interface or BMI uh or if you're using msgc we'll say you have an IFC file well that built uh build artifact contains a lot of the semantics information that compiler knows and it is possible for you as a programmer to go and crack open it and then generate new C plus plus source code that you can now get fit into the pipeline of build pipeline to augmented program and you do this iterate this process as long as you need till you don't need to generate more stuff and then when you when you link everything together uh you get a system that is fairly powerful it doesn't give you everything that static reflection will give you but my hypothesis and conjecture is that it gives you nearly about 90 percent of what we have been waiting for so it's a good thing to invest in um the for this to be successful you have to be mindful that because you're generating codes your build system how to support you know automatically generated code you know most of your systems about that and if somehow uh you're still running your own build definition by hand maybe this is the time to reconsider your your choices and see if something else can help you there okay and and another way of looking at build you know time reflection is let's say some form of grain Computing like you when you imagine you're using all these things and and then something was generated authenticity and you're not leaving it good to waste you you're reusing that information the same information at the compiler had before you two can can have that and with modules it it is there anyway like it's not additional work that we are asking the compiler they compile already did that works so we'll just being very responsible with the resources that that we have um so uh now I want to just illustrate the the idea of um uh build time um you know Reflection by using a very very simple simplified example the idea is not so much that I want to trivialize the problem it is to convey the basic of the idea once you get it I trust you that you'll take taking a run away with it and make it as complicated as you are that I trust you with so I'm just going to use a very very simple example so don't discount the example just think it is just a way of doing something it's a template and you can use it and magnify it to instantiating in other situations so the the example that I want to look at is um imagine that you you have a program uh rewriting program that has bunch of types and somehow you need to do a lot of formatting IO for formatting because you're sending data you're doing distributed computation you're sending data or network or you're saving uh you know data on file and and then bringing it back later imagine you're doing game developments and you want to save some save some characteristics of uh characters in a game or skinning and and so forth well how do you do that kind of IU thing automatically so that you don't spend your time you spend your time so you spend your time actually programming a game as opposed to doing work that is best left to machine so um the example I'm going to give you is using of course modules and what is what I use so um for this to to work properly and and and to scale we can't just go uh through the entire program and then generate IU formatting function for every single type that we find in the source file that just doesn't make any sense even I don't even compile and if it does it would just be waste so we need an ability to annotate in this this Source program hey I need something to be done automatically for this type okay so we need the hints whatever it is if you were designing a new programming language you probably need a keyword or something but remember I'm not here to talk about a new language feature I'm here to tell you what you can do with the existing language when I say existing language I'm mostly thinking about C plus plus 20 C plus plus 23 which should be out very soon and and you already have compilers out there supporting Gustav uh 23. so the ability to selectively tell the the tool the system to generate certain code for something will help reduce code blocks um and do we by doing so we also improve efficiency overall efficiency you know that space is time if your binary is Big it's probably going to hit up a lot of uh um space cache lines and and and so forth so uh take this very simple example imagine um I'm dealing with um uh points on the plane a planner geometry and I have a struct points then the usual thing have a coordinates you know X and Y of course I will go and write my own formatting function but it's boring it's boilerplate we want to increase your productivity we we want you to delegate that boring aspect to a tool just Define your abstractions and we'll take care of the rest that's what reflection is is really good at so in the example that I'm showing here like you said earlier we need the way to annotate so here I'm just using an attribute on on the type definition here the struct point to D have this attribute say uh gdr generates outputs so this is just some kind of you know DSL for me to to to to tell the tool to generate uh IU functions for for this type I don't want to write that function I want the tool to write it for me and what will happen when I do that is something like the following the the tool this you know so that helps me use uh real-time reflection will generate a new module source file it will take the uh the inputs module here the plane the geometry and he loses that name and then as basis and then we'll add reflected that output usually when you have [Music] um uh tools it's good if they they can predictively name things right and then the next thing it does all this is generated source code and say Imports to remember with C plus plus 23 now you just see import student then and then you move and do whatever uh you need to do um and you you can use this thing today like impositude works today uh if you download the uh um the msgc compiler and using your Ms build or using cmake it will take care of all of that and then the next thing it does uh they've told us is generate this function operator less than less than it takes an IR stream and point to D and then you know formats the the coordinates of the points in crystallized way and if you look at the code carefully those places are like green text you'll know that the entirely determined by the structure of the uh the class the destruct that that's here the name member and Absol so it is purely mechanical and this is something that a tool should do for you you do not need to do it the fact that the language the based language does not have this facility built in is yeah it's a shame but it's okay we can get the tools take care of those things that you can have here so like you say this is uh this is just a simple example but imagine you do not want a Authority like this you want let's say in uh Json format so you you know you'll have your tool generate the codes you know using Json library or if you want to have a banner representation on disk or you want to sign over to network now all those things the boilerplate that have structures like yeah templates that can be done automatically for you and the only thing that I so this is source code that's generally the tool and I have to make sure that my build system knows that this source file is going to be generated by the tool so that it schedules it's built properly the other thing that I as a programmer need to do is just to write my main you know program that's using this thing so plain geometry that module is something that I ordered that was input into the tool then the tool will generate automatically for me this or a module playing geometry reflected output that now I can just import an Imports to it again and I can just use um the uh the insertion uh if defaulting operator that was automatically generated based on the structure of of the class that that was defined so this is a a concrete example it is simple I agree but what I'm trying to convey here is not how sophisticated it is but how simple things can be okay and and most of you complicated um situations where you want to have static reflection you can structure the code in a way that you can actually use your system by carefully uh putting you know designing interface that so that you can have this cycle that I mentioned earlier how you orchestrate the build so the summary of course the io stream example is simple but it is a temp again it's a template you can use you can generate Json yaml if you're doing gaming game stuff is where you have a lot of Need for reflection stuff because you have types that you define in your source code but they represent stuff that you want to you know associate property is wave and and anyway that is mechanical so you can actually have a tool do these things for you these functions that are doing yeah the the the the output uh function they are automatically generated so they are always up to date with respect to the uh the type definition that is in your program right so you don't have to worry about it and and also if you happen to change the field or something you do not go you don't need to go and enhance 25 places to try to do you change those things the tool can just automatically generate everything for you and you can deploy this today we do not need to wait for another two three or five years you know decades to to get reflection and occur because this is simple enough that it can be taken care of and we can have your own like if if this doesn't work for you you can have your own generator based on the logic and the needs that you have that's the beauty of it you do not need to go and extend to the compiler you just need the compiler to tell you hey while I was building that module this is what I found is that useful to you and say oh yeah great give that to me I know how to use it okay so um all of that is kind of very high level uh description of how the code is is generated when you're using the msvc compiler and you build a module it generates an IFC file what we call builds module interface in you know standard terminology the msgc format that is the FC format is publicly documented as a matter of fact we want the community to really you know use it extend it and however it is specific a couple of years ago I gave a presentation about how you can actually decompose an IFC file and in another talk that's interesting that for you to see is one given by my colleague uh a camera on the camera and the way he he showed you know a a viewer of an FC fire written entirely in JavaScript so it's not even C plus plus right so when it when we say modules are truly an opportunity your tool doesn't need to be written in C plus right it can begin in language yeah you want as long as you can read a binary file okay um the one thing that I the last thing I wanted you to know before I go out is please start using modules today especially with C plus plus 23 where you don't need to remember which header file you need to include this and that no just say inputs to do boom and furthermore it is much faster the build time is improved because the the the the listed module which built once it's reused many many times so the combat doesn't need to re-pass it all the time it is simpler to use SPCA if you're on PCA today I really invite you to start considering using modules and and if named modules are a bit to still be step for you probably start with header unit but really what a game is is not named modules um there there is to be a a GitHub repo that contains all resource code that can use as inspiration that demonstrate what I just talked about and please call it extend it use it any way you you want and uh and give me feedback well what else would you like to see do you want an SDK how what are you going to do with it let me know um and and finally the IFC spec is is there on GitHub as well it you know it's for the community to develop contributes and and and and give feedback um with that said I'm I'm ready to to take questions thank you so much um so we've got a few questions in chat uh we have one from Antonio who says reflection is a fish hard to sell uh why not show some code you showed some code this was from from about halfway through um what arguments do you have on what there is to gain by using reflection what are the use cases for reflection C plus plus oh okay yeah so um not everybody needs reflection but the first thing I have to admit now clear hey not everybody needs reflection um I in the talk I gave the example of uh formatting that's just you know every time you're doing IU many of these types they have a photo certain pattern and they're very repetitive and you can get that automated um if you're doing gaming uh you have types the characters in your game they they tend to have properties values associated with them and you can have that saved on disk and read back automatically again the way you do that is very very structural and best done by tools if you're doing um this really competition these days we talk a lot about AI well AI is very computer intensive and they work when you're doing it work you're going to the best way to do it is you distribute it work so you have to send data over Network how do you get that done properly and and making sure that yours the data you're sending it starts everything is in sync best use you know a reflection to take care of that for you so it's not so much reflection in itself it's a tool to take care of boilerplate so that I can focus on the most creative aspects you know the joyful part of programming thanks and then we've got uh a few questions from milosh she says um do we believe static reflection would allow us to finally get rid of macros or are we cursed with uh hash if defined I'm just going to Source clang for the rest of time well okay so uh modules take care of you know a good chunk of the Democracy sorry if they have that kind of stuff taken care of by module now when we're talking about um compiler specific characteristics like you know certain features are available only on client or gccms you see uh those who will still be there um but when we're talking about code generation one of the things I I don't like macros but I also have to confess I use macros as a way to generate codes like generate sequence of tokens that are compiled by uh by the compiler well my sincere hope is that we will get a good reflection static reflection system that will take care of that huge sword of Need for um uh code generation then what is left is probably unstructured uh code sometimes you just want to include some text it has no structure to it well you still have to use you know macros for that but having something that plays by the language rules that your ID understand your group system understand is much better than having this you know character string manipulator yeah for sure and um of the the reflection repo uh you're going to pitch that live after the talk right yeah so yes yeah cool um another question is uh more theoretical but do we think it would be smart to have a pre-build step that is going to do this generation so that the IDE knows that these things exist yes I I agree yes yeah yeah it you know that's actually a good point um we talk a lot about what Reflections they great but they also add complications to the uh IB um experience where certain functions that you know now available at compile time or invoke that compile time need to be understood by the ID in order to provide um you know better experience yeah absolutely and then another more General one for everyone and a good introduction to compiler development on that one I'd recommend the book um crafting interpreters it's yes absolutely it's about interpreters but like it's mostly like all applicable to compilers as well you can like read that book and then pick up something a little bit more delving deeper into compilation techniques like uh engineering a compiler or modern compiler development in ml or C or Java whichever one you like for for some of the more compilery things but crafting interpreters is just such a a well-written and structured book that I recommend yeah 100 agree and and if anybody you know you know you should take size advice on it like this is great um and if you do it you'll find out that if you're writing an interpreter um and you want to do let's say IU for example because YouTube reads your you'll find out that you need a way to reflect the facilities in the sea headers on the C plus headers in your interpreter and this is another place where actually reflection help you write simply your interpreter that's fantastic second cat of the day here actually her name is lexical analysis cat so Mexico analysis and uh yeah uh anchor asks what compilers does is the question about GCC oh okay my my apologies they the only reason I didn't mention so I think on the last slide I said that uh use modules today you have cmic build system supports um and and they have built system support for msvc and client it comes in box uh for GCC it's not because you know it's more like the necessary support is not there so I didn't want to leave people on on something but you know you should also be mentioned that GCC also has um in support for modules okay and then there's one more on what compilers does gdr generally work with oh so uh the all the examples are built with msvc so the IFC format right now is very specific to admsvc compiler um you know I use my private you know Network private um build to do that so whatever preview is there as of today will will work um I would like to see the community um coalesce around a common format for a module bureau's module interface whether it is IFC or something else doesn't really matter but being able to have these tools work you know cross-platform cross compilers is is fundamental for for us the C plus probability to realize the uh the promise of you know modules being uh during opportunity yeah and I think that answers the next question as well which is could this work be implemented for other compilers like GCC and clang yeah um so the IFC spec is is is public and if someone feels energetic enough to to get a fork and and and generate uh IFC out of it it will work um you if you do that you do not need to change gcc's own internal representation you do not need to do that that's good it's one of work now what you will need to do is just ability to translate the IFC data structures into gccs or tax internal representation I think if I were to do that that's the way I would do it I will not uh sign up for every student right this is your client you're using obviously no no just ability to read all right that's it and then um still got time so another question is could the IFC spec be put in the C plus standard uh probably not C plus 26 or C plus 29. of course I would love that uh but the reality of thing is that from something like the LC you needed to evolve as quickly as possible the way compilers evolve whereas the the standards tend to be on three or six years raw so um if it could just be some kind of de facto stunner I think that will take care of all the Practical needs that we have and then let it evolve as quickly as it can and I would really love to to to see something like that happen great well we are out of questions and almost exactly on time um we stayed on time for the entire thing kind of thing suspicious you're running this thing quite well yeah it's our fourth year we're getting the hang of it so thank you very much Gabby thank you for everyone who has stuck around and watched all the talks uh these will be put online um on the the visual studio YouTube channel so um please keep your eye out for those going live and uh feel free to share them around if you have enjoyed um so thanks very much and hope to see you all next year

Build productive Python web applications with Visual Studio Code, Azure and Azure DevOps

hey everyone welcome to Microsoft Connect my name is Nina Zakharchenko I'm a senior cloud developer advocate at Microsoft focusing on Python and today I'm going to show you how to build productive Python web applications with Visual Studio code Azure and as your DevOps let's get started I've set up a repository that has all the code and the steps that you need to follow along just grab it from the URL get do slash connect appear I'm I've already set up my local development environment I've cloned this repository I've also set up a virtual environment by running Python 3 - M the end and then activating that virtual environment by running source and have been activate if I do a pip freeze we'll see that I've already installed all the packages from requirements txt in this environment let's take a look at this project in Visual Studio code code has an amazing and easy shortcut that lets us open up a whole workspace at once all we need to do is type code dot in the directory we'll see I have all my files here if I look here at the bottom I'll notice something interesting yes code has automatically picked up my Python virtual environment I didn't have to do anything to get this app running locally you're gonna have to set up a few secrets the guidelines for that live in the em-dash sample file here you'll see everything that you need to setup in order to get this pop working in production I've already set up a Postgres database I've run my migrations on it I've loaded in a little bit of fixture data let's make sure that our app runs locally to do that hit ctrl and backtick to open up the python terminal we'll see that V s code automatically activates the virtual environment for us we don't have to do anything to check out our app locally we'll need to run Python manage py run server to bring up the django web server and that's kicking off now let's take a look Oh we'll see we have a local Twitter application have our tweets we can even say a new tweet if we'd like hello connect everything is working as expected now if we run into issues how do we debug our jingo app going back to vs code let's kill our development server for now let's take a look and see what our request looks like by setting a breakpoint tap to the left of the line number two create a red breakpoint dot in the gutter next open the debug panel we'll see that we have no configurations here all we need to do is click add configuration and yes code knows that we have a Python project open it creates a new Python configuration for us super easy if we want to debug our Django what we need to do now is select the Python Django debug configuration and then hit this green button right here as our debugger starts we'll see that the bottom bar has turned orange instead of blue now if we hit our URL again we'll see that the debugger has stopped at the breakpoint we have a few options here we can continue we can step over we can step into or step out but I want to show you one of my favorite features and that's the debug console if we click here to the left of the terminal we'll see this little window pop open and I have a fully featured debug environment here I have autocomplete if I wanted to take a look at the request I can just type that in there I can also interactively work with this object I can click on the arrow here I can take a look at the body any of the content parameters examine anything that I want to about the request I can also take a look at our user Bob and check out any attributes about him I'm going to continue here that's great but what about debugging Django templates our templates can get really complex and hard to navigate thankfully the s code provides that too let's open up our index.html we'll see some template code here all I have to do is click to the left of that and that our debugger breakpoint triggered here I can look at the user in the debug console like I did before I can also setup watched variables here so every time a breakpoint stops these watched variables will populate I don't have to do anything I always want to see what user is coming up on my index view I can set up the user ID or the user in the watch here super-easy it makes debugging Python web applications a complete breeze now we've got everything working locally what if we want to deploy our application to the cloud well thankfully yes code has an answer for that too check out the extensions tab here on the left hand side in order to kick this off you'll need to install a handful of them the Python extension of course along with as your account to sign into your azor account and as your app service to do the deployment once you have these extensions installed you'll see on the left-hand side here a new icon that as your icon if you click into that you'll see your app service subscription all I need to do to set up a new deploy is hit this plus button right here I need to enter a globally unique name and I'm going to select an operating system Linux along with the Python 3 7 runtime see in the corner here that the web app is being created if an resource group isn't found it'll create one along with an app service plan let's just give this a few minutes to run here I have a pre-existing deployment what did I need to do to get this going I needed to configure our application settings so our production environment needs to know how to connect to this database you you can set these application settings straight from vs code here I click here you'll see all the ones that I've set you can even right click on an individual setting and hit edit rename delete it or you can do it from the portal to easily access the portal component of this application all we need to do is right click and hit open in portal and that will pop open the portal for us and open up the specific app service if I'm once my deployment is completed to set up that deployment I would want to right-click and configure the deployment source I would want the deployment source to be local get all I would need to do is right click again and hit deploy to web app that's it just a few clicks and you have an application running let's take a look at my existing app okay right click and hit browse website and it will go straight to that URL for me here we'll see our tweet our application running in the cloud on as your website's net this is great for smaller applications smaller uses maybe you're doing a little bit of work in development or QA what if we wanted to set up a CI NCD pipeline for our application we can do that with Azure DevOps pipelines to set those up go to dev azure calm here I have an existing as your DevOps project with a few pipelines set up I have two individual pipelines one for my continuous integration one for my continuous deployment let's take a look at the continuous integration one if I edit it here we'll see that there's a yamo file path as your - CI - pipeline Dhamma that exists in or git repository we can take a quick look at that here so the siamo file describes everything that we need to do we're going to be using in a bun - image we're going to be using Python 37 we're going to install all of our requirements and then we're going to run our tests and make sure that those paths before continuing onwards with a deploy going back to our pipelines let's take a look at the continuous deployment pipeline this is also configured with another llamo file this one is also in the repository right here the deploy pipeline we're using Ubuntu again Python setting up our Python version and then setting up a few environment variables our deployment URL our deployment username and a deployment password we set those up in the portal going back to our project here opening it in the portal going to our deployment center and grabbing those environment variables from here we're going to grab does get clone URL and then we're also going to make a set of user deployment credentials setting a username and password that were then going to configure in our pipeline another important thing about this pipeline is the triggers here we'll see that we're disabling continuous integration for our deployment pipeline but we're depending on the build completion step of our CI task having set this up once I deploy to master my CI build kicks off if it goes successfully I get a deployment super quick easy and really understandable that's all I have to show you today if you want to learn more about Python as your check out this URL you can also take a look at the Django on visual studio code tutorial or take a look at the demo repo all the steps that you need are right there all laid out and I hope you all have an excellent connect it was great talking TTA bye

Build Insights in Visual Studio

for many people building insights has been instrumental in improving the performance of the wheels we have received a lot of feedback from the community expressing their desire to have this functionality integrated into Visual Studio hi I'm Nelson troncoso and today I am excited to announce that for 17.7 preview to build insights will be available inside Visual Studio also we have worked closely with game studios whose large and complex code bases can greatly benefit from buildings to bring you this tool so without further Ado let me show you a preview build insights is included by default in the desktop development with C plus plus and game development with C plus plus workloads to get started we will need to collect performance data to do this under the build menu you will find an option to run build science on solution selected project or projects you can choose between performing a build or a rebuild I'm going to select build as soon as the bill starts visual studio will be in collecting performance data and it will automatically Stop and Save the data into an ETL Trace all right once the build is complete Visual Studio opens the trace and displays the collected data inside an editor window a very common issue that can increase the time it takes to compile C plus plus projects is the repetitive parsing of header files and it gets worse as the size of the code base increases for this reason we prioritize included in the first release to views to help you troubleshoot similar issues included files and include three the first view shows how many times a particular pile file was parsed by the compiler and the time it took the second the included displays which headers were included in every file it basically gives you the include hierarchy from here things that you can do is like for example go to the source code let me show you another file oh yes another thing that you can do from here is navigate to the other View as you can see I went from the header included by that file to this View also you can filter files by name all right let's start to investigate we can see that the repetitive parsing of some headers takes a significant portion of the build time uh windows.h takes 15 era locators there's 11 the other 10 10 and it goes from there with the most problematic headers a possible solution is to do a pre-compile header or PCH version here I have another project which is a duplicate of that one and I made some changes Windows Edge and you relocated the edge are included in a PCH something you might notice is that I have a C file and I have a CPP file file the reason is because uh Windows 8 is for C and C plus plus but era locator is just for C plus plus let's let's check as expected a real performance has improved significantly now it takes 37 seconds you can see the the percentage of parts in duration two uh let's go back uh yeah so 62 seconds almost half and then uh if we run we can also search for one of the files windows.h and we can see that it's no longer an issue just have uh half a second now it takes and we can see that it was included by the C and the C plus file which is expected because that's what we did um let's go to the included you see the PCH related files are the top one last thing we have also added a button you can use if you would like to dive deeper into your investigation using double UPA thank you to everyone who provided feedback we hope that this tool will enhance your workflow by helping you improve the performance of your C plus plus builds what you see today is only a glimpse of what is possible we're not done yet please continue to give us feedback as we refine this tool and add more capabilities thank you

Building Bots Part 1

it's about time we did a toolbox episode on BOTS hi welcome to visual studio toolbox I'm your host Robert green and jo...