microsoft.net programming platform for the next decade anders hejlsberg distinguished engineer...

29
Microsoft .NET Microsoft .NET Programming platform for the next Programming platform for the next decade decade Anders Hejlsberg Anders Hejlsberg Distinguished Engineer Distinguished Engineer Developer Division Developer Division

Post on 21-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Microsoft .NETMicrosoft .NETProgramming platform for the next decadeProgramming platform for the next decade

Anders HejlsbergAnders Hejlsberg

Distinguished EngineerDistinguished EngineerDeveloper DivisionDeveloper Division

Server-centric Server-centric ComputingComputing

Client-centric Client-centric ComputingComputing

XML EraXML Era

Shifting decadesShifting decades

1980s1980s File File SharingSharing

1990s1990sHTMLHTML

1970s1970s32703270

19901990GUIGUI

19811981PCPC

A rich historyA rich history

19951995InternetInternet

MS-DOSMS-DOSBASICBASIC

WindowsWindowsVisual BASICVisual BASIC

IE, IISIE, IISVisual StudioVisual Studio

XMLXMLWeb ServicesWeb Services

20002000

VisualVisualStudioStudio.NET.NET

The .NET FrameworkThe .NET FrameworkProgramming platform for the next decadeProgramming platform for the next decade

Natively supports XML Web ServicesNatively supports XML Web Services Unifies programming modelsUnifies programming models Dramatically simplifies developmentDramatically simplifies development Provides robust execution environmentProvides robust execution environment Supports multiple programming Supports multiple programming

languageslanguages

Operating System

Common Language Runtime

Base Class Library

ADO.NET and XML

ASP.NETWeb Forms Web Services

Mobile Internet Toolkit

WindowsForms

Common Language Specification

VB C++ C# JScript …

Visu

al S

tud

io.N

ET

The .NET FrameworkThe .NET Framework

Unified programming modelsUnified programming models

Windows API

.NET Framework

Consistent API availability regardless oflanguage and programming model

ASP

Server based,Stateless,

Projected UI

MFC/ATL

Subclassing,Power,

Expressiveness

VB Forms

RAD,Composition,

Delegation

Simplified developmentSimplified development

Higher level of abstractionHigher level of abstraction No low-level COM plumbingNo low-level COM plumbing Object-oriented to the coreObject-oriented to the core

Unified type systemUnified type system Everything is an object, no variants, one Everything is an object, no variants, one

string type, all character data is Unicodestring type, all character data is Unicode

Software componentsSoftware components Properties, methods, events, and attributes Properties, methods, events, and attributes

are first class constructsare first class constructs

Seamless interoperabilitySeamless interoperability

Simplified developmentSimplified development

HWND hwndMain = CreateWindowEx(HWND hwndMain = CreateWindowEx( 0, "MainWinClass", "Main Window",0, "MainWinClass", "Main Window", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, (HWND)NULL, (HMENU)NULL, hInstance, NULL); (HWND)NULL, (HMENU)NULL, hInstance, NULL); ShowWindow(hwndMain, SW_SHOWDEFAULT); ShowWindow(hwndMain, SW_SHOWDEFAULT); UpdateWindow(hwndMain);UpdateWindow(hwndMain);

Form form = new Form();Form form = new Form();form.Text = "Main Window";form.Text = "Main Window";form.Show();form.Show();

Windows API

.NET Framework

Robust environmentRobust environment

Automatic lifetime managementAutomatic lifetime management All objects are garbage collectedAll objects are garbage collected

Exception handlingException handling Error handling 1Error handling 1stst class and mandatory class and mandatory

Type-safetyType-safety No unsafe casts, uninitialized variablesNo unsafe casts, uninitialized variables

Deployment and managementDeployment and management Assemblies, side-by-side executionAssemblies, side-by-side execution No more DLL hell!No more DLL hell!

Multi-language platformMulti-language platform

The .NET Platform is language neutralThe .NET Platform is language neutral All .NET languages are first class playersAll .NET languages are first class players Complete cross-language integrationComplete cross-language integration Highly leveraged toolsHighly leveraged tools

Microsoft is providingMicrosoft is providing VB, C++, C#, Java, JScriptVB, C++, C#, Java, JScript

Industry and academiaIndustry and academia APL, COBOL, Eiffel, Fortran, Haskell, ML, APL, COBOL, Eiffel, Fortran, Haskell, ML,

Perl, Python, RPG, Scheme, Smalltalk, …Perl, Python, RPG, Scheme, Smalltalk, …

What is a Web Service?What is a Web Service?

HTML == user-to-machineHTML == user-to-machine XML/SOAP == machine-to-machineXML/SOAP == machine-to-machine Leveraging the WebLeveraging the Web

Same infrastructureSame infrastructure Same programming modelSame programming model Anyone can playAnyone can play

