Microsoft .NET Programming platform for the next decade
Download
Report
Transcript Microsoft .NET Programming platform for the next decade
Microsoft .NET
Programming platform for the next decade
Anders Hejlsberg
Distinguished Engineer
Developer Division
Shifting decades
3270
1970s
1980s
HTML
File Sharing
1990s
XML Era
Server-centric
Computing
Client-centric
Computing
2000
A rich history
XML
Web Services
1995
Internet
1990
GUI
1981
PC
MS-DOS
BASIC
IE, IIS
Visual Studio
Windows
Visual BASIC
Visual
Studio
.NET
The .NET Framework
Programming platform for the next decade
Natively supports XML Web Services
Unifies programming models
Dramatically simplifies development
Provides robust execution environment
Supports multiple programming
languages
The .NET Framework
VB
C++
C#
JScript
…
Common Language Specification
Windows
Forms
ADO.NET and XML
Base Class Library
Common Language Runtime
Operating System
Visual Studio.NET
ASP.NET
Web Forms Web Services
Mobile Internet Toolkit
Unified programming models
Consistent API availability regardless of
language and programming model
.NET Framework
RAD,
Composition,
Delegation
VB Forms
Subclassing,
Power,
Expressiveness
MFC/ATL
Windows API
Server based,
Stateless,
Projected UI
ASP
Simplified development
Higher level of abstraction
Unified type system
Everything is an object, no variants, one
string type, all character data is Unicode
Software components
No low-level COM plumbing
Object-oriented to the core
Properties, methods, events, and attributes
are first class constructs
Seamless interoperability
Simplified development
Windows API
HWND hwndMain = CreateWindowEx(
0, "MainWinClass", "Main Window",
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
(HWND)NULL, (HMENU)NULL, hInstance, NULL);
ShowWindow(hwndMain, SW_SHOWDEFAULT);
UpdateWindow(hwndMain);
.NET Framework
Form form = new Form();
form.Text = "Main Window";
form.Show();
Robust environment
Automatic lifetime management
Exception handling
Error handling 1st class and mandatory
Type-safety
All objects are garbage collected
No unsafe casts, uninitialized variables
Deployment and management
Assemblies, side-by-side execution
No more DLL hell!
Multi-language platform
The .NET Platform is language neutral
Microsoft is providing
All .NET languages are first class players
Complete cross-language integration
Highly leveraged tools
VB, C++, C#, Java, JScript
Industry and academia
APL, COBOL, Eiffel, Fortran, Haskell, ML,
Perl, Python, RPG, Scheme, Smalltalk, …
What is a Web Service?
HTML == user-to-machine
XML/SOAP == machine-to-machine
Leveraging the Web
Same infrastructure
Same programming model
Anyone can play
Truly scalable distributed apps
Stateless, loosely coupled, flexible protocol
Both Internet and Intranet
What is the foundation?
Simple, open, broad industry support
Directory of services:
UDDI
Service discovery:
DISCO
Service descriptions:
WSDL
Service interactions:
SOAP
Universal type system:
XSD
Universal data format:
XML
Ubiquitous communication:
Internet
How does it work?
Find a Service
http://www.uddi.org
Link to DISCO or WSDL document
UDDI
Discovery
Web
Service
Consumer
http://myservice.com
HTML or XML with link to WSDL
How do we talk? (WSDL)
http://myservice.com?wsdl
XML with service descriptions
Let’s talk (SOAP)
http://myservice.com/svc1
XML/SOAP BODY
Web
Service
Web Services with .NET
The .NET Framework provides
a bi-directional mapping
Application
Concepts
Web
Programs
Data
XML
Objects
Schema
XSD
Classes
Services
WSDL
Methods
Invocation
SOAP
Calls
Web Services with .NET
public class OrderProcessor
{
[WebMethod]
public
void SubmitOrder(PurchaseOrder
<?xml version="1.0"
encoding="utf-8"?>order) {...}
} <soap:Envelope>
<soap:Body>
[XmlRoot("Order",
Namespace="urn:acme.b2b-schema.v1")]
<SubmitOrder>
public class
PurchaseOrder
<Order
date=“20010703">
{
<shipTo>Anders Hejlsberg</shipTo>
public string
[XmlElement("shipTo")]
ShipTo; Gates</billTo>
public string ShipTo;
<billTo>Bill
public string
[XmlElement("billTo")]
BillTo;
public
string BillTo;
<comment>Overnight
delivery</comment>
public string
[XmlElement("comment")]
Comment; public string Comment;
<items>
PurchaseOrder
poItems;
= new PurchaseOrder();
public Item[]
[XmlElement("items")]
public Item[] Items;
<productId>17748933</productId>
po.ShipTo
=
“Anders
Hejlsberg";
public DateTime
[XmlAttribute("date")]
OrderDate;
public
DateTime OrderDate;
<description>Dom
Perignon</description>
“Bill Gates";
} po.BillTo =</items>
po.OrderDate
= DateTime.Today;
</Order>
…
</SubmitOrder>
OrderProcessor.SubmitOrder(order);
</soap:Body>
</soap:Envelope>
Web Services demo
The C# language
Component oriented
Unified and extensible type system
Versioning
Interoperability
Pragmatic language design
Components
What defines a component?
C# has first class support
Properties, methods, events
Integrated help and documentation
Design time and run-time attributes
Not naming patterns, adapters, etc.
Not external files
Components easy to build and consume
Components
Properties are a first class construct
public class Button: Control
{
private string text;
public string Caption {
get {
return text;
}
set {
text = value;
Repaint();
}
}
}
Button b = new Button();
b.Caption = "OK";
String s = b.Caption;
Unified type system
Traditional views of primitive types
C# unifies with no performance cost
C++, Java: They’re “magic”
Smalltalk, Lisp: They’re full-blown objects
Deep simplicity throughout system
Improved extensibility and reusability
New primitive types: Decimal, SQL…
Collections, etc., work for all types
Unified type system
All types ultimately inherit from object
Any piece of data can be stored,
transported, and manipulated with no
extra work
object
Stream
MemoryStream
Hashtable
FileStream
int
double
Unified type system
Boxing
Allocates box, copies value into it
Unboxing
Checks type of box, copies value out
int i = 123;
object o = i;
int j = (int)o;
i
123
System.Int32
o
j
123
123
Unified type system
Benefits
Eliminates “wrapper classes”
Collection classes work with all types
Replaces OLE Automation's Variant
Lots of examples in .NET Framework
string s = string.Format(
"Your total was {0} on {1}", total, date);
Hashtable t = new Hashtable();
t.Add(0, "zero");
t.Add(1, "one");
t.Add(2, "two");
Versioning
Overlooked in most languages
C++ and Java produce fragile base classes
Pervasive versioning considerations in
C# language design
Virtual methods and overriding
Overload resolution
Explicit interface implementation
const vs. readonly fields
Defaults for accessibility and virtuality
Versioning
class Base
// version 2
1
{
} public virtual void Foo() {
Console.WriteLine("Base.Foo");
}
}
class Derived: Base
// version 2b
1
2a
{
new public
public
virtual
override
virtual
void
void
void
Foo()
Foo()
Foo()
{{ {
Console.WriteLine("Derived.Foo");
base.Foo();
} Console.WriteLine("Derived.Foo");
} }
}
Interoperability
.NET Languages
XML/SOAP
VB.NET
MC++
JScript
...
C#
COM
OLE Automation
P/Invoke and unsafe code
Dynamic Link Libraries
Pragmatic language design
C++ heritage
Real-world useful constructs
Namespaces, enums, unsigned types, etc.
Have only one way to do one thing!
Don’t make me pay every day!
foreach, using, switch on string
decimal type for financial applications
ref and out parameters
Put the fun back in coding!
C# and CLI standardization
Work begun in September 2000
Active involvement by Intel, HP, IBM,
Fujitsu, Plum Hall, …
Technical work complete
ECMA votes this month
Fast-track to ISO