 Dys Gruen 1973, dyma'r bandwch yn siw ac y byddwn ni'n cael ei ddifwydd... Eryd. Ynny ddim yn ymgyrchol. Yn iddyn ni wedi gyda'r ddyn ni, y gyfnodd ymlaen i'r gweithio. Prif, gwelodd. Dw i'n ddefnyddio ar gyfer... Dyw'r ddyn i hwnnw, i ddysgrifio ar gyfer. Rhaid i ddifion. D度f. Mae gymhwg o'r cyhoeddiad yn siarad o olwyddiad i'r bys. Mae'n eu gwahodd o'r rhaid o'r ymddiad i'r bys, i gyhoeddiad i'r ymddiad i'r bys yma, o'r ddiwediad yma.ysgwch. Mae'r ddod o'r cyhoeddiad o'n cyhoeddiad o'r ddod o'r ddod o'r ddod o'r ddod o'r ddod o'r ddod. I'm not going to solve it. Thank you. Thank you. Hi everyone, thanks for having me. My name is Martin Woodward. If you want to abuse me on Twitter in real-time, I've switched Twitter notifications off, so you won't all see them. It's just at Martin Woodward. Please tell me if I'm speaking too fast or get over excited, it's how I work, unfortunately. Just to set expectations early, we've got a fantastically full room, which is awesome to see. Thank you very much for your time. To make sure I don't waste your time, I want you to get the next 90 minutes and learn something. If it's not for me, then I don't mind. I just want you to learn something in the next 90 minutes. What we're going to do is we're going to use the very, very, very, very latest build of a thing called DotNet Core, which is a new version of DotNet that's been developed in the open-source community and Microsoft are involved. And we're going to learn C-sharp the language using this brand-new version of DotNet. That isn't ready yet. I was looking quite late last night. Who's planning on following along on Fedora 2.3, for example? We might have some trouble. When you're following along, you might want to use Mono rather than I'll show you where to get. You can drop Mono in source already. I'll show you how to install that. Rather than installing the very latest version of DotNet that I have, but I'm going to show you here. I was trying it all last night and found some problems. Stick with Mono and you'll be able to follow along. I'm the plan. We'll see how it goes. The plan is I've built a workshop over the past week, a tutorial style, and put it up on my github repository. If you go to Tanyawell.devconf C-sharp and I'll put this up on the board so we have it in case you want it later on. I can't even write this one. There we go. You follow along. That has the full tutorial on it. We have lots of words that you can follow along. Especially if you're having trouble keeping up with my very fast English. Feel free at this point that has everything you need. Feel free to just walk out and grab the next session if you wanted to because you'll be able to follow along virtually here if you need. That's everything we need today in that github repository. We're going to go through and we're just going to do the very basic whatis.net We're going to just do some simple hello world stuff. I'm assuming who here has done any C-sharp programming before? Oh wow. Who's done things like who knows about lambda expressions and link? It's very advanced for you guys then. You might just want to wander on or you might want to have a play with .net core and see how bad it is and have fun with it that way rather than using mono. The idea is who here has never used C-sharp before? That's who we're aiming at. Of those people who's used Java and then Go Python Swift We'll be fine. It's a modern language so we'll be fine as we go through. We're basically going to run through and do a crash course in C-sharp is the plan. Feel free if you want to see how it's going but just look at the repository and just head off. It also includes instructions on how to get the very latest build of .net on your machine. Okay. As I say, my name is Martin Woodward. If you want to email me, you can. Abuse me on Twitter. That's what I look like in case you forget. I don't know why that's there. I work at a company called the .net foundation. A nonprofit foundation that's set up for opensource.net. I'll talk more about that in a moment. I live in, not far away in rural Northern Ireland which is a beautiful part of the world. There's the view from my desk is great. It always rains in Northern Ireland so we have lots of good rainbows. And then it's I do, so I I work for the .net foundation and I'm Microsoft pay my wages to go work on the .net foundation so Microsoft give me a desk as well in the office in Belfast. So I don't know. Has anyone been to Belfast here? No? Okay. That's where my office is in Belfast. It's just the, you see that little there, oops sorry get me laser pointer on, wait there. There we go, sorry about that. It's just up here up in I've done it wrong again, there you go. Just there is where my desk is. That's an old battle ship. I tell you what has anyone seen Game of Thrones? Game of Thrones? Yeah? That's where Game of Thrones is filmed. Yeah, I know. It looks so glamorous. Really isn't it? And then that's a good if anyone, when you do come to Belfast I'll do my tourist information come here, that's a great museum the Titanic Museum and actually don't let this worry you but you know the entire open source strategy of .net comes out of this little office here and that hole in the ground that's where the Titanic was built. So hopefully this one will end better. As we like to say it worked when we last touched it is what we are so or built by Irishmen, driven by an Englishman, is the other thing. Most of the team a lot of the .net comixes work over in Redmond in the Microsoft Office there and as I say I work for the .net foundation which is it's a non-profit foundation set up to help .net have a healthy and vibrant ecosystem and make sure that the core of .net doesn't belong to any one company and make sure that people can invest in it because for some reason people still have a hard time believing Microsoft getting into open source it still kind of rings it still makes people confused we are not open sourcing everything most of you are too young to know what this is this is Microsoft Bob we are not going to open source everything there are limits to where Microsoft will open source things we are definitely doing a lot more open source in the .net world in the .net foundation we have right now 180 projects and there are about 4,000 people have had a PR merged into .net the version that we are going to play with today so it's of those I think about 200 people Microsoft employees and then the rest is the world so it's a pretty active community and fun now of those 4,000 people a lot of them are doing this for fun and so obviously the people who get paid to do it every day tend to be at the minute getting more PRs merged because they get paid to work on it all day long so at the minute I'm finding it's about 80% of the PRs being merged for people with Microsoft in the company name and then 20% is other I would like to see some bigger chunks rather than just one other block but we'll get there people are coming back and submitting multiple PRs which is great as well it's not just people fixing a spelling mistake in a comment and running away as you've all probably had it's people actually sticking around in fact when we open source dotnet originally we open sourced it and then four days later a guy called Jeff Norn he's one of the mono committer he he delivered the mac port of it in four days and we had a team of people in Microsoft who'd been looking about for ages and you know we believe in again Microsoft's kind of getting starting to understand open source it took a while but we're getting there and the thing with this dotnet effort open sourcing dotnet is we decided rather than to work away on it in secret and then go tether with an open source licence we decided bravely some say foolishly but we are bravely to begin in the open and to be 100% in the open and have the developers working on this project that we announced we are doing in the open on github so if you want to see all the cool requests there is no secret repo anywhere they all work in github that's where everybody works every day so it's great and then if we track the number of contributors we get in it's doing quite well we're still we've sort of dropped below node in terms of the amount of people committing to our repository since the beginning of node compared to dotnet but we're up there we're doing okay we're definitely better than previous efforts from Microsoft in terms of getting people involved it's not just being published under an open source licence it's actually an open source healthy project and as I say just a quick word about Microsoft the elephant in the room as it were the attitudes have changed a little bit inside the company recently partially because the kids are in charge now adult supervision has left the room and the next generation of people are definitely leading the charge in the company and people like Sacha he used to be closer to me in the org chart than he is now he's risen a long way and I've stayed where I am and then Scott Guthrie led by senior executives in Microsoft is definitely a change and it's been great to see the change in culture in my old job in Microsoft I was the one that created our gate hub repository one day and I moved us on to gate hub for a lot of our open source work and that was in believe it or not June last year was when Microsoft started using gate hub officially and as a Microsoft and then there are now 2,000 this morning I took the screenshot this morning 1,724 full time engineers in Microsoft working in gate hub that's a lot of people contributing to the open source world which is just great to see and for me I come from sort of the eclipse background and the Java background and the Linux background and coming into Microsoft it's been a great time for me because the companies come closer to the way I used to work anyway were just those people but what I've liked the most is the culture change in the company Microsoft's a very again it's a very email driven company so lots and lots and lots of email if I show you my email inbox there's 23,000 unread messages in my inbox right now it's important they'll phone me but it's so it's a very email driven company but one of the great things you know when somebody has a again you're all too young but when somebody has a baby in the office they quite often send round pictures of hey we've had a baby and the best thing I enjoyed and I knew I had won I knew we were winning in the company was somebody sent out an email saying hey here's the baby and the first response that came back was you know plus one looks good to merge so I was like yes we're winning culture's changing right quickly most of you know then it seems that dotnet is a general purpose platform it's always been multi-language so lots of different languages on what's called the core language runtime but it's VBC and F-Shark are the primary languages today in dotnet the ones that have the most innovation and it's always been multi-language but now it's becoming multi-language and multi-platform yes I consider everybody's languages important and I love Haskell as well but it's more that where the funding's going in terms of full-time developers working on it so apologies if I offended any prolog of dotnet people but there's things like I and Python as well and there's lots of other languages on top of the CLR and there's quite a few experimental languages as well and somebody lost people in Microsoft Research used the CLR as a playground to try out new languages and new computer science it's quite interesting but anyway there are two specs that define the CLR there's 335 which is the runtime and then 3344 which is C-Shark that spec is woefully out of date with the modern C-Shark so one of the things I'm doing right now is working with the team to update it and we're hoping to update it to the C-Shark version 5 language to quickly get then onto C-Shark 6 in the spec but it is a public spec is C-Shark 2 which is hey I've only been in the job since April I should say but I think it's one of those things where again as they're learning to be more open they realise they're keeping up to date in June I'm hoping that they're going to get this solidified and catch up a bit and it's important that all of .NET is available if you go to that org on GitHub it's all there the compilers, the framework the runtime, the JIT the GC it's all there and it's all under there's a mix of MIT license code so it's all permissively licensed so go crazy if you want to go do a fork of .NET that does something else go for it, I'd rather you didn't I'd rather you contributed to that but you know what I mean it's all there if you want to the C-Shark compiler and the VV compiler is a project called Roslin if you want to find the compiler if you're interested F-Sharp has its own compiler because it turns out F-Sharp is a functional language on .NET and it turns out writing compilers in functional languages is a really interesting and fun problem so one of the first things the F-Sharp guys did was bootstrap their compiler in F-Sharp so the F-Sharp compiler isn't Roslin because Roslin is written in C-Sharp so the VV compiler is written in C-Sharp so the VV compiler is written in C-Sharp which boo nevermind sorry VV guys and then the entire web stack as well as open source including the new high performance web engine kestrel talk a bit about C-Shark language obviously there was V1, V2 where the ECMASpec is C-Shark 2 was when generics were introduced properly and I say properly as well actually introduced properly in the bytecode and then we had a bunch of new features coming in since then which we're going to cover today in C-Shark 6 there were some new features again which I'll show you but the main the main driver within the C-Shark 6 time frame was actually rewriting the compiler used to be written as a big lob of C++ I think it was like a 30,000 line file for the compiler in the old days and so they rewrote the compiler in C-Shark at the C-Shark 6 time frame and open sourced it and then the future for C-Shark 7 which is the next version of a language is around very lots of things around streaming lots of things around small kernel performance and things like that is where they're heading and making sure it's fast and getting things like messing with high performance strings and just when you're trying to do lots of high performance web servers like string manipulations really important so anyway go ahead the question about the Rosling compiler is it supposed to compile to the full feature of the .NET framework or is it supposed to compile to the .NET core? yes great question is the Rosling compiler just at .NET core or is it for the full framework? because it is the same compiler for the full framework and we're going to cover that there's different versions different flavors of .NET and there's the traditional .NET that you know and love some of you that sits on big windows and machines and you install it into your GAC and all that sort of stuff and it ships with windows and it ships with Visual Studio that thing uses the Rosling compiler underneath as well and part of the Rosling compiler now they're licensed under a proper open source license where people don't have to worry about patterns and things and it's actually really open then the mono guys as well are also using it and it's starting to try and make the whole ecosystem a lot richer which is great fantastic question thank you I will bring up a I'll send you a link to it probably because it's right now there's actually a set of different issues where they're defining C sharp 7 and what they want to go build in it so I will put up a link to that before we finish today and then you can go read in the detail and then tell them where they're going wrong as well but briefly it's to when I say like services features to the language to help it be more efficient for making small services like good handling of streams, very high performance stream I owe high performance handling of UTF-8 strings and optimized handling of UTF-8 strings because in .NET .NET does strings of UTF-16 which is great and we do localisation globalisation really really well but if you're running in a small micro kernel or small kernel you're throwing away half your bytes all of a sudden because you've got all these extra characters you're never using on the web because you're probably only using UTF-8 so that's all and then I'm trying to do that while keeping current strings this hard work by the way and then in terms of C sharp it's one of my goals again when I started to get C sharp is one of the top trending languages on GitHub and in Stack Overflow and we've got there now we're in the top five if you combine GitHub and Stack Overflow which is good top ten so langpop.nl is an awesome site if you want to go do any research on GitHub data and languages and things just quickly and then we'll get coding .NET's always been splitted to verticals and you've always had a big single version of a framework it's stored on your windows machine and on the desktop and then when you wanted your grade .NET it was always a real pain because you upgraded it to every single application on that one machine and then it would break half of them there was no way of saying I want five versions of .NET and I don't want any of them to touch it usually broke well not great things but it usually made them run under a different version of a framework which sometimes breaks things and then we have all things like the windows phone and we had the ASP which runs under IIS on windows and again I think it run the framework and you would install that on the box and break things in so it's organised into verticals we also have things like compact framework and micro framework and the version lots of different versions of .NET but always a vertical often developed with the same API but completely in isolation with .NET Core what we're trying to do is make it a lot more modular and a lot more componentised and then make it so that the things we build on top of .NET are inheriting from a common core and that core will be open for the open source somebody like the Xamarin guys want to take .NET and make it work on IOS and Android then they can do that with a full high performance open source base that's the same base that Microsoft are also funding to develop things on Azure and all that sort of stuff so it just makes sense and it's all split down into lots of modules blah blah blah there are different versions of .NET right now which you should consider there's a .NET framework a big desktop framework for building WinForms applications and stuff that's still there that's still being developed that's very very active development still and will remain so because it uses components from stuff we're also building for .NET Core like the compiler and everything then you have mono which was originally developed as any mono committers here by the way because they probably know about more about it than me it developed as a parallel fork of .NET and had to be done very carefully because of the times things weren't shared as openly as they are nowadays and they did an amazing job and mono is very equivalent to the full desktop framework whereas the desktop framework one's on windows, mono runs everywhere even on my little Raspberry Pi it's awesome but it's very much the traditional .NET framework approach then you have the Xamarin stuff which is based on top of mono which takes mono to iOS and Android and then finally we have .NET Core and .NET Core is being used for the new version of ASP.NET ASP.NET Core and also it's using anyone heard of universal windows applications or universal windows the marketing guys have done the trick then basically UWP apps or metro apps is probably what people think of them Windows 10 applications that runs on top of UWP the universal windows platform which is based on top of .NET Core again it's a much more modular version of .NET and what that also uses makes use of a feature is the ability to compile .NET code into native code now so you can actually yes sir there is a the libraries that support UWP are based on top of a point in time snapshot of that codebase but it's not it's slightly different stuff on the front end I'll dig into it more and show you more later if you want probably so there are parts of it but no .NET Core itself isn't in production but there are parts that have gone into production applications and then so all that as you say shipped in the last version of .NET and then we're working on all the .NET Core stuff and in the open and then I've warned you already but here be dragons we are on the bleeding edge as we'll see so we do some hackery today and then finally one of the things the team of folks in very strongly on is on performance so this is using um my name is the benchmark now sorry if you click on the deck you'll see where on the benchmark there is but what they're trying to do is drive the performance up of .NET so it's really really good at handling high web loads for example if you look at ASP.NET 4.6 then it could handle that sort of 32-thread system could handle 60,000 requests per second and they're up to 1.8 million and they're trying to get towards 3 million requests per second so they're really trying to get it very very very high performance right then let's go okay so timeyourall.com is anyone able to get there on the wi-fi or if you want to follow along if not then I hope so because I'm going to be using it as well and then let's just wake up my VM okay let me just check so it's d-e-v-c-o-n-f c-sharp let me try if you want if you just go to there you go that's what it is there is that okay oh you can just go to if you just search for martin woodward github and then you get to my repository I have already put down my repository brilliant, I'll manage it what did I do wrong you are using sudo to match okay good man, thank you very much that's a habit from Microsoft people we always like to run as admin you know us brilliant, thank you very much that's awesome and please do that if we find some problems today we'll fix it as we go through because let me just get rid of that so you don't need to pull down the repo I want to share a couple of other little things as well while we're here that you might not have seen so let me just make this a bit bigger for you sorry thank you I'm learning already today do we like it okay so one of the things I wanted to show you was I said Microsoft changing a little bit so let's do for example Microsoft have a editor they've built so let's just do code readme.md so this is an editor, it's called code visual studio code everything's got to be visual studio all the tools are part of the law but it's atom based electron based lightweight editor you know I put it this way, I was skeptical the guy that runs the team is a guy called Eric Ganna you've probably read your books of Gagam4 and he was one of the guys that originally you know sort of got glitched off running off the ground Well, OK. Yn dwi'n gwneud, Roeddwn ni'n enda'r ffyrddwn gwneud wrthu'i dweud hynny, ac mae hwn wedyn rwy'n geisio ar weld fy modr i fod. Dwi'n dweud dweud, dwi'n dweud beth sy'n rhaid bod rhai ddiwedd. Ond i'w oed yn y gallu ymddangosio rhai un i ddiwedd yn newydd, i dda i'n gweithio ymddangosio ymddangosio bwysig. Mae'r ddweud fyrdd ei gwyín ddi gymryd ym magwyd, a newydd yn gweithio'r ddiw i. Mae hwn yn gallu trool. Rydyn. O'r ffordd, mae'n ffordd gwahanol, ac mae'n cymdeithas mewn gwahanol o'r ffordd. Felly, mae'n cyflwyno bod yma. Felly, mae'n ffordd yn ffordd ar y ffordd. Yn ddigon nhw'n rhaid i'r ffordd yn ffordd arall, roedd eich rhaid o rhaid o'r ffordd. Felly, mae'n ffordd. A oedd yno'r ffordd o Ffordd, o'i chyfnodd yma, gydag yma, i'r pryn sy'n rhaid i'r pryn sy'n ffordd i'r rhaid i'r rhaid i'r pryn yma, a wnaeth hynny'n ddaeth. Ond wrth iddyn nhw'n gweithio'r ddonach o'r run. Rwy'n gweithio'r rhan o... Rwy'n credu bod yn ymddangos o'r Fadora. Mae'r hyn yn fwy o'r ddechrau, rhaid i'w fawr, felly mae'r ddechrau i'r ddechrau i'r rhan, mae'n ddiddordeb o'i ddiddordeb. Rwy'n ddiddordeb o'r ddiddordeb. Rwy'n ddiddordeb o'r ddiddordeb, mae'n ddiddordeb o'r ddiddordeb o'r ddiddordeb. We have. It's that one! We just have a nom and it ages over to the writing anyway. Eventually it's going to be www.y limiters.net and magic happens, but we're not there yet. So this is the yogi version for what the instructions are for. So you have just told some prerequisites, I then went and did all this tutorial on a known, this is because things have been a bit flaky, so Roman had you download the latest build which may or may not work. I ran all this on that particular build, so I know that works. So I wanted to make sure the latest build might well work before you find, but I just wanted to make sure if you were following along today, you were using a build which I knew worked and I'd tested all this stuff on, so there we go. And then extract it and then put it in your path basically. Or if you're running on Debian-based things and you know, whatever, and we've got on Debian, we've got to the point where you can do app get install, and that's the experience we want to have for in your policy, we'll get that. Especially if your guys help. Right, so then what we're going to go do, because that's tutorial one is just getting all this stuff installed on your machine. So I'm going to assume you can get that done, but we'll go and have a look and we'll see if we get some problems. Sorry, I'm going to follow along with this. Let me do it here. So getting started, there we go. Right, so the first thing we're going to do is, and as I say, if you've done C-Shark before, then this is maybe a little bit basic, but I'll show you what the experience is like under .NET Core. So, okay, so when you install .NET Core, you get the .NET command. .NET, and you type .NET, it's quite annoying. That was back before we had the memo about the internet is when .NET was named. So we have the world's worst name when it comes to Google food, but never mind. So, yeah, I know. What were we thinking anyway? I think they even will even modify their search engine to provide for C-Shark so that it's different from C. Yeah, one of the main, funny, one of the best C-Shark programmers on the planet and who's won Stack Overflow, a guy called John Skeet. He obviously works at Google, which is hilarious because he's not there, but he's a good guy and he's working on .NET stuff now at Google, so that's awesome. Yeah, so once you've got it installed, you can do .NET version and boom, you're up and running. And then, or if you want to follow along with Mono, then you can. Yeah, so all you do is, so I'm in here, I can do .NET Space New and it sets up a scaffold of a quick Hello World project for me. So you've got, you know, Program, ZX, where all the work is, and then a couple of files. You can ignore the newget.config for now. Newget is the .NET package manager, you know, like Maven or Yung or whatever. So it's the package manager for .NET and then, or MPM as well as like this. Project.json is a thing that describes the project. And basically it's telling us, again, because I've specified a build that we're running on here, I'm making sure we're going to be fairly stable. It's specifying an exact version of the .NET standard library that we want to use. And then, as we pull in other things later on, like threading or whatever, then we would add new dependencies into that dependency thing there. This framework section is the frameworks that you want to build on. If you were running this on Windows with the full framework and you wanted to build a library that supported the full framework .NET core, maybe you wanted a portable class library that worked on Windows Phone 8 and stuff like that, then you can actually specify multiple framework versions as well so that when you do a build, it builds them all. But we're just going to do .NET Core 5. And then I'm going to try and make myself use code. If I had to type thy and then a app kicked me, because I'm trying to force myself to use code, because it's actually really good. So code. I'll show you why I like it. You can configure, so there's a project called Omnisharp, OMNI-Sharp, and that gives completion, language completion, so lots of different things. It's a language completion service. And there is a plug-in into VIM for Omnisharp, so you can get all your auto-completion of C-sharp stuff within VIM, if you want to. I'm going to do it inside of this fancy code editor, because it's pretty. But let's see how we get on. I need to make the font bigger here too. I wonder if they've done control plus. Probably not. No, don't mind. I think to make my... It's a proper editor, so I think to do my preferences, I actually think I need to go in and... Do you have dark control? Yeah, a minus works. Oh, was it? Oh, there we go. Thank you. So there we go. See? Right, we can read it. Brilliant. So it does Hello World. I mean, when you do .NET new, it spits you up a Hello World, which is cool. We should probably do something a bit more funny than that. The next thing you do normally is you type .NET restore. What .NET restore does, don't do that if you're on RHEL or whatever. But we read the instructions, they're in tutorial too, if you're on RHEL. Normally you would type that. And that's what you will be able to type. And it'll magically work in about a week or two. It might even work today, but I didn't want to risk it. So unfortunately, it didn't recognise RHEL and Fedora 2.3 properly. The guys were building it like we're living in Centos world. And so it kind of wasn't working great. And so what we have to do is a bit of a hack, which I've documented here. Where basically, sorry, I'm just going to make that bigger. Basically you pretend that you're Centos or CentOS. How do you pronounce it? Both, okay. CentOS. I like that. It's an interesting sound. Cool. I normally say CentOS in my head, so I'm going to go with CentOS. So you just pretend you're CentOS. And then what you have to do is hack a file to flip it from saying I'm CentOS to actually being on RHEL or whatever you're on. And there's my crazy use of sed, which again, you could probably do a pull request and fix my sed. That's probably wrong as well. And then what I do is, rather than doing that every time, I just set up an alias, a DNR, which runs both commands. So I can just type DNR and it'll do that quickly for me, rather than... And what I'll probably do is actually map DNR to do .NET restore for me again later. Because it's an amusing acronym. So I'm going to do .DNR here, but if I was over in the Mac and did it properly, then... So that's the experience we want to get to. And we might already be there. There we go. Oh, hello. That's in the same way. That's kind of the experience you want to get to. Okay, so once you've done restore, it knows about the packages. Oh yeah, I've definitely done something wrong on my sed, but never mind. And then we've got the project.loc.json, which basically tells the compiler where to get the packages from. And then we've got the program. And then to build it, we could do .NET build. Again, we could also do .NET build-native, and that would actually give us an executable. You know, a single thing with a chi-mod-a, you know, u plus x on the bit, sg bit, joy. Again, native build's not working this week. So hey, let's not do that today. Let's go with the very slow, but always works, .NET run. And what this does is it does the .NET build in memory, and then executes it, and then throws the thing. And then ridiculously throws the thing away that it just built. And it's like, why don't you keep it around first? Well, hey, you're that, brilliant. And then, you know, you can... Hello, Bruno! There you go. And again, oops, sorry. And then .NET run. And this is the, again, this will get faster. Well, this is the experience of edsing .NET. You know, you edit the files, hit run, or hit build, and then it goes into the stuff. There is a REPL. If you want to do interactive .NET, you can just do .NET REPL. And, you know, he says, before I worked. And then, you know, type .NET in, system.... I think this works. So you can type .NET in, and then it executes it badly. But apparently I've done something wrong. But anyway, I'll type it properly next time. Pound quit, is it something? I'm just going to go and see if that'll work. Right, so yeah, there we go. Woohoo! Hello world, brilliant. My work here is done, let's go home. Right, next one. Just go, actually, that's a good point. So it's C-like language, I suppose. You know, it's kind of, if you've seen Java, you'll get it, I guess, as well. It's the... .NET has, at the top, rather than, like, import, like they have in basically every other language in the world, it uses using to bring in dependencies. So using, and using system means I'm, at the minute, just pulling from the system library. Things like console and thread and stuff are in there. But all the collections are all in different namespaces, or what they call packages in the C-sharp world. So I'm defining this class called program to live in a namespace called console application. And then you have a public static void main. That's what the executor looks for within a .NET assembly to be the thing that it runs. So .NET, you know, probably said void main. Hello world. And then, you know, as we're all, people on Windows hardly ever do this, but as we're all, you know, real programmers, we'll make it be an int and we'll return zero, you know? Cos that's awesome. And then .NET run. Actually, no, let's get it to return one. That'd be a bit more interesting. Oh, no, let's get it to return 42. There we go. I'm not quite sure what that error code is. Come on. I don't run again. I might give this VM more memory. And then echo. Dollar question mark, isn't it? To get it to return it. Come on. There you go. 42, so yeah. There you go. Amazing. I got a clap for that. Nice. You're very generous audience. Okay. There you go. Blah, blah, blah. Name spaces, public static main, a C-style comments. And then it's worth thinking there's, you've got visibility, so you've got public. You have private. And then you have a thing called, so privates within the class, within the namespace. No, we're doing it in the class. And then you have internal, which is within the namespace, and then protected, which is within the namespace or things that inherit from, I think. All the different ones are there. Generally, you tend to use mostly public and private when you're doing most development and then protected and internal when you're thinking about APIs and stuff, but most code is fairly open. And yeah, so there you go. That's a C-Shark program. We're not hammer it. If you want to learn more, go click on the tutorial. Right. Let's flip through the basics. So it's exactly how you expect it to be. So you have basic types. X equals one. You can do stuff like X plus plus, so increment X, and then store the result in X. You can have plus plus X as well. So give me X first, and then go increment it. What else do we have? Just stuff. Use what you expect from a programming language here. And obviously you have different scope. You can declare a variable within your method, or you can declare a variable within the class. If you declare a variable within some curly braces, then that's the scope of the variable, basically. In.net, when you do int or bar, they're actually just aliases to system.string. I don't know how to get this, is it? Yeah, probably. They're just aliases to the underlying system classes. So they're just there really as a convenience to make code easier to read. But we always use the aliases for the common types. Int, bool, string, float, all that sort of thing. It's important to remember that C sharp is a typesade language. These are types underneath. And then you have nullable types and non-nullable types and so on and so forth. So in question mark would be a nullable ints and things like that. Okay? And then in the way that inheritance is done in C sharp is with a, you know, so it's an object-orientated language, object-orientated typesafe language. So the way inheritance is done is you declare a class, say food. You then declare your base class. It's quite a nice, you know, short syntax. You just do colon food rather than, I can't remember what it is in Java. It's been, gosh. Anyway, yeah. Extend. Okay. And then what always makes me pause for thought is how you do constructors in C sharp. Cos you don't do the constructor and then do this bracket the constructor. You call the base constructor from your other constructor. So it's, again, it's a bit weird at first but once you've got used to it, you get used to it. So here in this example here I've got broccoli and, broccoli and chocolate are specialist types of the food class. And what I've got a method on food called eat. Now in C sharp you have to declare a method as virtual if you want it to be able to be overridden. You don't get that magically. You have to say, yes, I intend this to be overridden by an implementing class. And then, so I've declared that as virtual. And then food, chocolate doesn't override so when you call eat it goes nom nom. But then if you call eat on broccoli it throws an invalid operation exception cos he wants to do that. Now in notice as well you see sharp exceptions of run time exceptions and when you throw them and then you have that you can have specific try catch finally blocks but you generally don't declare, you know, not in Ling and Java you have throws invalid operation exception. You generally don't do run time exceptions in C sharp. Okay. Make sure I've covered everything, Ryan. We've done, we've whipped through. We're doing great. Inheritance polymorphism, okay, let's go. And then blah blah blah operators. Oh, here's a neat thing in C sharp. So you can do... Yeah, we do that. Okay. I'll just show you this now, I remember. So I'd say if you want to do... We've got hello, Renault. We can have, you know, string name equals run nom. And then, so, well, let's do it the way out. Let's do it the short way first. So we can do hello, Renault, like that. Then if we want to make a variable called Renault that passes the name in equals Renault. C sharp has... uses string formatters quite a lot. So by a string formatter, I mean string.formats blah. You know, you have this in other languages where you pass like a format string in and you can do some stuff. You can tell it you want it to be a decimal number or whatever. And it can do substitution for you. How we do that... We have that in C sharp, but we have some nice syntax for that. So I can say hello and I want to substitute in something. And then I can pass my variable in and then I can pass as many of these as I want. And each one of these is a positional indicator within that string. So the first one, the second one, well, the zero for one, the first one, the second one, you know, because it's an array of objects you're passing in. So that works. Sorry, I've done that wrong. So that... My keyboard doesn't seem to be typing. There we go. So that works as a substitution of a variable and that would execute. In C sharp 6, here we go. C sharp 6 feature. And they introduced a way of getting it to evaluate strings. So I could actually do dollar and then name here. And it actually... That should work. Oh, I probably have to declare my variable first. Well, in fact, why not just do dollar... args... Wow, I'd have a giant... No, one of these works. arg zero. So I'm going to pass in to my hello. The first thing I'm going to pass in to my command line. And I'm just going to come up here.net run... Let's do dev.conf instead. See if it goes horribly wrong. I appear to have forgotten how to type today. Wow, it's been moved, though. Hey, look at that. Magic. So that's just some neat... And that's just syntactic sugar that I've added in C sharp 6, but it's nice. Make sure code eats shorter and easier to read. Okay. Collections. You have proper generics in C sharp. So you can do, you know, a list of string... a list of type string. And then you can actually go and declare a bunch of strings now, if you wanted to. Yeah. So I'm doing it. I'm building a generic collection. So that way now when I go to... And in you have... So you've got the usual do while loops and all those standard loops you used to. There's a corn as well for each. So for each word in... So I can say for each word in list. And it's clever enough to know that list is now a string that compiler is. So if I do list.index... index of... because it knows that list is a string... Oh no, sorry, word. Index of... because it's saying over the enumeration, over the collection of lists, over the enumeration of lists, give me all the word... give me every element of that collection and put it into a variable called word. Now when I say var word, that's the same as me saying string word. Both of those things would still compile. But I can't be bothered remembering what everything is. So I'm just going to type var in and let the compiler work out what the actual type is. And that's worked out at a compile time. So it's not... That's not an example of dynamic languages there. That's a duck type and that's the compiler turning it into a real type at compile time. So that now gives me a variable called word for every item of the list and then does that loop for every item of that list. So I can just do word... I just do... Yeah, let's just do this. Console. Right line. OK, so while that's running, I'll go and just check and make sure I've covered off all the stuff we wanted to cover. Blah, blah, blah, control flow. And you can come back and if you want to get into more in depth, you can. OK, great. Yep, and I've done... Again, if you want to do some of these while I'm in the room, feel free. But I've done little exercises to practice and stuff. So feel free to just go and do those if you want to learn a bit more. The thing that's... So four inches nice, OK, great. Apart from that, what else has C-Shot got from me, OK? I quite like the way it does properties. So you know in... Oh, sorry. You know in... You know when you're building a plain old, you know, like a plain old class. A plain old C-Shot object. You do the whole, you know, public class person and then you do, like, private string first name and then you do public string getName getPerson, which returns person and then you do all that just stuff that you just have to do and you use resharp or use IntelliJ if you've got any sense to write that code for you because it's just always a boilerplate code you don't want to write. Well, in C-Sharp has some cool syntax to actually stock you from having to do that. So if I... I'm just going to jump in and show you this rather than you don't need to see me type it. Oh, yeah, look, that worked. Did that work? Right, okay. If I go to... So I'll show you the person class because there's some neat stuff. So this is the answer to the fourth of the exercises. So there you go. Spoiler alert. But if I'm defining a class called person, for when I'm defining my properties, I can just say public string is the name of the property and then the fact that I want a getter and a setter and it'll generate them for me. It'll generate the private and it'll generate the get and set for me as well. So I don't need to do that. Equally, if I just wanted it to be a read-only property, so I just want to be able to... like age, I want it to be read-only, I could just say get semicolon with no set and it would have no corresponding setter method. The way that you call those properties in code is you would say person, person equals new person as you do, you know? You can actually speed that up a bit as well. When I use my Mac for non-Mac things, I use a proper keyboard rather than the Mac keyboard because my muscle memory makes me do command C rather than control C. So person, person equals new person. And then I can do things like person. You know, full name. Person. First name. And that's how you call that getter and setter. So you actually call them with a... you know, you don't have get full name you just call it as a property. And then if you want to... if you try to do that on a method, say if you try to set a property where it wasn't allowed in your definition, then you'd actually get a compile time error still. You know? Right. But what we've also shown an example of in this class here is... What I'll do is I'll execute it while it's done. Ooh, no, I need to do control C. Right. What we also can do here is... we're doing things like... we're calculating a property. So when you call a getter, it's actually doing... and this is always one of the questions that they give you in interviews. You know, how do you calculate the age of someone? If you know a trick, it's really easy. Dates and getting wrong because it's only, you know, wanting to return 21 during a year or whatever. There's the age. And then, so that's calculated property. You can cache properties if you want. So here we have an example of a user ID which is stored in private storage. When I get it, if one doesn't exist already, if it's null or whitespace, there's handy little methods for all that sort of stuff, then it will lazily generate one. It will calculate one. So here it's calculating it to be, you know, M, wood, wood, 76 or whatever. And then it's returning it. But if you've explicitly set it, then you can override the name. So... But in this example with age, I'm not lazily... I'm not caching my value of age because age you want to always calculate because you might have got older. You know, you might have called... the last time you called age might have been after the object was created or whatever. So you need to calculate that out of time. And then similarly, a ball which identifies if you're an adult. Does that there? And then dot net run. And then just quickly some other cool syntactic sugar that you have in T-Shop. That's how you... We showed you already. That's how you create a list of... That's how I'm creating a list and instantiating it with values, with objects in the same bit of syntax. You know, all that's quite easy to do. And it looks, when it's not so big, it looks neat, you know what I mean? Nice. Nice easy to read language. Okay. And there we go. So that's the calculated door there. And then you've got Bob Microsoft. And that's his user ID and his AOL style. So cool. Right, properties syntax is nice. That's one of the things I love. And then again, you've got a bunch of stuff here about different things you can do with properties. Right, here we go. Delegates and lambda expressions. Right. So the syntax I want to get you to is this syntax here. So here I have a collection of numbers. And what I'm doing is I'm defining out... I'm evaluating if I is even or not. And then I'm using that to give me the number out of a collection. So I'm finding all of the elements of this collection which match that particular criteria. When I first... So I did... I was a Java guy. I was a VB guy originally. Then I did Java. Then I did C sharp in like C sharp 1, 1.1 and 2. You know, 2 of generics was like, ooh, that's new, because I'm from the Java and we didn't really have problem with generics yet. And I was never allowed to use Java 5 and then... So it was all a bit, ooh, that's a bit advanced. And then I went back into Java world for 10 years while working for Microsoft in my app for five of those years. And then I came back to C sharp and everything after C sharp 2 is all a bit new. And I opened up some code and I see that syntax. I'm like, oh, am I even C? What's going on in here? I don't understand it. So it's actually quite easy and if you already get this then great. But it took me a while to figure it out. So basically you have the ability in C sharp to have delegates. So I can say, I can define a method. So here we go, public static reverse string. And I can set my delegate type called reverse. I can define it and point it at a method which implements that signature. So there we go. I've got reverse string which is implementing... You pass me a string, I return you a string and I've got a thing called delegate where it's basically give me anything which implements... Give it a string and get back a string. So this is an interface. So I can have anything to implement that particular method signature. So that's what a delegate is and then you do it and it reverses the string. Awesome. You actually call it like a method. The delegate. And then there's a bunch of helper functions to save you having to create strongly typed delegates the whole time. They have a bunch of generic delegate helpers, action function and predicate. And basically if we do like a function one there this is a delegate that does something. So it takes a string so it takes a string, it returns a string and then that's me defining it there as a delegate. And then you can also do that anonymously using this syntax here. So you can actually define... Remember I was doing list and ended an open curly brace and actually defined my list as I was doing it. That's actually using an anonymous delegate and I'm here, I'm... Sorry, I'm not the most anonymous type. Here I'm coming in and I'm defining a delegate anonymously and so I'm defining that. I'm saying it's a delegate pass in a number and then returns a number. All a lambda expression is is this here with a syntax. So all is just syntactical sugar around defining anonymous in a delegates. So you say I'm taking in I and then I am doing something with it. I'm going to return back to you a Boolean because of what I do except. I'm going to return back to you a Boolean which is the result of evaluating I divided by 2 equals 0. Equals equals 0 is a Boolean test for equality in T-Shop not an assignment. So does I divide by 2 equals 0? If it does then that's what you want to return back a value of for when you pass in I. It's exactly the same that gets compiled down into exactly the same piece of code as that. But it's a lot easier to read it's you know short so maybe not easy to read but it's short and you do get used to them. I know you can do cool stuff with them. You can also do as well as functional ones you also have statement so I'm actually coming in here and I'm executing two commands as part of my delegate so I'm doing I'm passing in a string and I'm going to format the string with hello something and I'm going to write out so now when I call my delegate passing in Alice it says hello Alice so it's pretty cool and it's a great way of confusing your friends and writing some very terse syntax methods and things and passing around but it's also really handy with APIs because you cannot start to build a bunch of APIs now where you don't need call back handlers you just pass in the code which does it which makes it significantly easier to read when you're calling an API that needs a callback and in the windows world there are lots of APIs that need callbacks because it's a UI paradigm but also there are lots of APIs that need callbacks because we have a lot of asynchronous programming in server side C sharp as well right next neat thing link language into great query when I saw this when I came back to C sharp well I was like what the what because what you do is you look at your code and it's like somebody wrote some sequel backwards in your C sharp program that means the select clause is at the end so it's select new link expert from programmers where programmers dot is new to link is set to is set to one that's interesting I'm turning you into a link expert so the reason why it selects at the end is because the compiler and to do auto completed things needs to know what P is before it can give you auto complete on the select part so that's why they're kind of reverse it so apart from that it's fine that is just syntactical sugar over the API syntax which actually I find a lot easier to use myself personally because it looks like actual code so where P is new to link and then that's the same that's what this gets converted into these method calls these method calls when you these get there's a feature in C sharp extension method so you can add methods to things to all the classes and when you call the system when you add system.link into your class then on to anything which implements I and U variable it adds these link methods like where, select and port-a-bye things, yeah what's the type of what? what's the type of what? what's the type of what? what's the type of what? in that case yeah it's always hard to work out link experts would be what's evaluated so it would be a new link expert where, yeah from, it would be a new link expert class so yeah it's what it would be it's a list of link expert, thank you, yeah there you go and then there we go and you can use lambda expressions the reasons why it's quite handy as well is you can use link syntax over anything which implements the I U variable so an array or whatever or a list of collection but also APIs can return objects which are complicated and do lots of crazy stuff but also implement I and U variable so they can optimise when they make server calls and network and all sorts of things but you can write the same bit of code which just does data type operations over some data regardless of if it's a database or a API or or just a collection in memory and then we have an example of here this is the example that's in the tutorial in the exercises the one time I will use the query syntax is when I'm using the let keyword and that actually it's easier to read it in query syntax what the intention of the code is but I'm saying from my sentence from my collection of strings give me a sentence and then split the sentence down into words so give me a thing called sentence which is from my strings split it into words now you know you're doing some hacking when you're just off split that's like string tokeniser in Java you know you're hacking when you're just that class off so anyway string dot split on space give me a word and then from that collection of words give me a word and set so w to be word to be a lowercase word and then give me everything where the first character of the word is a vowel so that actually you can read what that's doing fairly well now as you can tell it's very easy to very quickly write some a lot of code here because you're writing a lot of stuff by doing this and depending on the API you're calling it can perform terribly as well so you have to be careful about what you're actually doing but you can do it and it's very easy to read and very to us okay so I'm going to do this so I'm going to do this so I'm going to do this okay blah blah blah and then in the exercise it's got some other it's got all the type of stuff you kind of do with data you know like unions and joins and order buys and all that sort of stuff you can do all that stuff which actually becomes really handy when you get you've got a collection of things and you just want to reverse it you can just do an order buy on it order by descending or whatever and that's the best way of working with collections of stuff regardless of where they've come from and then I don't we don't cover it in the exercise in the tutorial but there's a thing called peeling so if you do or click if you do as parallel it's part of the core so here it'll actually split off the the methods you know it'll actually parallelise if there's as much as it can and pull back the results and try and do it in parallel execution it's great for doing stuff where you want to parallelise where what you're doing has no side effects on pulling data together but if you actually want to do it and go affect things in parallel then there is a parallel task library it's called news which actually helps you do that but it's built into the language if you just want to go pull data together because you can do that safely quite easily okay right asynchronous programming and then we're nearly there so again this was the other new thing which a lot of the APIs now in .NET asynchronous APIs because asynchronous is good if you want to return back to the UI thread but also in the server the more asynchronous you are the more scalable your solution is you're not tying up a thread with handling your request when you use the asynchronous keyword the framework manages all your thread pooling and thread allocation for you and thread state for you and so if you're in a bit and it's not doing anything it goes down into the operating system and signals an interrupt set it to come back when it's ready and then it carries on execution inside of its application and does some stuff and then when the operating system comes back and says yeah I'm ready then it goes to there and reimbokes things so it's a way of doing great parallelisation but in terms of like a really low level down at the OS doing interrupt based parallelisation actually in the language it's really straightforward to use so I'll give you the example I'll show you here's an example of doing it so this is really useful if you're doing any IO operation any significant IO operation mostly when we're writing cloud applications every IO operation is a significant IO operation because you might just disappear or whatever so you tend to use this a lot nowadays so here we have an example where I'm calling HTTP client and I'm running a task I'll show you this in text here so I'm doing await HTTP client get string asynchronously and return back the content of that web page to string and then I'm doing a match on HTTP how many times it finds the word .NET in the .NET foundation web page using period net rather than .NET so yeah and then if you want to do that's an example of the console application version of it where I'm actually where I'm a static rather than a wait now the way that the one thing I want to show you I'll show you the exercise actually because I think that demonstrates it better so if I go into I'll give you some sample code here but let's just bring it up and then that's probably enough and I could show you ASP so sorry wait system there we are okay CD pins really is there I'll show you the sample code basically what I'm doing here is I've got some sample code one that does a slow operation and one that does a fast operation and then I'm going to try and here we go so I'm going to try and call the slow operation asynchronously bring up the code when you see it you call the slow operation first and then you call the fast operation and then you see that the fast operation is dumping out to the console while the slow operation is in a sleep state and the slow operation and then the fast operation finishes first the slow operation finishes and then the program holds execution at the point where you're waiting for the result of the slow operation if I could just show you the code either way I'll show you the code let's just show you on GitHub so exercise 3 so here's my do something class where I'm saying it's an asynchronous operation I've got a delay so I'm waiting 100 and then in my for loop I'm just dumping out to the console so here in my program class is a say run my slow task and you actually see it kicking off the slow task it gets to a point where it sees that it's waiting for something whatever type of operation it's waiting for and then does carries and then returns operation back into your fast class runs it and then you get the slow task then the fast task sorry you see the fast task running it holds here because you're saying you're saying I would like the result of slow task now please and then that point is where it actually holds it because you're waiting for it and then it'll carry on going but all that magic of thread thingy in the marion to say it's all taken care of for you with that really really cool syntax and then the final thing I'll show you just quickly as we head out the door I'll just do it in here as I'm in here is the way the ASP network so if I do now I'm going to jump back to the alt so we're doing this .NET command which is actually fairly new I'm going to do I'm going to do a new type of syntax but I'm just going to generate my ASP net site first of all so Yo ASPNet using Yoamun to just quickly generate a template one what kind of ASPNet application do you want I want a simple I want a big web application with login and everything as if I'm going to build a website for the conference what's the name of it devconf and then it's done it there and then if I just do cd devconf open it up and while that's doing it stuff while that's doing it stuff put that there I'm just doing this in here as well because my VM seems to have started hanging so this is an ASPNet site and again in the tutorial I kind of well actually don't I will explain more about it but I've got one to go up which explains more but you come in and you've got the controller code but also you've got say the view this is a model view controllers tile application so let's do and then to run it you just do dnx web but a web application in the new world basically just the console application still if I go to start up cs you'll actually see there is the public static void main class where it's kicking off a web application and running it so there's a web server called kestor and it's just the main method yes sir you can create a library which you can take between the two called a portal class you can create a new get package that has all the different framework versions in it and then that works and in terms of ASD net applications you can build an ASD net core application and have it run in the RIAX in top of .NET full framework as well as running in .NET core so can I take existing application which is working with the .NET framework and just put it to .NET core and run it? no this is the short answer usually so .NET core is we've made much more modular libraries so we're in Q&A time now we've got a portal you need to rebuild it there's probably going to be some refacturing of it as well because ASP .NET core is a more modular version of .NET so it used to be when you installed .NET in a box it came with everything all the threading everything and system.drawing which is used to draw to the UI everything it was there and people would use everything now with .NET core it's much more modular so you have to use the modules and then use that opportunity to break actually parts of .NET down into more modules so some things have moved a little bit there's a tool called API port on github so you can analyse your application for it so you can take the idea so maybe you should answer the question so the APIs are the APIs most of the APIs are there but there are things that have moved so some things have moved things like threading have moved the way that it handles application domains has completely changed so those sorts of areas but if you're just doing standard stuff system.link all that stuff is exactly the same but when it comes to doing about 90 normally when you run the analyse for your application you find about 95-90% of your application's work is going to work and it shows you which bits are and you can go up with those the worst thing is all these dependencies because you never build an application in greenfield you've got to have a library, have a .NET core version and so one of my jobs and I'm out of time is to go and actually work with all the different open source library vendors and get them to or open source projects and help them have a core version as well. Thank you and then any more questions I'll be outside so thank you just remind you you can vote for lighting costs in front of the 105 and anyone's got a follow up I'm going to be here till Monday morning but I'm here all day today and all day tomorrow so come grab me we'll have some beers tonight as well and thank you very much for your time thank you the only Microsoft workflow is they're not against it but if you want to do their focus in Microsoft for a minute is on the server side stuff so if you want yes they're not working on it it's low down network so I would use mono if you want to do any of that stuff the .NET core stuff though is incredibly performance so if you can use .NET core then use it because it's amazing for Microsoft no worries yeah no I would not for .NET core yet so to do that you have to use mine because that's still ah okay yeah it's awesome yeah that's brilliant and also things like the async APIs and stuff they really help building UI applications because you don't want to tie up the UI for everyone that stuff thanks for coming thank you I'll get out of your way sorry sir there you go do you think we had in you did you see it was definitely full wasn't it I didn't think it was full oh yeah that's great oh thank you I hadn't realized so many people wouldn't know I'm such a worry and you know how should it be more of a bad stuff and less of a bad ah tak toh ja sy'n fiedd popise'ch chewi'n maith rastafennu kebyn ni'n ceo efo ma'n bys o'n sgwstio'r sgwstio'r server ychwaned ychwaned erioed o'n llag wad mae'n bwys o'r reisio'r reisio'r llig i'r reisio a'i mas gwrth ac yn gywed hynny'n fawr a'i fawr o'r perdd. ni'n cerddiaeth ha Daherdn ni? mae'n ei ddam yn 15 munud o gyllud mae'n 100 munud mae'n du ingredients Mae gyda siwtio'r nastafu oherwydd dyna hwn. A allaeth oherwydd dyna datblygu llawer oherwydd hyn ny'n ddechrau. Echyd yn rywbeth i wneud. Oherwydd unrhyw ychydig, oherwydd mae'n i'n gael yn eich ddechrau. Nodd buch o'r uch. Gwyborddi. mor eich wneud ychwanegu, mae'r cyffreddau a'r cyffreddau. Mae'r cyffreddau eich wneud ychwanegu, a'n ffrwng.