Truly scalable distributed appsTruly scalable distributed apps Stateless, loosely coupled, flexible protocolStateless, loosely coupled, flexible protocol Both Internet and IntranetBoth Internet and Intranet

What is the foundation?What is the foundation?

Ubiquitous communication: Internet

Universal data format: XML

Universal type system: XSD

Service interactions: SOAP

Service descriptions: WSDL

Service discovery: DISCO

Directory of services: UDDI

Simple, open, broad industry supportSimple, open, broad industry support

DiscoveryDiscovery

Let’s talk (SOAP)Let’s talk (SOAP)

How does it work?How does it work?

http://myservice.comhttp://myservice.com

HTML or XML with link to WSDLHTML or XML with link to WSDL

How do we talk? (WSDL)How do we talk? (WSDL)http://myservice.com?wsdlhttp://myservice.com?wsdl

XML with service descriptionsXML with service descriptions

http://myservice.com/svc1http://myservice.com/svc1

XML/SOAP BODYXML/SOAP BODY

Web Web ServiceService

WebWebService Service

ConsumerConsumer

UDDIUDDI

Find a ServiceFind a Servicehttp://www.uddi.orghttp://www.uddi.org

Link to DISCO or WSDL documentLink to DISCO or WSDL document

Web Services with .NETWeb Services with .NET

Programs

Objects

Classes

Methods

Calls

Web

XML

XSD

WSDL

SOAP

Data

Schema

Services

Invocation

ApplicationConcepts

The .NET Framework providesa bi-directional mapping

public class OrderProcessorpublic class OrderProcessor{{

public void SubmitOrder(PurchaseOrder order) {...}public void SubmitOrder(PurchaseOrder order) {...}}}

public class PurchaseOrderpublic class PurchaseOrder{{ public string ShipTo;public string ShipTo; public string BillTo;public string BillTo; public string Comment;public string Comment; public Item[] Items;public Item[] Items; public DateTime OrderDate;public DateTime OrderDate;}}

Web Services with .NETWeb Services with .NETpublic class OrderProcessorpublic class OrderProcessor{{ [WebMethod][WebMethod] public void SubmitOrder(PurchaseOrder order) {...}public void SubmitOrder(PurchaseOrder order) {...}}}

[XmlRoot("Order", Namespace="urn:acme.b2b-schema.v1")][XmlRoot("Order", Namespace="urn:acme.b2b-schema.v1")]public class PurchaseOrderpublic class PurchaseOrder{{ [XmlElement("shipTo")][XmlElement("shipTo")] public string ShipTo; public string ShipTo; [XmlElement("billTo")][XmlElement("billTo")] public string BillTo; public string BillTo; [XmlElement("comment")][XmlElement("comment")] public string Comment; public string Comment; [XmlElement("items")][XmlElement("items")] public Item[] Items; public Item[] Items; [XmlAttribute("date")][XmlAttribute("date")] public DateTime OrderDate; public DateTime OrderDate;}}

PurchaseOrder po = new PurchaseOrder();PurchaseOrder po = new PurchaseOrder();po.ShipTo = “Anders Hejlsberg";po.ShipTo = “Anders Hejlsberg";po.BillTo = “Bill Gates";po.BillTo = “Bill Gates";po.OrderDate = DateTime.Today;po.OrderDate = DateTime.Today;……OrderProcessor.SubmitOrder(order);OrderProcessor.SubmitOrder(order);

<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?><soap:Envelope><soap:Envelope> <soap:Body><soap:Body> <SubmitOrder><SubmitOrder> <Order date=“20010703"><Order date=“20010703"> <shipTo>Anders Hejlsberg</shipTo><shipTo>Anders Hejlsberg</shipTo> <billTo>Bill Gates</billTo><billTo>Bill Gates</billTo> <comment>Overnight delivery</comment><comment>Overnight delivery</comment> <items><items> <productId>17748933</productId><productId>17748933</productId> <description>Dom Perignon</description><description>Dom Perignon</description> </items></items> </Order></Order> </SubmitOrder></SubmitOrder> </soap:Body></soap:Body></soap:Envelope></soap:Envelope>

Web Services demoWeb Services demo

The C# languageThe C# language

Component orientedComponent oriented Unified and extensible type systemUnified and extensible type system VersioningVersioning InteroperabilityInteroperability Pragmatic language designPragmatic language design

ComponentsComponents

What defines a component?What defines a component? Properties, methods, eventsProperties, methods, events Integrated help and documentationIntegrated help and documentation Design time and run-time attributesDesign time and run-time attributes

C# has first class supportC# has first class support Not naming patterns, adapters, etc.Not naming patterns, adapters, etc. Not external filesNot external files

Components easy to build and consumeComponents easy to build and consume

ComponentsComponents

Properties are a first class constructProperties are a first class construct

public class Button: Controlpublic class Button: Control{{ private string text;private string text;

public string Caption {public string Caption { get {get { return text;return text; }} set {set { text = value;text = value; Repaint();Repaint(); }} }}}}

