SlideShare ist ein Scribd-Unternehmen logo
1 von 21
C# Today &
Tomorrow
http://stackoverflow.com/research/developer-survey-2015
http://stackoverflow.com/research/developer-survey-2015
http://stackoverflow.com/research/developer-survey-2015
Changing our tune…
Run on Windows
.NET as system component
Run on VM (CLR)
Black box compilers
Edit in Visual Studio
Proprietary
Run everywhere
Deploy with app
Compile to native
Open compiler APIs
Use your favorite editor
Open source
Project Roslyn
“Let’s rewrite the C# and VB compilers and IDE
from scratch!”
• Evolve
• Enable
• Dogfood
The compiler/IDE dichotomy
Compiler
Batch
Throughput
Correctness
Prevent badness
Reactive to what you did
IDE
Incremental
Responsiveness
Error tolerance
Enable goodness
Predictive of what you will do
The Roslyn Compiler API
There should only need to be
one code base in the world
for understanding C#
Other IDEs On other platforms
Custom diagnostics Style, API usage, patterns…
Source transformation Refactorings, fixers, migraters, updaters…
Scripting Batch scripts, hosted code…
Coding in execution REPL, edit-and-continue…
Documentation Hyperlinked API docs, web playgrounds…
Static analysis Code metrics, graphs, telemetry, code querying…
Metaprogramming Source generators, injectors, weavers…
Other language understanding scenarios
Custom analyzers and fixes
Plug in to diagnostic reporting and code fixing
infrastructure
Batch and interactive
“Code-aware libraries”
APIs can ship with analyzers and fixes to guide their users
Toolboxes
Style enforcement, discovery of opportunities
Language evolution explained
Stagnation
C#
Evolution of C#
C# 1
Hello World
C# 2
Generics
C# 3
Queries,
Lambdas
C# 4
Dynamic,
Concurrency
C# 5
Async
C# 6
Avoid
boilerplate
C# 7
???
Demo: REPL and C# 6
C# “7”
Pattern matching
if (o is Point p) { WriteLine($"({p.X}, {p.Y})"); }
if (o is Point p && p.X == 5) { WriteLine($"Y: {p.Y}"); }
if (o is Point(5, var y)) { WriteLine($"Y: {y}"); }
Patterns in switch statements
switch (o)
{
case int i:
WriteLine($"Number {i}");
break;
case Point(int x, int y):
WriteLine($"({x},{y})");
break;
case string s when s.Length > 0:
WriteLine(s);
break;
case null:
WriteLine("<null>");
break;
default:
WriteLine("<other>");
break;
}
Tuples
public (int sum, int count) Tally(IEnumerable<int> values)
{
var s = 0; var c = 0;
foreach (var value in values) { s += value; c++; }
return (s, c);
}
var t = Tally(myValues);
Console.WriteLine($"Sum: {t.sum}, count: {t.count}");
(var s, var c) = Tally(myValues);
Console.WriteLine($"Sum: {s}, count: {c}");
Records
class Person : IEquatable<Person>
{
public string First { get; }
public string Last { get; }
public Person(string First, string Last) { this.First = First; this.Last = Last; }
public (string First, string Last) Deconstruct() => (First, Last);
public bool Equals(Person other) => First == other.First && Last == other.Last;
public override bool Equals(object obj) => obj is Person other ? Equals(other) : false;
public override int GetHashCode() => GreatHashFunction(First, Last);
…
}
class Person(string First, string Last);
Creating immutable objects
var p1 = new Point { X = 3, Y = 7 };
var p2 = p1 with { X = -p1.X };
Nullable and non-nullable reference types
string? n; // Nullable reference type
string s; // Non-nullable reference type
n = null; // Sure; it's nullable
s = null; // Warning! Shouldn’t be null!
s = n; // Warning! Really!
WriteLine(s.Length); // Sure; it’s not null
WriteLine(n.Length); // Warning! Could be null!
if (n != null) { WriteLine(n.Length); } // Sure; you checked
WriteLine(n!.Length); // Ok, if you insist!
?

