Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext...

33
Почему только C# @serjic JetBrains

Transcript of Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext...

Page 1: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Почему только C#@serjic JetBrains

Page 2: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

.Next● .Net Core● ASP.Net vNext● Roslyn and C# 6● Xamarin and Mono● Visual Studio Community● ...

Page 3: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative
Page 4: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Declarative Imperative

&

Page 5: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Declarative / Imperative● Xml● Structure● What● Pure● DSL● Good

● C● Sequence● How● Stateful● Framework● Bad

Page 6: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Declarative / Imperative● hard to predict● hard to debug● lack expressiveness

● hard to read● error prone● verbose

intuitive, design principles,observability, etc.

Page 7: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Xaml MsBuild kProj

Page 8: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Xaml● .xaml → .g.cs + baml● xaml использует C# типы● C# использует Xaml типы● Результат - 2 прохода компилятора● Общее пространство символов

Page 9: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

А могло быть по-другому!● C# + точки расширения● Типы и методы● Xaml, C# и VB - части одного

компилятора● Фазы компиляции● Декларативность

Page 10: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

MsBuild● Properties● Items● Tasks● Imports● Targets

Page 11: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

MsBuild● Modules● Cobol and procedures● Shared state● Build procedure for tasks● Packages● Complexity

Page 12: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

CsHtml<script> var t = $(@ToCss(“.myClass {color:red}”)); </script>

Page 13: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Code Sharing.● Universal apps:

SHARED

A B

Page 14: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Issues● Common symbol space● Tooling● Imperative in xml● Complexity● Observability● Debug● Extensibility

Page 15: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

R# Experience<action Text=”Foo”Handler=”Bar”>

[Handler(“Bar”)]class Foo: IAction {}

[Action(...)]class Foo : IAction, IInsertAfter<X,Y>{}

Page 16: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

R# ExperienceXml Configuration:<Assembly Name=”X” Configurations = “VSSince10”/>

Zones configuration:[ZoneMarker]class Zone : IRequire<ISinceVs10>{}

Page 17: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

R# Experiencestatic class Build { [BuildStep] DotPeekSingleExe[] PackDotPeek(Package[] packages) { …. }}

Page 18: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

R# Experience[SettingsKey]class IntelliSenseSettings { [SettingsEntry(“Code completion enabled”)] bool CodeCompletionEnabled;}

Page 19: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

R# Experience● Metadata model

○ Metadata layer○ No assembly load○ Advances features in IOC container○ Build time○ Runtime type bindings on demand

Page 20: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Code is data● Refactoring● Build transformation● Roslyn● Reflection● PostSharp

Page 21: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

meta C#● String literals

○ No semantic checks○ No support in tooling○ No interop with type system○ Expressive!

Page 22: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

meta C#● Attributes

○ Primitives, constants, arrays, typeof○ Metadata access○ Runtime access○

Page 23: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

meta C#● Interfaces

○ Generics ○ Inheritance

● Classes○ + Constructors

Page 24: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

meta C#● Hierarchy and IOC

Page 25: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

meta C#● Fields

Page 26: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

meta C#● Fields

○ = Type + Name○ C# 6 - nameof(expr)○ Expression trees

Page 27: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Build● Access metadata at build time● Build for build steps● Consume packages● Build packages● Transfer build state● Use build artifacts at runtime● Composability

Page 28: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

R# experience● Build bootstrap

○ Compile build sources○ Per-package build scirpt○ Limited set of APIes○ Prepare solution for editing○ Pass build settings (configuration)○ Substitute binary dependencies

Page 29: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

R# experience● Compile is simple

○ < 10 custom targets○ 1 custom import in project files○ MsBuild

Page 30: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

R# experience● Build graph

Page 31: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

CI configuration● TeamCity

○ 28 configurations○ 50 build agents○ 20-30 branches a day○ Builds exchange serializable artifacts○ Build requests artifact type.

Page 32: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Takeaway● Declarative is not xml● Keep extensions imperative● Apply Solid to declarative ● Make declarative simple● Never introduce shared state●

Page 33: Почему только C#public.jugru.org/dotnext/2014/moscow/shkredov.pdf · ASP.Net vNext Roslyn and C# 6 Xamarin and Mono Visual Studio Community ... Declarative Imperative

Thanks.