Button b = new Button();Button b = new Button();b.Caption = "OK";b.Caption = "OK";String s = b.Caption;String s = b.Caption;

Unified type systemUnified type system

Traditional views of primitive typesTraditional views of primitive types C++, Java: They’re “magic”C++, Java: They’re “magic” Smalltalk, Lisp: They’re full-blown objectsSmalltalk, Lisp: They’re full-blown objects

C# unifies with no performance costC# unifies with no performance cost Deep simplicity throughout systemDeep simplicity throughout system

Improved extensibility and reusabilityImproved extensibility and reusability New primitive types: Decimal, SQL…New primitive types: Decimal, SQL… Collections, etc., work for all typesCollections, etc., work for all types

Unified type systemUnified type system

All types ultimately inherit from objectAll types ultimately inherit from object Any piece of data can be stored, Any piece of data can be stored,

transported, and manipulated with no transported, and manipulated with no extra workextra work

StreamStream

MemoryStreamMemoryStream FileStreamFileStream

HashtableHashtable doubledoubleintint

objectobject

Unified type systemUnified type system

BoxingBoxing Allocates box, copies value into itAllocates box, copies value into it

UnboxingUnboxing Checks type of box, copies value outChecks type of box, copies value out

int i = 123;int i = 123;object o = i;object o = i;int j = (int)o;int j = (int)o;

123123i

o

123123

System.Int32System.Int32

123123j

Unified type systemUnified type system

BenefitsBenefits Eliminates “wrapper classes”Eliminates “wrapper classes” Collection classes work with all typesCollection classes work with all types Replaces OLE Automation's VariantReplaces OLE Automation's Variant

Lots of examples in .NET FrameworkLots of examples in .NET Framework

string s = string.Format(string s = string.Format( "Your total was {0} on {1}", total, date);"Your total was {0} on {1}", total, date);

Hashtable t = new Hashtable();Hashtable t = new Hashtable();t.Add(0, "zero");t.Add(0, "zero");t.Add(1, "one");t.Add(1, "one");t.Add(2, "two");t.Add(2, "two");

VersioningVersioning

Overlooked in most languagesOverlooked in most languages C++ and Java produce fragile base classes C++ and Java produce fragile base classes

Pervasive versioning considerations in Pervasive versioning considerations in C# language designC# language design Virtual methods and overridingVirtual methods and overriding Overload resolutionOverload resolution Explicit interface implementationExplicit interface implementation const vs. readonly fieldsconst vs. readonly fields Defaults for accessibility and virtualityDefaults for accessibility and virtuality

VersioningVersioning

class Derived: Baseclass Derived: Base // version 1// version 1{{ public virtual void Foo() {public virtual void Foo() { Console.WriteLine("Derived.Foo"); Console.WriteLine("Derived.Foo"); }}}}

class Derived: Baseclass Derived: Base // version 2a// version 2a{{ new public virtual void Foo() {new public virtual void Foo() { Console.WriteLine("Derived.Foo"); Console.WriteLine("Derived.Foo"); }}}}

class Derived: Baseclass Derived: Base // version 2b// version 2b{{ public override void Foo() {public override void Foo() { base.Foo();base.Foo(); Console.WriteLine("Derived.Foo"); Console.WriteLine("Derived.Foo"); }}}}

class Baseclass Base // version 1// version 1{{}}

class Base class Base // version 2 // version 2 {{ public virtual void Foo() {public virtual void Foo() { Console.WriteLine("Base.Foo"); Console.WriteLine("Base.Foo"); }}}}

InteroperabilityInteroperability

C#C#

VB.NETVB.NET

MC++MC++

JScript JScript

... ...

.NET Languages.NET Languages

COMCOMOLE AutomationOLE Automation

XML/SOAPXML/SOAP

Dynamic Link LibrariesDynamic Link Libraries

P/Invoke and unsafe codeP/Invoke and unsafe code

Pragmatic language designPragmatic language design

C++ heritageC++ heritage Namespaces, enums, unsigned types, etc.Namespaces, enums, unsigned types, etc. Have only one way to do one thing!Have only one way to do one thing! Don’t make me pay every day!Don’t make me pay every day!

Real-world useful constructsReal-world useful constructs foreach, using, switch on stringforeach, using, switch on string decimal type for financial applicationsdecimal type for financial applications ref and out parametersref and out parameters

Put the fun back in coding!Put the fun back in coding!

C# and CLI standardizationC# and CLI standardization

Work begun in September 2000Work begun in September 2000 Active involvement by Intel, HP, IBM, Active involvement by Intel, HP, IBM,

Fujitsu, Plum Hall, …Fujitsu, Plum Hall, … Technical work completeTechnical work complete ECMA votes this monthECMA votes this month Fast-track to ISOFast-track to ISO