Weitere ähnliche Inhalte

Was ist angesagt?

2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - english2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - englishJen Yee Hong
 
Basic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmersBasic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmersJen Yee Hong
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scalaRuslan Shevchenko
 
DaNode - A home made web server in D
DaNode - A home made web server in DDaNode - A home made web server in D
DaNode - A home made web server in DAndrei Alexandrescu
 
F#语言对异步程序设计的支持
F#语言对异步程序设计的支持F#语言对异步程序设计的支持
F#语言对异步程序设计的支持jeffz
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate CompilersFunctional Thursday
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronouskang taehun
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)Olve Maudal
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17LogeekNightUkraine
 
C Sharp Lecture Johan Franzen
C Sharp Lecture  Johan FranzenC Sharp Lecture  Johan Franzen
C Sharp Lecture Johan Franzeng_hemanth17
 
DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright Andrei Alexandrescu
 
Keep It Simple Security (Symfony cafe 28-01-2016)
Keep It Simple Security (Symfony cafe 28-01-2016)Keep It Simple Security (Symfony cafe 28-01-2016)
Keep It Simple Security (Symfony cafe 28-01-2016)Oleg Zinchenko
 
Connecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with EmbindConnecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with EmbindChad Austin
 
Emscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math opsEmscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math opsLuka Zakrajšek
 

Was ist angesagt? (20)

MFC Message Handling
MFC Message HandlingMFC Message Handling
MFC Message Handling
 
Let's Go-lang
Let's Go-langLet's Go-lang
Let's Go-lang
 
2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - english2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - english
 
Csp scala wixmeetup2016
Csp scala wixmeetup2016Csp scala wixmeetup2016
Csp scala wixmeetup2016
 
Basic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmersBasic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmers
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
 
DaNode - A home made web server in D
DaNode - A home made web server in DDaNode - A home made web server in D
DaNode - A home made web server in D
 
F#语言对异步程序设计的支持
F#语言对异步程序设计的支持F#语言对异步程序设计的支持
F#语言对异步程序设计的支持
 
Oro meetup #4
Oro meetup #4Oro meetup #4
Oro meetup #4
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronous
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
 
C Sharp Lecture Johan Franzen
C Sharp Lecture  Johan FranzenC Sharp Lecture  Johan Franzen
C Sharp Lecture Johan Franzen
 
DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright
 
Keep It Simple Security (Symfony cafe 28-01-2016)
Keep It Simple Security (Symfony cafe 28-01-2016)Keep It Simple Security (Symfony cafe 28-01-2016)
Keep It Simple Security (Symfony cafe 28-01-2016)
 
P2
P2P2
P2
 
Connecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with EmbindConnecting C++ and JavaScript on the Web with Embind
Connecting C++ and JavaScript on the Web with Embind
 
Emscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math opsEmscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math ops
 
Typescript is the best
Typescript is the bestTypescript is the best
Typescript is the best
 

Ähnlich wie C# Today and Tomorrow

