class: center, middle .NET Framework & C# ---- ![:scale 10%](Microsoft_.NET_logo.png) --- # Agenda 1. .NET 1. Languages (C#/F#) 1. Why to use? 1. History --- class: center, middle Why do you use C#? C# is a dead language Microsoft... What the f***, you are using Windows laptop? ??? Things heard from other developers Microsoft is not anymore seen as a big bad company (VS Code, Typescript) --- # .NET Framework .NET Framework is a software framework developed by Microsoft. -- * It includes a large class library named __Framework Class Library__ (FCL) * Provides language interoperability * Programs written for .NET Framework execute in a software environment named __Common Language Runtime__ (CLR) * FCL and CLR together constitute .NET Framework. -- ![:scale 30%](DotNet.svg.png) ??? * More commonly used term is Base Class Library (BLC) * It is only small part of FCL * https://i.stack.imgur.com/SxbSG.jpg * CLR is an application virtual machine that provides services such as security, memory management, and exception handling. * As such, computer code written using .NET Framework is called "managed code". --- #### .NET Framework * Windows only runtime -- #### Mono Mono is an open source implementation of Microsoft's .NET Framework based on the ECMA standards for C# and the Common Language Runtime. * Win/Linux/macOs/Mobile * Xamarin * Unity * [Godot](https://godotengine.org/article/introducing-csharp-godot) -- #### .NET Core * Cross-Platform * The chosen one, which will change the future of the .NET ??? * Can't see the difference when using different frameworks * .NET got it's name because y2k and internet boom. * Unity dropped support for js-like UnityScript * Godot is a pretty popular game engine. https://github.com/collections/game-engines --- #### Problem Many different frameworks and many different versions. How can I use my code with all of the frameworks without compiling to each? ![:scale 100%](./frameworks.jpg) ??? Solution on the next slide --- #### .NET Standard Common "interface" definition for all API's. ![:scale 80%](./dotnet-tomorrow.png) --
Official Documentation: https://github.com/dotnet/standard/blob/master/docs/versions.md ??? * Repacked BCL to .NET Standard * https://msdnshared.blob.core.windows.net/media/2016/09/ * MS also fucked up a lot of things while making this happen. * And still fucked up years later * Got easier when could drop support for older version --- # How does it work? 1. .NET languages (C#, F#, VB.net, many others) compile to __.NET bytecode__ (Common Intermediate Language) -- 1. __CIL__ is then interpreted by Common Language Runtime (__CLR__), which is a virtual machine -- ![:scale 60%](./2000px-CLR_diag.svg.png) -- * JIT: [Understanding .NET Just-In-Time Compilation](https://www.telerik.com/blogs/understanding-net-just-in-time-compilation) * GC: [Understanding .NET Garbage Collection](https://www.telerik.com/blogs/understanding-net-garbage-collection) --- # Why .NET? * Open Source * Cross-Platform * Language develops fast * Can participate to the language developement from GitHub * https://github.com/dotnet/csharplang/milestone/6 * https://github.com/dotnet/csharplang/tree/master/proposals * https://github.com/dotnet/csharplang/tree/master/meetings --- C# -------- * Good general purpose programming language * Statically typed * Multi threaded * Standard Library offers almost everything you need for basic applications * Benefit: Common way to do things * Con: Lacks of open source libraries that might do things better ??? * TODO: Compare to single threaded --- C# -------- * Features: * LINQ * Generics * TPL, Async * Methods first class & Delegates * Anononymous functions, lambda (x => x * x) * Dynamics * Reflection * Syntax is good for typed language * Bad Pattern Matching is better than nothing ??? * LINQ: Language integrated query. Advanced methods for querying collections or db (e.g. map, reduce) * Generics: Create generic methods without defining specific type * Can pass and return methods like values. Delegates advanced function pointers --- F# --------------- * Functional programming language * F# is a superset of C#, so everything that C# can do F# can do * F# projects can be used from C# projects * Hope some day can have mixed projects * Features: * Type inference system * Type providers ??? * Type inference: No need to degine types, compiler does that * Providers: Uses kind a reflection to decide types * Used lots of data analytics * No need to mention VB.NET, IronPython etc. --- ### ASP.NET * ASP.NET is a good web framework * Can be simple or feature rich * Multithreaded * Fast etc. * [aspnet/benchmarks](https://github.com/aspnet/benchmarks) ??? * TODO: Why Multithreaded better than EventLoop? * Add new functionality from packages/modules * At least ASP.NET Core is fast. Not any idea if Full Framework one is. Nobody cares. ASP.NET Core Kestrel: Adventures in building a fast web server - Damian Edwards, David Fowler https://vimeo.com/172009499 --- ### IDE / Editors * Visual Studio is great IDE * VS is a piece of crap when it decides not to work * VS for Mac/Linux, IntelliJ Rider * VS Code has a good support for C# ??? When VS fucks up, only solution is to reinstall whole windows --- ### Roslyn compiler * Language can develop faster with better compiler * 3rd party scripting support as can use compiler as a service * OmniSharp * HTTP API for compiler * Used by e.g. VS Code ??? * Released 2015 * Open source --- # Cons Was a long time MS / Windows only, so lack of 3rd party support * Tooling is not as good as with Java * Lack of open source projects * Community -- Developement environment is extremely heavy * Visual Studio * SQL Server * IIS -- C# has a long histrory * Many ways to do same things ??? * Luckily IIS is not mandatory anymore. * IIS Express * Command line * SQL Server (https://github.com/Microsoft/sqlopsstudio) * Docker * Free management * VS Code --- # Version history Version|Date|Updates ---|---|---: 1.0 | 2002-02-13 | ... 2.0 | 2005-11-07 | Feature Complete 3.0 | 2006-11-06 | WPF, WCF 3.5 | 2007-11-19 | Linq, EF (ORM) 4.0 | 2010-04-12 | TPL, dynamics 4.5 | 2012-08-15 | Async 4.6 | 2015-07-20 | Roslyn ... | ... | ... 4.7.1 | 2017-10-17 | xxxx ----------------- | ------------------ | ------------------------------- Core 1.0 | 2016-06-27 | Still beta quality Core 1.1 | 2016-06-27 | Minor fixes Core 2.0 | 2017-08-14 | Real 1.0 Core 2.1 | 2018-05-30 | Performance updates ??? With the new compiler there is no need to release new versions of Framework so often, so Framework gets only minor updates. New features come with language versoin updates. Minor Framework version updates have security updates and some performance improvements. Core had lots of changes during alpha & beta. (project.json & API namig). 1.0 was still little hacky and CLI was not ready at that time. It was also late. --- # C# versions https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history Version|VS|Updates ---|---|---: C# 1.0 | Visual Studio 2002 | C# 1.1 | Visual Studio 2003 | #line, pragma, xml doc comments C# 2.0 | Visual Studio 2005 | Generics, Anonymous methods, iterators/yield, static classes C# 3.0 | Visual Studio 2008 | LINQ, Lambda Expressions, Implicit typing, Extension methods C# 4.0 | Visual Studio 2010 | dynamic, Optional parameters and named arguments C# 5.0 | Visual Studio 2012 | async/await, Caller Information, some breaking changes C# 6.0 | Visual Studio 2015 | Null-conditional operators, String Interpolation C# 7.0 | Visual Studio 2017 | Tuples, Pattern matching, Local functions --- # Future C# 8 proposals: https://github.com/dotnet/csharplang/milestone/8 * Non-Nullable reference types * Implicit delegate types * Better pattern matching * Record types --
Still missing or what would be nice to have * Language still too verbose * Type inference could be better * Pipe operator * Option type * Mixins * const / var ??? * Dictionary initializers could be more autoatic --- # Why it was good at the Dark Ages? -- * Steps ahead of the competition * Anonymous methods, typed delegates 2005-11-07 * Linq (map, filter, reduce..) 2007-11-19 * Rx 2009-11-17 * Task Parallel Library (promises) 2010-04-12 * Async (async/await) 2012-08-15 * Lots of functional style features -- * Backwards compatibility was always good * Could always use newest Framework -- * F# * Possibility to use good functional langauge -- * Cross-Platform was always coming * First with Mono and then with .NET Core ??? * Competitors: Java | Modern: Kotlin, Swift * Functional style features also common in other modern languages * F# has newer gain level of first class citizen. It seems that it is only used to test new fetures for C#. Generally one of the best modern functional programming languages. * Mono never had chance to become popular as first Microsoft hated that project and later they announcen own .NET Cross-platfom project. First announcement was like from 2012(?). --- #### Self learning material: * C# Koans: https://github.com/NotMyself/DotNetCoreKoans * LINQ Tutorial: https://github.com/Basware/LINQ-Tutorial --- #### References: * https://en.wikipedia.org/wiki/.NET_Framework * https://en.wikipedia.org/wiki/.NET_Framework_version_history * https://blogs.msdn.microsoft.com/rxteam/2010/10/28/release-notes/ * https://blog.agchapman.com/roslyn-5-years-on/ * https://en.wikipedia.org/wiki/Common_Language_Runtime * https://github.com/dotnet/roslyn * https://github.com/dotnet/csharplang * http://mattwarren.org/2017/12/19/Open-Source-.Net-3-years-later