(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...Phil Calçado
 
C# What's next? (7.x and 8.0)
C# What's next? (7.x and 8.0)C# What's next? (7.x and 8.0)
C# What's next? (7.x and 8.0)Christian Nagel
 
Dr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slidesDr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slidesDr-archana-dhawan-bajaj
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chhom Karath
 
Functional Principles for OO Developers
Functional Principles for OO DevelopersFunctional Principles for OO Developers
Functional Principles for OO Developersjessitron
 
Kotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsKotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsJigar Gosar
 
C# 7.x What's new and what's coming with C# 8
C# 7.x What's new and what's coming with C# 8C# 7.x What's new and what's coming with C# 8
C# 7.x What's new and what's coming with C# 8Christian Nagel
 
Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practicesIwan van der Kleijn
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기경주 전
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...Sang Don Kim
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Abou Bakr Ashraf
 
Roslyn and C# 6.0 New Features
Roslyn and C# 6.0 New FeaturesRoslyn and C# 6.0 New Features
Roslyn and C# 6.0 New FeaturesMichael Step
 
IntroToCSharpcode.ppt
IntroToCSharpcode.pptIntroToCSharpcode.ppt
IntroToCSharpcode.pptpsundarau
 

Ähnlich wie C# Today and Tomorrow (20)

Effective Object Oriented Design in Cpp
Effective Object Oriented Design in CppEffective Object Oriented Design in Cpp
Effective Object Oriented Design in Cpp
 
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
 
C# What's next? (7.x and 8.0)
C# What's next? (7.x and 8.0)C# What's next? (7.x and 8.0)
C# What's next? (7.x and 8.0)
 
Dr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slidesDr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slides
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
XAML/C# to HTML/JS
XAML/C# to HTML/JSXAML/C# to HTML/JS
XAML/C# to HTML/JS
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chapter i c#(console application and programming)
Chapter i c#(console application and programming)
 
Novidades do c# 7 e 8
Novidades do c# 7 e 8Novidades do c# 7 e 8
Novidades do c# 7 e 8
 
Functional Principles for OO Developers
Functional Principles for OO DevelopersFunctional Principles for OO Developers
Functional Principles for OO Developers
 
Kotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsKotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrains
 
C# 7.x What's new and what's coming with C# 8
C# 7.x What's new and what's coming with C# 8C# 7.x What's new and what's coming with C# 8
C# 7.x What's new and what's coming with C# 8
 
Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practices
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
 
Dr archana dhawan bajaj - c# dot net
Dr archana dhawan bajaj - c# dot netDr archana dhawan bajaj - c# dot net
Dr archana dhawan bajaj - c# dot net
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
Visula C# Programming Lecture 2
Visula C# Programming Lecture 2Visula C# Programming Lecture 2
Visula C# Programming Lecture 2
 
Roslyn and C# 6.0 New Features
Roslyn and C# 6.0 New FeaturesRoslyn and C# 6.0 New Features
Roslyn and C# 6.0 New Features
 
IntroToCSharpcode.ppt
IntroToCSharpcode.pptIntroToCSharpcode.ppt
IntroToCSharpcode.ppt
 

Mehr von Bertrand Le Roy

Orchard 2... and why you should care
Orchard 2... and why you should careOrchard 2... and why you should care
Orchard 2... and why you should careBertrand Le Roy
 
Orchard Harvest Keynote 2015 - the CMS of the future
Orchard Harvest Keynote 2015 - the CMS of the futureOrchard Harvest Keynote 2015 - the CMS of the future
Orchard Harvest Keynote 2015 - the CMS of the futureBertrand Le Roy
 
Best kept Orchard recipes - Orchard Harvest Amsterdam 2013
Best kept Orchard recipes - Orchard Harvest Amsterdam 2013Best kept Orchard recipes - Orchard Harvest Amsterdam 2013
Best kept Orchard recipes - Orchard Harvest Amsterdam 2013Bertrand Le Roy
 
Commerce - Orchard Harvest Amsterdam 2013
Commerce - Orchard Harvest Amsterdam 2013Commerce - Orchard Harvest Amsterdam 2013
Commerce - Orchard Harvest Amsterdam 2013Bertrand Le Roy
 
Orchard Harvest Amsterdam 2013 Keynote
Orchard Harvest Amsterdam 2013 KeynoteOrchard Harvest Amsterdam 2013 Keynote
Orchard Harvest Amsterdam 2013 KeynoteBertrand Le Roy
 

Mehr von Bertrand Le Roy (7)

Next .NET and C#
Next .NET and C#Next .NET and C#
Next .NET and C#
 
Orchard 2... and why you should care
Orchard 2... and why you should careOrchard 2... and why you should care
Orchard 2... and why you should care
 
.Net Core
.Net Core.Net Core
.Net Core
 
Orchard Harvest Keynote 2015 - the CMS of the future
Orchard Harvest Keynote 2015 - the CMS of the futureOrchard Harvest Keynote 2015 - the CMS of the future
Orchard Harvest Keynote 2015 - the CMS of the future
 
Best kept Orchard recipes - Orchard Harvest Amsterdam 2013
Best kept Orchard recipes - Orchard Harvest Amsterdam 2013Best kept Orchard recipes - Orchard Harvest Amsterdam 2013
Best kept Orchard recipes - Orchard Harvest Amsterdam 2013
 
Commerce - Orchard Harvest Amsterdam 2013
Commerce - Orchard Harvest Amsterdam 2013Commerce - Orchard Harvest Amsterdam 2013
Commerce - Orchard Harvest Amsterdam 2013
 
Orchard Harvest Amsterdam 2013 Keynote
Orchard Harvest Amsterdam 2013 KeynoteOrchard Harvest Amsterdam 2013 Keynote
Orchard Harvest Amsterdam 2013 Keynote
 

Kürzlich hochgeladen

Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086anil_gaur
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 

Kürzlich hochgeladen (20)

Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 

C# Today and Tomorrow

  • 5. Changing our tune… Run on Windows .NET as system component Run on VM (CLR) Black box compilers Edit in Visual Studio Proprietary Run everywhere Deploy with app Compile to native Open compiler APIs Use your favorite editor Open source
  • 6. Project Roslyn “Let’s rewrite the C# and VB compilers and IDE from scratch!” • Evolve • Enable • Dogfood
  • 7. The compiler/IDE dichotomy Compiler Batch Throughput Correctness Prevent badness Reactive to what you did IDE Incremental Responsiveness Error tolerance Enable goodness Predictive of what you will do
  • 8. The Roslyn Compiler API There should only need to be one code base in the world for understanding C#
  • 9. Other IDEs On other platforms Custom diagnostics Style, API usage, patterns… Source transformation Refactorings, fixers, migraters, updaters… Scripting Batch scripts, hosted code… Coding in execution REPL, edit-and-continue… Documentation Hyperlinked API docs, web playgrounds… Static analysis Code metrics, graphs, telemetry, code querying… Metaprogramming Source generators, injectors, weavers… Other language understanding scenarios
  • 10. Custom analyzers and fixes Plug in to diagnostic reporting and code fixing infrastructure Batch and interactive “Code-aware libraries” APIs can ship with analyzers and fixes to guide their users Toolboxes Style enforcement, discovery of opportunities
  • 12. Evolution of C# C# 1 Hello World C# 2 Generics C# 3 Queries, Lambdas C# 4 Dynamic, Concurrency C# 5 Async C# 6 Avoid boilerplate C# 7 ???
  • 15. Pattern matching if (o is Point p) { WriteLine($"({p.X}, {p.Y})"); } if (o is Point p && p.X == 5) { WriteLine($"Y: {p.Y}"); } if (o is Point(5, var y)) { WriteLine($"Y: {y}"); }
  • 16. Patterns in switch statements switch (o) { case int i: WriteLine($"Number {i}"); break; case Point(int x, int y): WriteLine($"({x},{y})"); break; case string s when s.Length > 0: WriteLine(s); break; case null: WriteLine("<null>"); break; default: WriteLine("<other>"); break; }
  • 17. Tuples public (int sum, int count) Tally(IEnumerable<int> values) { var s = 0; var c = 0; foreach (var value in values) { s += value; c++; } return (s, c); } var t = Tally(myValues); Console.WriteLine($"Sum: {t.sum}, count: {t.count}"); (var s, var c) = Tally(myValues); Console.WriteLine($"Sum: {s}, count: {c}");
  • 18. Records class Person : IEquatable<Person> { public string First { get; } public string Last { get; } public Person(string First, string Last) { this.First = First; this.Last = Last; } public (string First, string Last) Deconstruct() => (First, Last); public bool Equals(Person other) => First == other.First && Last == other.Last; public override bool Equals(object obj) => obj is Person other ? Equals(other) : false; public override int GetHashCode() => GreatHashFunction(First, Last); … } class Person(string First, string Last);
  • 19. Creating immutable objects var p1 = new Point { X = 3, Y = 7 }; var p2 = p1 with { X = -p1.X };
  • 20. Nullable and non-nullable reference types string? n; // Nullable reference type string s; // Non-nullable reference type n = null; // Sure; it's nullable s = null; // Warning! Shouldn’t be null! s = n; // Warning! Really! WriteLine(s.Length); // Sure; it’s not null WriteLine(n.Length); // Warning! Could be null! if (n != null) { WriteLine(n.Length); } // Sure; you checked WriteLine(n!.Length); // Ok, if you insist!
  • 21. ?

Hinweis der Redaktion

  1. Evolve: it’s now easier to evolve the languages Enable: it enables a whole ecosystem of code analysis, refactoring tools, and tools that act on code Dogfood: we can roll out new language features and tooling to early adopters for feedback without having to ship VS or compilers
  2. Pace of innovation is not necessarily whenever you get an idea. There’s such a thing as an innovation that comes too soon. The evolution comparison is also interesting because it’s the environment that drives innovation, not random mutations. Horseshoe crab picture by Didier Descouens (Own work) [CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons Saddleback caterpillar picture by Mary Keim https://www.flickr.com/photos/38514062@N03/9410316517/in/photolist-fkykfv-fkyk58-fpYfpv https://creativecommons.org/licenses/by-nc-sa/2.0/
  3. Launch VS, open REPL (view/other windows/c# interactive) 2+2, Console.WriteLine(“Hello SpaceX”) – Remember, Alt+up arrow to copy a previous statement. CTRL+Enter to execute no matter where the cursor is. using static System.Console; Console.WriteLine(“Hello SpaceX”) <- Roslyn tells you what became unnecessary. Hover to see recommendation. Remove “Console” Interpolating strings should be easy: Add the $ in front of the string, and start introducing expressions: {2016} at the end of the string. Replace expression with {2015+1} Make it reusable next year by writing {DateTime.Now.Year} You can also declare variables in the REPL: var awesomeCompany = “SpaceX”; and then replace the static string. Let’s define a method now: take the previsous code and change it to: string Greeting() {return $”Hello {awesomeCompany} {DateTime.Now.Year}”;} then call Greeting() Change it to a expression-bodied function: string Greeting() => $"Hello { awesomeCompany} { DateTime.Now.Year}"; Let’s look at other C#6 features. First, auto-property initializers: public class Person { public string FirstName { get; } = "Brett"; } new Person().FirstName You can also set such properties from a constructor, which is nice as it removes the need for a private setter that you never don’t need. You can replace the property definition with public string FirstName => "Brett"; Add the following members to the class to introduce the null-coalesce operator: public string LastName { get; set; } public string Initials => FirstName?[0].ToString() + LastName?[0].ToString(); then do new Person().Initials then new Person { LastName = "Morrison" }.Initials We have a new operator that can make a lot of refactoring scenarios more robust: nameof nameof(Person) string Greeting(string awesomeCompany) => $"Hello {nameof(awesomeCompany)} { awesomeCompany } { DateTime.Now.Year }"; Refactoring is going to work inside string interpolation. Index initializers: var numbers = new Dictionary<int, string> { [1] = "One", [42] = "Forty-two“ }; numbers[42] Other C#6 features include await in catch blocks, and “when” conditions on catch.
  4. Closest current equivalent code is var p = o as Point; if (p != null) {… but that gives p too large a scope.
  5. Alternative today is to declare a small class, or have out parameters. The syntax is designed to mirror that of function arguments.
  6. String! Could have been another solution, but would have implied that non-nullable is the exception. Having string? makes nullable strings the exception, as it should have been from the start, but enforcing string without qualifiers to be non-nullable would have been far too breaking. In the end, emitting warnings for failures to check for null is a good compromise as it encourages the right behavior without breaking existing code.